All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Yonggang Luo" <luoyonggang@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH 0/4] hw: support machine filtering without is_available
Date: Thu,  5 Nov 2026 10:24:28 +0000	[thread overview]
Message-ID: <20261105102432.1131493-1-berrange@redhat.com> (raw)

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



             reply	other threads:[~2026-11-05 10:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 10:24 Daniel P. Berrangé [this message]
2026-11-05 10:24 ` [PATCH 1/4] hw/core: record permitted targets against MachineClass Daniel P. Berrangé
2026-11-05 10:24 ` [PATCH 2/4] hw: replace 'is_available' with 'targets' in machines Daniel P. Berrangé
2026-11-05 10:24 ` [PATCH 3/4] target/riscv: remove 'is_available' from riscv CPUs Daniel P. Berrangé
2026-11-05 10:24 ` [PATCH 4/4] qom: drop the 'is_available' callback from TypeInfo Daniel P. Berrangé
2026-11-05 17:25 ` [PATCH 0/4] hw: support machine filtering without is_available Pierrick Bouvier
2026-11-06 15:35   ` Daniel P. Berrangé
2026-11-06 16:28     ` Yonggang Luo
2026-11-06 17:13     ` Pierrick Bouvier
2026-11-05 19:18 ` Yonggang Luo
2026-11-05 19:24   ` Pierrick Bouvier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261105102432.1131493-1-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=luoyonggang@gmail.com \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.