hw/arm/aspeed_ast27x0-fc.c | 3 ++- hw/arm/aspeed_ast27x0_evb.c | 5 +++-- hw/arm/raspi.c | 21 +++++++++++++-------- hw/arm/raspi4b.c | 3 ++- hw/arm/virt.c | 5 +++-- hw/core/machine-qmp-cmds.c | 18 ++++++++++++++++++ hw/core/machine.c | 13 +++++++++++++ hw/hexagon/virt.c | 3 ++- hw/m68k/virt.c | 4 ++-- hw/or1k/virt.c | 3 ++- hw/riscv/virt.c | 4 +++- include/hw/core/boards.h | 3 +++ include/qom/object.h | 3 --- qapi/machine.json | 12 +++++++++++- qom/object.c | 4 ---- rust/qom/src/qom.rs | 1 - system/vl.c | 9 +++++++++ target/riscv/kvm/kvm-cpu.c | 1 - target/riscv/tcg/tcg-cpu.c | 1 - 19 files changed, 86 insertions(+), 30 deletions(-)
The 'is_available' callback on TypeInfo is based on a mistaken notion that we should filter out classes at registration time based on architecture. This creates new problems however, some already present and some which will impact a future multi-target binary * For introspection of the binaries' features, we have a dependancy on selecting a target before we can introspect features. It would require re-launching QEMU for each target, leading to lots of redundant introspection and a big time sink. It would also not be possible to introspect targets * It creates a circular dependancy on QOM initialization inside the QOM initialization code, since 'target_info()' itself uses QOM. This then requires further work to break by initializing QOM target info before the rest of QOM. * We have no means to introspect what targets a machine type can be used with, as this information is expressed as code (in target_XXXX() methods), instead of as data. * New fields in TypeInfo requires more changes to macros used for initializing machines. There is no inherant conceptual reason why we must filter out classes at type registration time. This is just a shortcut to workaround historical technical debt where certain classes have clashing names. This is an undesirable approach, as it is trading one set of problems for a new set of problems. This series proposes removal of the 'is_available' concept from QOM, and illustrates handling machines with full introspection support available from the MachineClass. This implies fixing the root cause, of clashing class names, but does not include patches since various series have already been posted for machine class name fixes. The machine changes are fairly simple * MachineClass gains a 'targets' field which is a bit mask of SysEmuTarget * machine_class_is_available() matches 'targets' against 'target_info()' * -machine CLI enforces machine_class_is_available() * query-machines filters on machine_class_is_available by default * query-machines gains 'all-targets': 'bool' to opt-in to returning the unfiltered list, with a 'targets' list present NB, this removes filtering from riscv CPUs with no alternative proposed. I'm unclear what this was trying to address to begin with, but utlimately it should be possible to address it with runtime filtering/matching of classes, instead of hiding TypeInfo registration. If someone gives me info on the CPUs problem I can a make a design suggestion. Daniel P. Berrangé (4): hw/core: record permitted targets against MachineClass hw: replace 'is_available' with 'targets' in machines target/riscv: remove 'is_available' from riscv CPUs qom: drop the 'is_available' callback from TypeInfo hw/arm/aspeed_ast27x0-fc.c | 3 ++- hw/arm/aspeed_ast27x0_evb.c | 5 +++-- hw/arm/raspi.c | 21 +++++++++++++-------- hw/arm/raspi4b.c | 3 ++- hw/arm/virt.c | 5 +++-- hw/core/machine-qmp-cmds.c | 18 ++++++++++++++++++ hw/core/machine.c | 13 +++++++++++++ hw/hexagon/virt.c | 3 ++- hw/m68k/virt.c | 4 ++-- hw/or1k/virt.c | 3 ++- hw/riscv/virt.c | 4 +++- include/hw/core/boards.h | 3 +++ include/qom/object.h | 3 --- qapi/machine.json | 12 +++++++++++- qom/object.c | 4 ---- rust/qom/src/qom.rs | 1 - system/vl.c | 9 +++++++++ target/riscv/kvm/kvm-cpu.c | 1 - target/riscv/tcg/tcg-cpu.c | 1 - 19 files changed, 86 insertions(+), 30 deletions(-) -- 2.56.0
On Thu, Nov 5, 2026 at 6:24 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> The 'is_available' callback on TypeInfo is based on a mistaken
Thanks, we realized the limitation of 'is_available', and discussed
with Pierrick a lot
about this, I implemented both ways to remove 'is_available' in my local branch.
One is this idea(these patches), add targets in MachineClass::targets,
but we have to rename "virt-machine" that
in conflict.
The other one also achieves the same effect, except no need to rename
"virt-machine" QOM type names, by introducing a private
TypeBucket in object.c I post a small series to answer you question,
in my local branch, "is_avaiable" is removed.
https://lore.kernel.org/qemu-devel/20261105190346.1539-1-luoyonggang@gmail.com/T/#t
In both local branches, there is no more QOM name conflict, and target
is selected till the machine selection. so that
have no target_info() access in class_init or type_init.
object_class_get_list(NULL, true); can be called without target
selection, the current question which direction is better.
Both ways works fine, and both ways have their advantages and disadvantages.
> notion that we should filter out classes at registration time
> based on architecture.
>
> This creates new problems however, some already present and
> some which will impact a future multi-target binary
>
> * For introspection of the binaries' features, we have
> a dependancy on selecting a target before we can
> introspect features. It would require re-launching
> QEMU for each target, leading to lots of redundant
> introspection and a big time sink. It would also not
> be possible to introspect targets
>
> * It creates a circular dependancy on QOM initialization
> inside the QOM initialization code, since 'target_info()'
> itself uses QOM. This then requires further work to break
> by initializing QOM target info before the rest of QOM.
>
> * We have no means to introspect what targets a machine
> type can be used with, as this information is expressed
> as code (in target_XXXX() methods), instead of as data.
>
> * New fields in TypeInfo requires more changes to macros
> used for initializing machines.
>
> There is no inherant conceptual reason why we must filter out
> classes at type registration time. This is just a shortcut to
> workaround historical technical debt where certain classes
> have clashing names. This is an undesirable approach, as it
> is trading one set of problems for a new set of problems.
>
> This series proposes removal of the 'is_available' concept
> from QOM, and illustrates handling machines with full introspection
> support available from the MachineClass.
>
> This implies fixing the root cause, of clashing class names,
> but does not include patches since various series have already
> been posted for machine class name fixes.
>
> The machine changes are fairly simple
>
> * MachineClass gains a 'targets' field which is a bit mask
> of SysEmuTarget
> * machine_class_is_available() matches 'targets' against
> 'target_info()'
> * -machine CLI enforces machine_class_is_available()
> * query-machines filters on machine_class_is_available
> by default
> * query-machines gains 'all-targets': 'bool' to opt-in
> to returning the unfiltered list, with a 'targets'
> list present
>
> NB, this removes filtering from riscv CPUs with no
> alternative proposed. I'm unclear what this was trying
> to address to begin with, but utlimately it should be
> possible to address it with runtime filtering/matching
> of classes, instead of hiding TypeInfo registration.
> If someone gives me info on the CPUs problem I can a
> make a design suggestion.
>
> Daniel P. Berrangé (4):
> hw/core: record permitted targets against MachineClass
> hw: replace 'is_available' with 'targets' in machines
> target/riscv: remove 'is_available' from riscv CPUs
> qom: drop the 'is_available' callback from TypeInfo
>
> hw/arm/aspeed_ast27x0-fc.c | 3 ++-
> hw/arm/aspeed_ast27x0_evb.c | 5 +++--
> hw/arm/raspi.c | 21 +++++++++++++--------
> hw/arm/raspi4b.c | 3 ++-
> hw/arm/virt.c | 5 +++--
> hw/core/machine-qmp-cmds.c | 18 ++++++++++++++++++
> hw/core/machine.c | 13 +++++++++++++
> hw/hexagon/virt.c | 3 ++-
> hw/m68k/virt.c | 4 ++--
> hw/or1k/virt.c | 3 ++-
> hw/riscv/virt.c | 4 +++-
> include/hw/core/boards.h | 3 +++
> include/qom/object.h | 3 ---
> qapi/machine.json | 12 +++++++++++-
> qom/object.c | 4 ----
> rust/qom/src/qom.rs | 1 -
> system/vl.c | 9 +++++++++
> target/riscv/kvm/kvm-cpu.c | 1 -
> target/riscv/tcg/tcg-cpu.c | 1 -
> 19 files changed, 86 insertions(+), 30 deletions(-)
>
> --
> 2.56.0
>
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
On 11/5/2026 11:18 AM, Yonggang Luo wrote: > On Thu, Nov 5, 2026 at 6:24 PM Daniel P. Berrangé <berrange@redhat.com> wrote: >> >> The 'is_available' callback on TypeInfo is based on a mistaken > > Thanks, we realized the limitation of 'is_available', and discussed > with Pierrick a lot > about this, I implemented both ways to remove 'is_available' in my local branch. > > One is this idea(these patches), add targets in MachineClass::targets, > but we have to rename "virt-machine" that > in conflict. > > The other one also achieves the same effect, except no need to rename > "virt-machine" QOM type names, by introducing a private > TypeBucket in object.c I post a small series to answer you question, > in my local branch, "is_avaiable" is removed. > https://lore.kernel.org/qemu-devel/20261105190346.1539-1-luoyonggang@gmail.com/T/#t > > > In both local branches, there is no more QOM name conflict, and target > is selected till the machine selection. so that > have no target_info() access in class_init or type_init. > object_class_get_list(NULL, true); can be called without target > selection, the current question which direction is better. > Both ways works fine, and both ways have their advantages and disadvantages. > I was waiting for Daniel to explicitly describe what is expected: implement it is even better. Now that we have the two approaches clearly described, I'll let Daniel pick and finalize the one he wants to see for this new binary. Only requirement is that it has to build and pass the multi target test, so we know there is no regression. Thanks for your work and persistence on this Yonggang. > > >> notion that we should filter out classes at registration time >> based on architecture. >> >> This creates new problems however, some already present and >> some which will impact a future multi-target binary >> >> * For introspection of the binaries' features, we have >> a dependancy on selecting a target before we can >> introspect features. It would require re-launching >> QEMU for each target, leading to lots of redundant >> introspection and a big time sink. It would also not >> be possible to introspect targets >> >> * It creates a circular dependancy on QOM initialization >> inside the QOM initialization code, since 'target_info()' >> itself uses QOM. This then requires further work to break >> by initializing QOM target info before the rest of QOM. >> >> * We have no means to introspect what targets a machine >> type can be used with, as this information is expressed >> as code (in target_XXXX() methods), instead of as data. >> >> * New fields in TypeInfo requires more changes to macros >> used for initializing machines. >> >> There is no inherant conceptual reason why we must filter out >> classes at type registration time. This is just a shortcut to >> workaround historical technical debt where certain classes >> have clashing names. This is an undesirable approach, as it >> is trading one set of problems for a new set of problems. >> >> This series proposes removal of the 'is_available' concept >> from QOM, and illustrates handling machines with full introspection >> support available from the MachineClass. >> >> This implies fixing the root cause, of clashing class names, >> but does not include patches since various series have already >> been posted for machine class name fixes. >> >> The machine changes are fairly simple >> >> * MachineClass gains a 'targets' field which is a bit mask >> of SysEmuTarget >> * machine_class_is_available() matches 'targets' against >> 'target_info()' >> * -machine CLI enforces machine_class_is_available() >> * query-machines filters on machine_class_is_available >> by default >> * query-machines gains 'all-targets': 'bool' to opt-in >> to returning the unfiltered list, with a 'targets' >> list present >> >> NB, this removes filtering from riscv CPUs with no >> alternative proposed. I'm unclear what this was trying >> to address to begin with, but utlimately it should be >> possible to address it with runtime filtering/matching >> of classes, instead of hiding TypeInfo registration. >> If someone gives me info on the CPUs problem I can a >> make a design suggestion. > > > >> >> Daniel P. Berrangé (4): >> hw/core: record permitted targets against MachineClass >> hw: replace 'is_available' with 'targets' in machines >> target/riscv: remove 'is_available' from riscv CPUs >> qom: drop the 'is_available' callback from TypeInfo >> >> hw/arm/aspeed_ast27x0-fc.c | 3 ++- >> hw/arm/aspeed_ast27x0_evb.c | 5 +++-- >> hw/arm/raspi.c | 21 +++++++++++++-------- >> hw/arm/raspi4b.c | 3 ++- >> hw/arm/virt.c | 5 +++-- >> hw/core/machine-qmp-cmds.c | 18 ++++++++++++++++++ >> hw/core/machine.c | 13 +++++++++++++ >> hw/hexagon/virt.c | 3 ++- >> hw/m68k/virt.c | 4 ++-- >> hw/or1k/virt.c | 3 ++- >> hw/riscv/virt.c | 4 +++- >> include/hw/core/boards.h | 3 +++ >> include/qom/object.h | 3 --- >> qapi/machine.json | 12 +++++++++++- >> qom/object.c | 4 ---- >> rust/qom/src/qom.rs | 1 - >> system/vl.c | 9 +++++++++ >> target/riscv/kvm/kvm-cpu.c | 1 - >> target/riscv/tcg/tcg-cpu.c | 1 - >> 19 files changed, 86 insertions(+), 30 deletions(-) >> >> -- >> 2.56.0 >> > >
On 11/5/2026 2:24 AM, Daniel P. Berrangé wrote: > The 'is_available' callback on TypeInfo is based on a mistaken > notion that we should filter out classes at registration time > based on architecture. > > This creates new problems however, some already present and > some which will impact a future multi-target binary > > * For introspection of the binaries' features, we have > a dependancy on selecting a target before we can > introspect features. It would require re-launching > QEMU for each target, leading to lots of redundant > introspection and a big time sink. It would also not > be possible to introspect targets > > * It creates a circular dependancy on QOM initialization > inside the QOM initialization code, since 'target_info()' > itself uses QOM. This then requires further work to break > by initializing QOM target info before the rest of QOM. > > * We have no means to introspect what targets a machine > type can be used with, as this information is expressed > as code (in target_XXXX() methods), instead of as data. > > * New fields in TypeInfo requires more changes to macros > used for initializing machines. > > There is no inherant conceptual reason why we must filter out > classes at type registration time. This is just a shortcut to > workaround historical technical debt where certain classes > have clashing names. This is an undesirable approach, as it > is trading one set of problems for a new set of problems. > > This series proposes removal of the 'is_available' concept > from QOM, and illustrates handling machines with full introspection > support available from the MachineClass. > > This implies fixing the root cause, of clashing class names, > but does not include patches since various series have already > been posted for machine class name fixes. > > The machine changes are fairly simple > > * MachineClass gains a 'targets' field which is a bit mask > of SysEmuTarget > * machine_class_is_available() matches 'targets' against > 'target_info()' > * -machine CLI enforces machine_class_is_available() > * query-machines filters on machine_class_is_available > by default > * query-machines gains 'all-targets': 'bool' to opt-in > to returning the unfiltered list, with a 'targets' > list present > > NB, this removes filtering from riscv CPUs with no > alternative proposed. I'm unclear what this was trying > to address to begin with, but utlimately it should be > possible to address it with runtime filtering/matching > of classes, instead of hiding TypeInfo registration. > If someone gives me info on the CPUs problem I can a > make a design suggestion. > > Daniel P. Berrangé (4): > hw/core: record permitted targets against MachineClass > hw: replace 'is_available' with 'targets' in machines > target/riscv: remove 'is_available' from riscv CPUs > qom: drop the 'is_available' callback from TypeInfo > > hw/arm/aspeed_ast27x0-fc.c | 3 ++- > hw/arm/aspeed_ast27x0_evb.c | 5 +++-- > hw/arm/raspi.c | 21 +++++++++++++-------- > hw/arm/raspi4b.c | 3 ++- > hw/arm/virt.c | 5 +++-- > hw/core/machine-qmp-cmds.c | 18 ++++++++++++++++++ > hw/core/machine.c | 13 +++++++++++++ > hw/hexagon/virt.c | 3 ++- > hw/m68k/virt.c | 4 ++-- > hw/or1k/virt.c | 3 ++- > hw/riscv/virt.c | 4 +++- > include/hw/core/boards.h | 3 +++ > include/qom/object.h | 3 --- > qapi/machine.json | 12 +++++++++++- > qom/object.c | 4 ---- > rust/qom/src/qom.rs | 1 - > system/vl.c | 9 +++++++++ > target/riscv/kvm/kvm-cpu.c | 1 - > target/riscv/tcg/tcg-cpu.c | 1 - > 19 files changed, 86 insertions(+), 30 deletions(-) > Thanks for posting the series. Would that be possible to complete it so that beyond compilation, test ./build/tests/unit/test-multi-target passes also? At the moment it fails with duplicated types being registered. That's why this is_available was introduced in the first place. It was just a way to move forward and provide the multi-target test to prevent regression while work on single-binary is continued by Yonggang. With a complete picture, I would be more than happy to remove is_available, I have no personal attach to it. Regards, Pierrick
On Thu, Nov 05, 2026 at 09:25:28AM -0800, Pierrick Bouvier wrote: > On 11/5/2026 2:24 AM, Daniel P. Berrangé wrote: > > The 'is_available' callback on TypeInfo is based on a mistaken > > notion that we should filter out classes at registration time > > based on architecture. > > > > This creates new problems however, some already present and > > some which will impact a future multi-target binary > > > > * For introspection of the binaries' features, we have > > a dependancy on selecting a target before we can > > introspect features. It would require re-launching > > QEMU for each target, leading to lots of redundant > > introspection and a big time sink. It would also not > > be possible to introspect targets > > > > * It creates a circular dependancy on QOM initialization > > inside the QOM initialization code, since 'target_info()' > > itself uses QOM. This then requires further work to break > > by initializing QOM target info before the rest of QOM. > > > > * We have no means to introspect what targets a machine > > type can be used with, as this information is expressed > > as code (in target_XXXX() methods), instead of as data. > > > > * New fields in TypeInfo requires more changes to macros > > used for initializing machines. > > > > There is no inherant conceptual reason why we must filter out > > classes at type registration time. This is just a shortcut to > > workaround historical technical debt where certain classes > > have clashing names. This is an undesirable approach, as it > > is trading one set of problems for a new set of problems. > > > > This series proposes removal of the 'is_available' concept > > from QOM, and illustrates handling machines with full introspection > > support available from the MachineClass. > > > > This implies fixing the root cause, of clashing class names, > > but does not include patches since various series have already > > been posted for machine class name fixes. > > > > The machine changes are fairly simple > > > > * MachineClass gains a 'targets' field which is a bit mask > > of SysEmuTarget > > * machine_class_is_available() matches 'targets' against > > 'target_info()' > > * -machine CLI enforces machine_class_is_available() > > * query-machines filters on machine_class_is_available > > by default > > * query-machines gains 'all-targets': 'bool' to opt-in > > to returning the unfiltered list, with a 'targets' > > list present > > > > NB, this removes filtering from riscv CPUs with no > > alternative proposed. I'm unclear what this was trying > > to address to begin with, but utlimately it should be > > possible to address it with runtime filtering/matching > > of classes, instead of hiding TypeInfo registration. > > If someone gives me info on the CPUs problem I can a > > make a design suggestion. > > > > Daniel P. Berrangé (4): > > hw/core: record permitted targets against MachineClass > > hw: replace 'is_available' with 'targets' in machines > > target/riscv: remove 'is_available' from riscv CPUs > > qom: drop the 'is_available' callback from TypeInfo > > > > hw/arm/aspeed_ast27x0-fc.c | 3 ++- > > hw/arm/aspeed_ast27x0_evb.c | 5 +++-- > > hw/arm/raspi.c | 21 +++++++++++++-------- > > hw/arm/raspi4b.c | 3 ++- > > hw/arm/virt.c | 5 +++-- > > hw/core/machine-qmp-cmds.c | 18 ++++++++++++++++++ > > hw/core/machine.c | 13 +++++++++++++ > > hw/hexagon/virt.c | 3 ++- > > hw/m68k/virt.c | 4 ++-- > > hw/or1k/virt.c | 3 ++- > > hw/riscv/virt.c | 4 +++- > > include/hw/core/boards.h | 3 +++ > > include/qom/object.h | 3 --- > > qapi/machine.json | 12 +++++++++++- > > qom/object.c | 4 ---- > > rust/qom/src/qom.rs | 1 - > > system/vl.c | 9 +++++++++ > > target/riscv/kvm/kvm-cpu.c | 1 - > > target/riscv/tcg/tcg-cpu.c | 1 - > > 19 files changed, 86 insertions(+), 30 deletions(-) > > > > Thanks for posting the series. > > Would that be possible to complete it so that beyond compilation, test > ./build/tests/unit/test-multi-target passes also? At the moment it fails > with duplicated types being registered. Oh I see, it didn't failure because I only enabled the two arm/aarch64 targets, once i add in more targets we get a clash on the virt-machine class. FYI, it also fails without my patch series present in some scenarios: # child process (/multi-targets/qom-types-are-unique/aarch64 [1950288]) stderr: "Registering `vm-launch-update' which already exists\n" ** ERROR:../tests/unit/test-multi-target.c:41:test_qom_types_are_unique: child process (/multi-targets/qom-types-are-unique/aarch64 [1950288]) failed unexpectedly not ok /multi-targets/qom-types-are-unique/aarch64 - ERROR:../tests/unit/test-multi-target.c:41:test_qom_types_are_unique: child process (/multi-targets/qom-types-are-unique/aarch64 [1950288]) failed unexpectedly Bail out! Aborted (core dumped) tests/unit/test-multi-target This is caused by presence of 'igvm-devel' at build time on one of my machines (Fedora), which enables this device type, if you have both arm and aarch64 targets enabled. We need to add igvm to our Fedora dockerfile to catch this in CI. Moving it from specific_ss to system_ss make the test pass, but I'm unclear if it is sufficient to rely on lack of compiler and test complaints ? Or it needs manual code inspection to make sure the device is safe in this scenario ? > That's why this is_available was introduced in the first place. It was > just a way to move forward and provide the multi-target test to prevent > regression while work on single-binary is continued by Yonggang. Right, so with my series, we would first need the class renames to fix the multi-target test. I should have labelled this posting "POC" as it was not tested thoroughly. With regards, Daniel -- |: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
On 11/6/2026 7:35 AM, Daniel P. Berrangé wrote: >> >> Thanks for posting the series. >> >> Would that be possible to complete it so that beyond compilation, test >> ./build/tests/unit/test-multi-target passes also? At the moment it fails >> with duplicated types being registered. > > Oh I see, it didn't failure because I only enabled > the two arm/aarch64 targets, once i add in more > targets we get a clash on the virt-machine class. > > FYI, it also fails without my patch series present > in some scenarios: > > # child process (/multi-targets/qom-types-are-unique/aarch64 [1950288]) stderr: "Registering `vm-launch-update' which already exists\n" > ** > ERROR:../tests/unit/test-multi-target.c:41:test_qom_types_are_unique: child process (/multi-targets/qom-types-are-unique/aarch64 [1950288]) failed unexpectedly > not ok /multi-targets/qom-types-are-unique/aarch64 - ERROR:../tests/unit/test-multi-target.c:41:test_qom_types_are_unique: child process (/multi-targets/qom-types-are-unique/aarch64 [1950288]) failed unexpectedly > Bail out! > Aborted (core dumped) tests/unit/test-multi-target > > This is caused by presence of 'igvm-devel' at build time on > one of my machines (Fedora), which enables this device type, > if you have both arm and aarch64 targets enabled. > > We need to add igvm to our Fedora dockerfile to catch this > in CI. > > Moving it from specific_ss to system_ss make the test pass, > but I'm unclear if it is sufficient to rely on lack of > compiler and test complaints ? Or it needs manual code > inspection to make sure the device is safe in this > scenario ? > We are guaranteed a "common" file works because config poisoning ensures the whole compilation unit, including headers, does not use any target specific code (#ifdef). So if it compiles, it's a safe change. >> That's why this is_available was introduced in the first place. It was >> just a way to move forward and provide the multi-target test to prevent >> regression while work on single-binary is continued by Yonggang. > > Right, so with my series, we would first need the class > renames to fix the multi-target test. > Correct. That's why is_available was used to do selective registration for virt and max cpu, because I don't see how a rename can work without breaking existing binaries. Introducing .targets does not solve the problem by itself, since name conflict is still there. That's why I suggested to use buckets per target, which is what Yonggang implemented. I have no strong attachment to any approach and would be happy to follow any end-to-end solution you recommend. I'll let you lead on this. > I should have labelled this posting "POC" as it was not > tested thoroughly. > No worries, it would have been caught in CI anyway, so we are safe here. > With regards, > Daniel Regards, Pierrick
On Fri, Nov 6, 2026 at 11:35 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Thu, Nov 05, 2026 at 09:25:28AM -0800, Pierrick Bouvier wrote:
> > On 11/5/2026 2:24 AM, Daniel P. Berrangé wrote:
> > > The 'is_available' callback on TypeInfo is based on a mistaken
> > > notion that we should filter out classes at registration time
> > > based on architecture.
> > >
> > > This creates new problems however, some already present and
> > > some which will impact a future multi-target binary
> > >
> > > * For introspection of the binaries' features, we have
> > > a dependancy on selecting a target before we can
> > > introspect features. It would require re-launching
> > > QEMU for each target, leading to lots of redundant
> > > introspection and a big time sink. It would also not
> > > be possible to introspect targets
> > >
> > > * It creates a circular dependancy on QOM initialization
> > > inside the QOM initialization code, since 'target_info()'
> > > itself uses QOM. This then requires further work to break
> > > by initializing QOM target info before the rest of QOM.
> > >
> > > * We have no means to introspect what targets a machine
> > > type can be used with, as this information is expressed
> > > as code (in target_XXXX() methods), instead of as data.
> > >
> > > * New fields in TypeInfo requires more changes to macros
> > > used for initializing machines.
> > >
> > > There is no inherant conceptual reason why we must filter out
> > > classes at type registration time. This is just a shortcut to
> > > workaround historical technical debt where certain classes
> > > have clashing names. This is an undesirable approach, as it
> > > is trading one set of problems for a new set of problems.
> > >
> > > This series proposes removal of the 'is_available' concept
> > > from QOM, and illustrates handling machines with full introspection
> > > support available from the MachineClass.
> > >
> > > This implies fixing the root cause, of clashing class names,
> > > but does not include patches since various series have already
> > > been posted for machine class name fixes.
> > >
> > > The machine changes are fairly simple
> > >
> > > * MachineClass gains a 'targets' field which is a bit mask
> > > of SysEmuTarget
> > > * machine_class_is_available() matches 'targets' against
> > > 'target_info()'
> > > * -machine CLI enforces machine_class_is_available()
> > > * query-machines filters on machine_class_is_available
> > > by default
> > > * query-machines gains 'all-targets': 'bool' to opt-in
> > > to returning the unfiltered list, with a 'targets'
> > > list present
> > >
> > > NB, this removes filtering from riscv CPUs with no
> > > alternative proposed. I'm unclear what this was trying
> > > to address to begin with, but utlimately it should be
> > > possible to address it with runtime filtering/matching
> > > of classes, instead of hiding TypeInfo registration.
> > > If someone gives me info on the CPUs problem I can a
> > > make a design suggestion.
> > >
> > > Daniel P. Berrangé (4):
> > > hw/core: record permitted targets against MachineClass
> > > hw: replace 'is_available' with 'targets' in machines
> > > target/riscv: remove 'is_available' from riscv CPUs
> > > qom: drop the 'is_available' callback from TypeInfo
> > >
> > > hw/arm/aspeed_ast27x0-fc.c | 3 ++-
> > > hw/arm/aspeed_ast27x0_evb.c | 5 +++--
> > > hw/arm/raspi.c | 21 +++++++++++++--------
> > > hw/arm/raspi4b.c | 3 ++-
> > > hw/arm/virt.c | 5 +++--
> > > hw/core/machine-qmp-cmds.c | 18 ++++++++++++++++++
> > > hw/core/machine.c | 13 +++++++++++++
> > > hw/hexagon/virt.c | 3 ++-
> > > hw/m68k/virt.c | 4 ++--
> > > hw/or1k/virt.c | 3 ++-
> > > hw/riscv/virt.c | 4 +++-
> > > include/hw/core/boards.h | 3 +++
> > > include/qom/object.h | 3 ---
> > > qapi/machine.json | 12 +++++++++++-
> > > qom/object.c | 4 ----
> > > rust/qom/src/qom.rs | 1 -
> > > system/vl.c | 9 +++++++++
> > > target/riscv/kvm/kvm-cpu.c | 1 -
> > > target/riscv/tcg/tcg-cpu.c | 1 -
> > > 19 files changed, 86 insertions(+), 30 deletions(-)
> > >
> >
> > Thanks for posting the series.
> >
> > Would that be possible to complete it so that beyond compilation, test
> > ./build/tests/unit/test-multi-target passes also? At the moment it fails
> > with duplicated types being registered.
>
> Oh I see, it didn't failure because I only enabled
> the two arm/aarch64 targets, once i add in more
> targets we get a clash on the virt-machine class.
>
> FYI, it also fails without my patch series present
> in some scenarios:
>
> # child process (/multi-targets/qom-types-are-unique/aarch64 [1950288]) stderr: "Registering `vm-launch-update' which already exists\n"
> **
> ERROR:../tests/unit/test-multi-target.c:41:test_qom_types_are_unique: child process (/multi-targets/qom-types-are-unique/aarch64 [1950288]) failed unexpectedly
> not ok /multi-targets/qom-types-are-unique/aarch64 - ERROR:../tests/unit/test-multi-target.c:41:test_qom_types_are_unique: child process (/multi-targets/qom-types-are-unique/aarch64 [1950288]) failed unexpectedly
> Bail out!
> Aborted (core dumped) tests/unit/test-multi-target
>
> This is caused by presence of 'igvm-devel' at build time on
> one of my machines (Fedora), which enables this device type,
> if you have both arm and aarch64 targets enabled.
>
> We need to add igvm to our Fedora dockerfile to catch this
> in CI.
>
> Moving it from specific_ss to system_ss make the test pass,
> but I'm unclear if it is sufficient to rely on lack of
> compiler and test complaints ? Or it needs manual code
> inspection to make sure the device is safe in this
> scenario ?
>
> > That's why this is_available was introduced in the first place. It was
> > just a way to move forward and provide the multi-target test to prevent
> > regression while work on single-binary is continued by Yonggang.
>
> Right, so with my series, we would first need the class
> renames to fix the multi-target test.
>
> I should have labelled this posting "POC" as it was not
> tested thoroughly.
It's good to have these, make the progress more clear, and we have
more agreements.
I think a possible direction is comes with
qom: filter type lookup with TypeBucket
https://lore.kernel.org/qemu-devel/20261105190346.1539-1-luoyonggang@gmail.com/T/#mc0a763e16d33b7b7c79d87fb07936ae4f04d68a0
So we can get conflict machine names such as "virt-machine" to be
registered with this TypeBucket.
Then we can limit the subclasses of TYPE_MACHINE to use this means(TypeBucket).
That is we can add unit-test in tests/unit/test-multi-target.c
to ensure after object_class_get_list(NULL, true); only TYPE_MACHINE's
subclass's "targets" can differ from QEMU_ARCH_ALL.
Or one more abstract class TYPE_CPU(only when absolutely necessary).
For example deal with:
target/arm: register separate max-v8 CPU types for arm and aarch64
https://lore.kernel.org/qemu-devel/auyP09mbwuefulBL@redhat.com/
>
> With regards,
> Daniel
> --
> |: https://berrange.com ~~ https://hachyderm.io/@berrange :|
> |: https://libvirt.org ~~ https://entangle-photo.org :|
> |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
>
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
© 2016 - 2026 Red Hat, Inc.