On Mon, Sep 28, 2026 at 6:14 PM Daniel P. Berrangé <[email protected]> wrote:
>
> I don't think that we need to report machines though.
> We already have 'query-machines' which gives much broader
> information on the machines. "MachineInfo" needs to
> gain
>
> "targets": ["SysEmuTarget"]
>
> to list which target(s) a machine can be used with.
>
This is my final design for the query-target / query-targets / query-machines,
for consistency and testability.
Per review: reuse `QemuTargetInfo` for both target commands, drop the
per-target machine list, and let
`MachineInfo` say which target(s) each machine runs on.
`QemuTargetInfo` stays small; `query-target` and `query-targets` return a
derived struct that adds the target's device and accel Kconfig state.
## QemuTargetInfo
```
{ 'struct': 'QemuTargetInfo',
'data': { 'arch': 'SysEmuTarget' } } # since 1.2
```
`mips` and `mipsel` are distinct `SysEmuTarget` values; the target value
identifies the system emulator, including its endianness, rather than only
the underlying architecture family.
## QemuTargetDetails: QemuTargetInfo plus kconfig
```
{ 'struct': 'QemuTargetDetails',
'base': 'QemuTargetInfo',
'data': { 'kconfig': 'any' } }
```
`kconfig` maps every device and accel `CONFIG_*` symbol to whether it
is enabled for that target.
For example, `TYPE_NITRO_ENCLAVE_MACHINE` is available only when
`CONFIG_NITRO_ENCLAVE` is enabled for the target:
```
{ "arch": "x86_64",
"kconfig": { "CONFIG_NITRO_ENCLAVE": true } }
```
Examples below are trimmed.
## query-target (now returns QemuTargetDetails)
Adding members to a return type is backward compatible; existing
clients reading only `arch` are unaffected.
```
{ 'command': 'query-target', 'returns': 'QemuTargetDetails' }
```
Single-target binary (`qemu-system-aarch64`):
```
-> { "execute": "query-target" }
<- { "return": { "arch": "aarch64",
"kconfig": { "CONFIG_ARM_VIRT": true,
"CONFIG_Q35": false,
... } } }
```
## query-targets (new, returns ['QemuTargetDetails'])
Single-target binary:
```
-> { "execute": "query-targets" }
<- { "return": [ { "arch": "aarch64",
"kconfig": { "CONFIG_ARM_VIRT": true,
"CONFIG_Q35": false, ... } } ] }
```
Combined `qemu-system` linking aarch64 and riscv64 (`none` is always
present):
```
-> { "execute": "query-targets" }
<- { "return": [ { "arch": "aarch64",
"kconfig": { "CONFIG_ARM_VIRT": true,
"CONFIG_RISCV_VIRT": false, ... } },
{ "arch": "riscv64",
"kconfig": { "CONFIG_ARM_VIRT": false,
"CONFIG_RISCV_VIRT": true, ... } },
{ "arch": "none",
"kconfig": { "CONFIG_ARM_VIRT": false,
"CONFIG_RISCV_VIRT": false, ... } } ] }
```
## query-machines: MachineInfo gains targets
```
{ 'struct': 'MachineInfo',
'data': { 'name': 'str', 'typename': 'str', ...existing members...,
'targets': ['QemuTargetInfo'] } } # since 11.2
```
Combined `qemu-system` (other MachineInfo members trimmed):
```
-> { "execute": "query-machines" }
<- { "return": [
{ "name": "virt-11.2", "typename": "arm-virt-11.2-machine",
"alias": "virt", "is-default": false,
"cpu-max": 512, "deprecated": false, "secure": true,
"targets": [ { "arch": "aarch64" } ] },
{ "name": "virt", "typename": "riscv-virt-machine",
"cpu-max": 512, "deprecated": false,
"secure": true,
"targets": [ { "arch": "riscv64" } ] },
{ "name": "none", "typename": "none-machine",
"cpu-max": 1, "deprecated": false,
"secure": false,
"targets": [ { "arch": "aarch64" },
{ "arch": "riscv64" },
{ "arch": "none" } ] }
] }
```
Single-target binary: every entry has exactly one element in
`targets`, equal to `query-target`'s `arch`.
A client that wants the old "machines per target" view filters
`query-machines` on `targets`.
## Open questions for the list
Machine names are not unique in a combined binary (`virt` above exists
for aarch64 and riscv64). `typename` is the unique QOM identity, so the
list contains one `MachineInfo` per `typename`; `targets` lists the
targets on which that machine type is available.
1. `kconfig` on `QemuTargetDetails`. The use case is tests telling "not
built" apart from "missing". Open points:
- `'any'` (a JSON object) vs. a list of enabled symbol names.
The object makes a typo (symbol absent) distinguishable from
"disabled" (`false`).
- Stable, or an `unstable` feature, given that Kconfig symbol
names are internal and can be renamed.
- Size: several hundred entries per target, which is why it is
in `QemuTargetDetails` (`query-target`, `query-targets`) and not
in `QemuTargetInfo` (which contains only the target architecture).
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo