On Wed, Oct 07, 2026 at 07:28:59AM -0700, Pierrick Bouvier wrote:
> On 10/7/2026 12:48 AM, Yonggang Luo wrote:
> > On Wed, Oct 7, 2026 at 12:03 PM Pierrick Bouvier
> > <[email protected]> wrote:
> >>
> >> For now, TARGET_ARCH only contains 32 vs 64 bit arch. The variants,
> >> based on endianness, are accessible through TARGET_NAME. However,
> >> TARGET_NAME is a string, and thus can't be concatenated to generate code
> >> and retrieve matching SYS_EMU_TARGET enum entry.
> >> Thus, export this information in TARGET_ARCH_VARIANT as an unquoted
> >> identifier.
> >>
> >> There is one more subtlety, user binaries have extra targets that are
> >> not present in SYS_EMU_TARGET, like armeb.
> >> Thus, for user binaries, simply export TARGET_ARCH.
> > 
> > 
> >>
> >> Signed-off-by: Pierrick Bouvier <[email protected]>
> >> ---
> >>  meson.build | 11 +++++++++--
> >>  1 file changed, 9 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/meson.build b/meson.build
> >> index cae1591cd28..9bcfe84daba 100644
> >> --- a/meson.build
> >> +++ b/meson.build
> >> @@ -3288,7 +3288,14 @@ default_targets = 'CONFIG_DEFAULT_TARGETS' in 
> >> config_host
> >>  actual_target_dirs = []
> >>  fdt_required = []
> >>  foreach target : target_dirs
> >> -  config_target = { 'TARGET_NAME': target.split('-')[0] }
> >> +  target_name = target.split('-')[0]
> >> +  config_target = { 'TARGET_NAME': target_name }
> >> +  if target.endswith('linux-user')
> >> +    config_target += { 'TARGET_ARCH_VARIANT': 'TARGET_ARCH' }
> > 
> > If TARGET_ARCH_VARIANT or just called (TARGET_NAME_ENUM) is just a
> > direct mapping of target_name regardless linux-user/bsd-user/softmmu,
> > the logic would
> > be simpler. That would need add more enum to SYS_EMU_TARGET, the
> > current form is:
> > ##
> > # @SysEmuTarget:
> > #     The comprehensive enumeration of QEMU system emulation
> > #     ("softmmu") targets.  Run "./configure --help" in the project
> > #     root directory, and look for the \*-softmmu targets near the
> > #     "--target-list" option.  The individual target constants are not
> > #     documented here, for the time being.
> > #
> > # @rx: since 5.0
> > #
> > # @avr: since 5.1
> > #
> > # @loongarch64: since 7.1
> > #
> > # @hexagon: since 11.0
> > #
> > # .. note:: The resulting QMP strings can be appended to the
> > #    "qemu-system-" prefix to produce the corresponding QEMU
> > #    executable name.  This is true even for "qemu-system-x86_64".
> > #
> > # Since: 3.0
> > ##
> > { 'enum' : 'SysEmuTarget',
> >   'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hexagon', 'hppa', 'i386',
> >              'loongarch64', 'm68k', 'microblaze', 'mips', 'mips64',
> >              'mips64el', 'mipsel', 'or1k', 'ppc',
> >              'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4',
> >              'sh4eb', 'sparc', 'sparc64', 'tricore',
> >              'x86_64', 'xtensa', 'xtensaeb' ] }
> > 
> > 
> > The list target names that missing from SysEmuTarget:
> > 
> > Comparing the target-name prefixes of `configs/targets/*.mak` with the
> > `SysEmuTarget` enum in `qapi/machine.json`, the following seven names are
> > missing. All are Linux-user-only targets.
> > 
> > | Target name | Config |
> > |---|---|
> > | `aarch64_be` | `configs/targets/aarch64_be-linux-user.mak` |
> > | `armeb` | `configs/targets/armeb-linux-user.mak` |
> > | `microblazeel` | `configs/targets/microblazeel-linux-user.mak` |
> > | `mipsn32` | `configs/targets/mipsn32-linux-user.mak` |
> > | `mipsn32el` | `configs/targets/mipsn32el-linux-user.mak` |
> > | `ppc64le` | `configs/targets/ppc64le-linux-user.mak` |
> > | `sparc32plus` | `configs/targets/sparc32plus-linux-user.mak` |
> > 
> > All `*-softmmu` and `*-bsd-user` target names match enum entries.
> > 
> > This comparison uses names derived from config filenames, not the
> > `TARGET_ARCH` values inside those configs.
> > 
> > By doing this I think it would be more consistent.
> > If these target names are removed in future, then just remove it from
> > SysEmuTarget
> > along with. So SysEmuTarget is just a direct mapping of TARGET_NAME. Though
> > The comment of SysEmuTarget needs updated, it's not just about softmmu, but 
> > also
> > for linux-user and bsd-user. But the fact is, with the current
> > changes. *-user also
> > used SysEmuTarget as an enum.
> > 
> > 
> > And TARGET_ARCH should also be exported by TargetInfo for other usage.
> > And it's enums is the subset
> > of enum SysEmuTarget
> >
> 
> I tend to agree, but didn't find a real reason to do this change (yet).
> Also, I would be in favor to rename SysEmuTarget since in EmuTarget,
> since it would now be decoupled from system emulation only.
> 
> @Daniel: Would you be favor to see such a change? I know that
> introspection/QAPI is related to system emulation, and I'm not
> completely sure adding user targets is the right move at this moment.

The QAPI type names are purely internal - they're not exposed to
clients of QMP, so we can (and have) renamed the types in the
past.

If SysEmuTarget gains some more enum values that correspond
to linux-user targets, that would be visible when introspecting
the QAPI schema. I don't think that is a problem though - it is
always possible for SysEmuTarget to return a bunch of names, for
which there is no binary. All that matters really is that
query-target returns the right name.

So I think the rename + extra targets is fine.

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 :|


Reply via email to