Skip to content

Specification for reusable hardware configurations#4833

Open
AthreyVinay wants to merge 6 commits into
mainfrom
avinay-hardware-custom-filter-spec
Open

Specification for reusable hardware configurations#4833
AthreyVinay wants to merge 6 commits into
mainfrom
avinay-hardware-custom-filter-spec

Conversation

@AthreyVinay
Copy link
Copy Markdown
Member

resolves: #4693

Pull Request Checklist

  • update the specification

@AthreyVinay AthreyVinay added this to the 1.73 milestone Apr 27, 2026
@AthreyVinay AthreyVinay added the specification Metadata specification (core, tests, plans, stories) label Apr 27, 2026
@AthreyVinay AthreyVinay added area | hardware Implementation of hardware requirements ci | full test Pull request is ready for the full test execution labels Apr 27, 2026
@github-project-automation github-project-automation Bot moved this to backlog in planning Apr 27, 2026
@AthreyVinay AthreyVinay moved this from backlog to review in planning Apr 27, 2026
@AthreyVinay AthreyVinay changed the title Document specification Introduce hostfilter for reusable hardware configurations Apr 27, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new specification for referencing external hardware filter configurations via the hostfilter key in .fmf files. The feedback suggests ensuring the description field starts with the summary text to maintain consistency with existing documentation standards.

Comment thread spec/hardware/hostfilter.fmf Outdated
Comment thread spec/hardware/hostfilter.fmf Outdated
Comment thread spec/hardware/hostfilter.fmf Outdated
Comment thread spec/hardware/hostfilter.fmf Outdated
@AthreyVinay AthreyVinay changed the title Introduce hostfilter for reusable hardware configurations Add support for reusable hardware configurations Apr 28, 2026
@AthreyVinay AthreyVinay force-pushed the avinay-hardware-custom-filter-spec branch from 9c8fe30 to 9fcc235 Compare April 28, 2026 18:25
Comment thread spec/hardware/preset.fmf
@thrix thrix self-requested a review May 2, 2026 20:33
@thrix
Copy link
Copy Markdown
Contributor

thrix commented May 2, 2026

@AthreyVinay so this is just adding the schema right? In that case I would update the description.

@AthreyVinay
Copy link
Copy Markdown
Member Author

AthreyVinay commented May 5, 2026

@AthreyVinay so this is just adding the schema right? In that case I would update the description.

yes, spec-only, following the same pattern as spec/hardware/gpu.fmf. Also, the same with # NOTE: not yet supported + commented-out link:. Is that ok @thrix?

@AthreyVinay AthreyVinay force-pushed the avinay-hardware-custom-filter-spec branch from 9fcc235 to 19b30be Compare May 5, 2026 17:54
@psss psss self-assigned this May 6, 2026
@psss psss changed the title Add support for reusable hardware configurations Specification for reusable hardware configurations May 6, 2026
@tcornell-bus tcornell-bus modified the milestones: 1.73, 1.74 May 7, 2026
Copy link
Copy Markdown
Member

@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, otherwise lgtm. Re the note, fine with or without it.

Comment thread spec/hardware/preset.fmf Outdated
Comment thread spec/hardware/preset.fmf
Comment thread spec/hardware/preset.fmf Outdated
memory: ">= 64 GB"

A filter reference expands to all of its defined constraints combined
with AND, and can be used anywhere a hardware constraint can appear.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part reads ambiguous. The AND there relates to the sibling keys, but this can read as if everything in the preset yaml is anded (whatever that would mean)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wording has been updated, @LecrisUT, please re-review.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LecrisUT Hi! Most of your comments must be addressed in latest spec:)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just to confirm, there is no more implicit and gluing and something like

    provision:
        hardware:
            import-preset:
                path: ~/.config/tmt/presets.yml
            preset: BIG_MEMORY
            cpu:
                model: 97

is forbidden? The current state is ambiguous about this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default way how hardware constraints are handled:

When multiple environment requirements are provided the provision implementation should attempt to satisfy all of them. It is also possible to write this explicitly using the and operator containing a list of dictionaries with individual requirements.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being explicit if it is supported or not and how it behaves would be appreciated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging still happens, as it always did, preset is just another key, and just like and or or keys it translates into a group of constraints. Same as the following:

    provision:
        hardware:
            import-preset:
                path: ~/.config/tmt/presets.yml
            preset: BIG_MEMORY
            cpu:
                model: 97
            memory: 4 GB

translates to:

        hardware:
            and:
              - whatever-is-behind-BIG_MEMORY
              - cpu:
                    model: 97
              - memory: 4 GB

Copy link
Copy Markdown
Member

@psss psss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for outlining the spec! I'm a bit hesitant about separating the preset fetch key from the hardware section. Wouldn't it be a bit better to group all hardware-related stuff under a single umbrella? Also, should we support multiple presets as well?

@bmeneg, could you please have a look at the proposed syntax? Any suggestions from your side?

Comment thread spec/hardware/preset.fmf Outdated
@happz
Copy link
Copy Markdown
Contributor

happz commented May 11, 2026

Thanks for outlining the spec! I'm a bit hesitant about separating the preset fetch key from the hardware section. Wouldn't it be a bit better to group all hardware-related stuff under a single umbrella?

Please, see the previous threads, namely #4833 (comment) and #4833 (comment).

Also, should we support multiple presets as well?

We already do. A single file can define multiple presets, and they can be used with the help of and:

hardware:
  - and:
      - preset: AMD__ROME
      - preset: BIG_MEMORY

Comment thread spec/hardware/preset.fmf Outdated
Comment thread spec/hardware/preset.fmf Outdated
Comment thread spec/hardware/preset.fmf Outdated
# Use a remote preset
provision:
hardware-preset:
url: https://github.com/my-team/presets.yml
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or alternatively it could be moved into hardware level? That way we could also merge the filter into it

I'd prefer not to have it there, although it would make some sense for sure.

I see that both approaches have some advantages. Although from implementation point of view the separate key could be (in some respect) a bit simpler, I'm trying to look at it from the user perspective and having all hardware-related stuff under one section currently wins.

Also from the separation of concerns perspective I'd say it makes a perfect sense if the Hardware class handles everything needed for the full hardware requirements parsing, including fetching the presets.

Allowing it under hardware would open new can of worms: would preset be allowed to used everywhere in the tree, should it be resolved first, what about backreferences?

It might not be such a big can of worms if we clearly state that the import-preset keyword needs to be only at the top level of the hardware key. From implementation point of view it would be just popping the key as the first step and then handling the rest as constraints.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, to summarize so @AthreyVinay can continue:

hardware:
  import-preset:
    - url: https://github.com/my-team/project/presets.yml
    - path: ~/.config/tmt/presets.yml
  and:
    - preset: AMD__ROME
    - preset: BIG_MEMORY
    - cpu:
        model: 79
  • import-preset and preset
  • import-preset allowed only on the top-level
  • preset is a string, not a string or list of strings
  • import-preset can be a mapping or list of mappings

Did I miss anything?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, exactly. Thanks for the summary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: abcd1b8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a patch that extends hardware key, allowing user to use a URL or a file (hardware: @foo.yaml, or --hardware http://...). I followed the syntax we use for envvar files (--environment @foo.env). Would it make sense, instead of path and url keys, use the same approach?

hardware:
  import-preset:
    - https://github.com/my-team/project/presets.yml
    - @~/.config/tmt/presets.yml

Or without @, that would work as well, since we have tmt.utils.is_url() helper we can use to tell whether the item looks like an URL or not, and handle it accordingly.

While I was hacking on that hardware patch, I noticed there's an opportunity for "load me content from this source" operation, used at several places, environment and hardware being two examples, this one seems like another. It would be nice to present a consistent input format eventually.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure +1 for consistency.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. +1 from me to drop the keys and just have a list of links. I would vote for not using @ as I understand it as instead of defining the value here check the file which is not the case here. We could also support the standard file:// prefix. So what about these three options?

hardware:
    import-preset:
      - https://github.com/my-team/project/presets.yml
      - file:///home/user/config/tmt/presets.yml
      - ~/.config/tmt/presets.yml

While I was hacking on that hardware patch, I noticed there's an opportunity for "load me content from this source" operation, used at several places, environment and hardware being two examples, this one seems like another. It would be nice to present a consistent input format eventually.

Agreed, would be nice to handle these consistently.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's also a +1 from my side on dropping the keywords and use links directly.

@psss psss moved this from review to implement in planning May 14, 2026
@happz happz moved this from implement to review in planning May 14, 2026
Comment thread spec/hardware/preset.fmf
Comment thread spec/hardware/preset.fmf
@AthreyVinay AthreyVinay force-pushed the avinay-hardware-custom-filter-spec branch 2 times, most recently from c03ce60 to f3d0ec1 Compare May 15, 2026 08:29
@AthreyVinay AthreyVinay force-pushed the avinay-hardware-custom-filter-spec branch from f3d0ec1 to ac88bda Compare May 15, 2026 08:35
Comment thread spec/hardware/preset.fmf
model: 49
- name: MEMORY_MIN_64G
hardware:
memory: ">= 64 GB"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking about simplification, what about using dictionary layout for the presets.yaml files? For the above-mentioned example it would look like this:

AMD__ROME:
    cpu:
        family: 23
        model: 49

BIG_MEMORY:
    memory: ">= 64 GB"

It's basically mapping a preset name to dictionary content. No need to repeat hardware again and again. Everything is a hardware preset.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the explicitness of having the hardware key. It reads more clearly how it connects to provision.hardware

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion here, but I like the explicitness too, making it clear it accepts only hardware definitions (seems obvious, but we never know...). However I also understand why removing the hardware does make sense: it gives the impression that the resulting mapping would be:

provision:
  hardware:
    # preset expanded here
    hardware:
      cpu:
        family: 23
        model: 49

@psss psss requested review from LecrisUT and happz May 15, 2026 08:53
@happz happz self-assigned this May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area | hardware Implementation of hardware requirements ci | full test Pull request is ready for the full test execution specification Metadata specification (core, tests, plans, stories)

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

Finalize the syntax for custom hardware filters

7 participants