machine: uniquify virt QOM names
v2 cover machine: uniquify virt QOM names
Multiple targets register a virt board as MACHINE_TYPE_NAME("virt"). Those QOM types collide if more than one board is linked into one qemu-system process. This series splits the QOM type from the -M name so each virt board can keep a unique type while -M virt, help, and migration stay the same.
- Add machine_class_set_name() so boards can set MachineClass::name when it must differ from the QOM type. machine_class_base_init still defaults the name to the QOM type without -machine. Document that MachineClass::name is the -M name, not the QOM type. Sort -M help by that name so order matches the printed names after types are prefixed (arm-virt-11.1-machine vs virt-11.1).
- Give each colliding virt board a unique QOM type and keep the existing -M name via machine_class_set_name(): riscv-virt, arm-virt, or1k-virt, hexagon-virt, loongarch-virt, m68k-virt, and xtensa-virt. Versioned ARM, LoongArch, and M68K boards keep virt-<ver>. Latest ARM virt still sets mc->alias to virt.
- query-machines returns MachineInfo typename, the QOM type from object_class_get_name(), for qom-list-properties. The -M name alone is not that type once virt boards are prefixed.
Changes v1 -> v2:
- query-machines returns MachineInfo typename. v1 returned only the -M name, so a client that appended "-machine" looked up the wrong type for a prefixed board such as arm-virt-11.1-machine versus -M virt-11.1.
Yonggang Luo (9):
machine: allow -M name to differ from QOM type hw/riscv/virt: use unique QOM name hw/arm/virt: use unique QOM name hw/or1k/virt: use unique QOM name hw/hexagon/virt: use unique QOM name hw/loongarch/virt: use unique QOM name hw/m68k/virt: use unique QOM name hw/xtensa/virt: use unique QOM name
qapi: return MachineInfo typename from query-machines
hw/arm/virt.c | 3 +- hw/core/machine-qmp-cmds.c | 1 + hw/core/machine.c | 6 ++++ hw/hexagon/virt.c | 1 + hw/loongarch/virt.c | 3 +- hw/m68k/virt.c | 7 ++-- hw/or1k/virt.c | 3 +- hw/riscv/virt.c | 3 +- hw/xtensa/virt.c | 3 +- include/hw/arm/virt.h | 2 +- include/hw/core/boards.h | 12 ++++++- include/hw/hexagon/virt.h | 2 +- include/hw/loongarch/virt.h | 2 +- include/hw/riscv/virt.h | 2 +- qapi/machine.json | 6 +++- system/vl.c | 8 ++--- tests/qtest/qom-test.c | 65 +++++++++++++++++++++++++++++++++---- 17 files changed, 104 insertions(+), 25 deletions(-)
Signature · 1 line
2.52.0.windows.1
PATCH v2 1/9 machine: allow -M name to differ from QOM type
- Add machine_class_set_name() so boards can keep a stable -M name when the QOM type is uniquified. machine_class_base_init still defaults the name to the QOM type without -machine.
- Document that MachineClass::name is the -M name, not the QOM type.
- Sort -M help by MachineClass::name so order matches the printed names when QOM types are prefixed (arm-virt-11.1-machine vs virt-11.1).
--- hw/core/machine.c | 6 ++++++ include/hw/core/boards.h | 12 +++++++++++- system/vl.c | 8 +++----- 3 files changed, 20 insertions(+), 6 deletions(-)
hw/core/machine.c +6 -0
@@ -1215,6 +1215,12 @@ static void machine_class_init(ObjectClass *oc, const void *data) "Memory size configuration"); } +void machine_class_set_name (MachineClass *mc,const char *name) +{ +g_free (mc->name); + mc->name =g_strdup (name); +} +static void machine_class_base_init (ObjectClass *oc,const void *data) {MachineClass *mc =MACHINE_CLASS (oc);
include/hw/core/boards.h +11 -1
@@ -36,6 +36,16 @@ const char *machine_default_cpu_type(const MachineState *ms);* @mc: Machine class */ const char *machine_class_default_cpu_type (MachineClass *mc); +/** +* machine_class_set_name: Set the -M name when it differs from the QOM type +* @mc: Machine class +* @name: Name used by -M lookup, help, and migration +* +* machine_class_base_init sets MachineClass::name from the QOM type with +* the -machine suffix removed. Call this from board class_init when the +* CLI name must stay stable after the QOM type is uniquified. +*/ +void machine_class_set_name (MachineClass *mc,const char *name);void machine_add_audiodev_property (MachineClass *mc);void machine_run_board_init (MachineState *machine,const char *mem_path,Error **errp);
@@ -269,7 +279,7 @@ struct MachineClass {/*< public >*/ const char *family;/* NULL iff @name identifies a standalone machtype */ -char *name; +char *name;/* -M name; default is QOM type without -machine */ const char *alias;const char *desc;const char *deprecation_reason;
system/vl.c +3 -5
@@ -1538,10 +1538,9 @@ static gint machine_class_cmp(gconstpointer a, gconstpointer b, gpointer d)if (mc1->family ==NULL ) {if (mc2->family ==NULL ) {/* Compare standalone machine types against each other; they sort -* in increasing order. +* in increasing order by the name shown in -M help. */ -return strcmp (object_class_get_name (OBJECT_CLASS (mc1)), -object_class_get_name (OBJECT_CLASS (mc2))); +return strcmp (mc1->name, mc2->name); }/* Standalone machine types sort after families. */
@@ -1560,8 +1559,7 @@ static gint machine_class_cmp(gconstpointer a, gconstpointer b, gpointer d) }/* Within the same family, machine types sort in decreasing order. */ -return strcmp (object_class_get_name (OBJECT_CLASS (mc2)), -object_class_get_name (OBJECT_CLASS (mc1))); +return strcmp (mc2->name, mc1->name); }static void machine_help_func (const QDict *qdict)
Signature · 1 line
2.52.0.windows.1
Re: [PATCH v2 1/9] machine: allow -M name to differ from QOM type
Hi Yonggang,
Quoted 7 lines · Yonggang Luo
- Add
machine_class_set_name()so boards can keep a stable -M name when the QOM type is uniquified.machine_class_base_initstill defaults the name to the QOM type without -machine.
- Document thatMachineClass::nameis the -M name, not the QOM type.
- Sort -M help byMachineClass::nameso order matches the printed names when QOM types are prefixed (arm-virt-11.1-machine vs virt-11.1).
Quoted 8 lines
Signed-off-by Yonggang Luo <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>--- hw/core/machine.c | 6 ++++++ include/hw/core/boards.h | 12 +++++++++++- system/vl.c | 8 +++----- 3 files changed, 20 insertions(+), 6 deletions(-)
this indeed allows QOM types to coexist in same binary.
In such binary, how are we now supposed to differentiate two virt machines from -M <name>, given they both have same alias name?
Regards,
Pierrick
Re: [PATCH v2 1/9] machine: allow -M name to differ from QOM type
Quoted 7 lines · Pierrick Bouvier
this indeed allows QOM types to coexist in same binary. In such binary, how are we now supposed to differentiate two virt machines from -M <name>, given they both have same alias name?
Regards,
Pierrick
# Machine option demos
Intended design for combined qemu-system. Implement to match these rows. Last -M / -machine / -readconfig wins. qemu.conf is applied first.
arch:name binds arch and picks name. arch: binds arch. x86_64: and i386: then run that target's default machine. aarch64: and riscv64: have no default and exit with No machine specified, and there is no default. A later bare name keeps the last prefix. Help / ? after arch: lists that target; it does not leave the target at none.
Single-target rows are historic qemu-system-<arch> and stay as they are.
## Bind and run
| Command | Shows | |---------|-------| | `qemu-system -M aarch64:virt` | Bind `aarch64`, run `virt`. | | `qemu-system -M x86_64:q35` | Bind `x86_64`, run `q35`. | | `qemu-system -M riscv64:virt` | Bind `riscv64`, run `virt`. | | `qemu-system -M type=aarch64:virt` | Same as `-M aarch64:virt`. | | `qemu-system -machine aarch64:virt` | Same as `-M`. | | `qemu-system-aarch64 -M virt` | Historic. No `arch:` bind. | | `qemu-system-x86_64` | Single-target default (`pc` / `q35`). |
## Default machine (arch:)
| Command | Shows | |---------|-------| | `qemu-system -M x86_64:` | Bind `x86_64`, run that target's default. | | `qemu-system -M i386:` | Bind `i386`, run that target's default. | | `qemu-system -M aarch64:` | Bind `aarch64`, then `No machine specified, and there is no default`. | | `qemu-system -M riscv64:` | Bind `riscv64`, then the same error. | | `qemu-system -M none:` | Target `none`, empty `none` machine. |
## List
| Command | Shows | |---------|-------| | `qemu-system -M help` | Grouped list. `none:` first, then each target. | | `qemu-system -M ?` | Same as `-M help`. | | `qemu-system -M aarch64:help` | Flat list for `aarch64` only. | | `qemu-system -M aarch64:?` | Same as `-M aarch64:help`. | | `qemu-system -M riscv64:help` | Flat list for `riscv64` only. | | `qemu-system -M none:help` | `none` and `empty machine`. No other target group. | | `qemu-system-aarch64 -M help` | Flat list for that target only. |
## Empty machine
| Command | Shows | |---------|-------| | `qemu-system` | Target `none`, empty `none` machine. | | `qemu-system -M none` | Empty `none` machine. | | `qemu-system -M none:none` | Same. | | `qemu-system -M aarch64:none` | Target `aarch64`, empty `none` machine. | | `qemu-system -M aarch64:virt -M none` | Empty `none` machine. Target stays `aarch64`. |
## Properties
| Command | Shows | |---------|-------| | `qemu-system -M aarch64:virt,help` | Bind `aarch64`, dump `virt` properties. | | `qemu-system -M aarch64:,help` | `No machine specified, and there is no default`. | | `qemu-system -M virt,help` | `machine type "virt" needs an arch: prefix`. | | `qemu-system -M none,help` | Dump empty `none` machine properties. | | `qemu-system-aarch64 -M virt,help` | Historic property dump for `virt`. |
## Last -M wins
| Command | Shows | |---------|-------| | `qemu-system -M aarch64:virt -M x86_64:q35` | Target `x86_64`, machine `q35`. | | `qemu-system -M aarch64:virt -M virt` | Last name is `virt`. Keep prefix `aarch64`, run `virt`. | | `qemu-system -M virt -M aarch64:virt` | Target `aarch64`, machine `virt`. | | `qemu-system -M aarch64: -M virt` | Bind `aarch64`, then bare `virt` runs `virt`. | | `qemu-system -M aarch64:virt -M riscv64:` | Bind `riscv64`, then `No machine specified, and there is no default`. | | `qemu-system -M aarch64:virt -M riscv64:virt` | Target `riscv64`, machine `virt`. | | `qemu-system -M help -M aarch64:virt` | Help is not last; run `aarch64:virt`. | | `qemu-system -M aarch64:virt -M help` | Keep prefix `aarch64`. List has `virt`, not `q35`. |
## -readconfig
A [machine] type = "..." file is another machine option. The last of -M, -machine, and -readconfig wins.
| Command | Shows | |---------|-------| | `-readconfig` with `type = "aarch64:virt"` | Bind `aarch64`, run `virt`. | | that file, then `-M none` | Machine `none`. Target stays `aarch64`. | | `-readconfig` with `type = "none:"` | Target `none`, empty `none` machine. | | `-M aarch64:virt`, then `-readconfig` `type = "riscv64:virt"` | Target `riscv64`, machine `virt`. |
## Wrong target or machine
| Command | Shows | |---------|-------| | `qemu-system -M virt` | `machine type "virt" needs an arch: prefix` | | `qemu-system -M riscv64` | Same. Bare `riscv64` is a machine name, not a target. | | `qemu-system -M aarch64` | Same. Bare `aarch64` is a machine name, not a target. | | `qemu-system -M aarch64:q35` | Target `aarch64`, then `unsupported machine type: "aarch64:q35"` | | `qemu-system -M arm:sbsa-ref` | Target `arm`, then unsupported (`sbsa-ref` is `aarch64` only). | | `qemu-system -M aarch64:no-such` | Target `aarch64`, then `unsupported machine type: "aarch64:no-such"` | | `qemu-system -M no-such:virt` | `target 'no-such' is not available` | | `qemu-system -M AARCH64:virt` | `target 'AARCH64' is not available` (names are lowercase). | | `qemu-system -M none:virt` | `machine type "none:virt" is not available for target none` |
## Odd strings
| Command | Shows | |---------|-------| | `qemu-system -M :virt` | Not a prefix. Same as bare `virt`: needs `arch:`. | | `qemu-system -M :` | Not a prefix. Unsupported machine `:` / needs `arch:`. | | `qemu-system -M aarch64:virt:extra` | First colon only. Name is `virt:extra`. Unsupported machine. | | `qemu-system-x86_64 -M aarch64:virt` | Prefix `aarch64` != `x86_64`. Not available for this target. | | `qemu-system-aarch64 -M aarch64:virt` | Prefix matches. Run `virt`. |
## Intended grouped -M help (no target)
| Group | Contents | |-------|----------| | `none:` | only `none` | | `i386:` and `x86_64:` | pc / q35 / isapc / microvm / xen / nitro | | `arm:` and `aarch64:` | `virt-*` and 32-bit ARM boards | | `aarch64:` only | sbsa-ref, versal, zcu102, imx8, npcm845, raspi3/4, ast2700 | | `riscv32:` and `riscv64:` | RISC-V boards | | `microblaze:` | petalogix and xlnx-zynqmp-pmu |
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
Re: [PATCH v2 1/9] machine: allow -M name to differ from QOM type
In reply to Yonggang LuoQuoted 36 lines
- Add
machine_class_set_name()so boards can keep a stable -M name when the QOM type is uniquified.machine_class_base_initstill defaults the name to the QOM type without -machine.
- Document thatMachineClass::nameis the -M name, not the QOM type.
- Sort -M help byMachineClass::nameso order matches the printed names when QOM types are prefixed (arm-virt-11.1-machine vs virt-11.1).Signed-off-by Yonggang Luo <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>Message-ID: <[email protected]>
hw/core/machine.c +6
-0@@ -1215,6 +1215,12 @@ static void machine_class_init(ObjectClass *oc, const void *data) "Memory size configuration"); } +void machine_class_set_name (MachineClass *mc,const char *name) +{ +g_free (mc->name); + mc->name =g_strdup (name); +} +static void machine_class_base_init (ObjectClass *oc,const void *data) {MachineClass *mc =MACHINE_CLASS (oc);include/hw/core/boards.h +0
-0@@ -36,6 +36,16 @@ const char *machine_default_cpu_type(const MachineState *ms);* @mc: Machine class */ const char *machine_class_default_cpu_type (MachineClass *mc);
include/hw/core/boards.h const char *machine_default_cpu_type(const MachineState *ms); · line 48
Quoted 10 lines
include/hw/core/boards.h +10
-0+/** +* machine_class_set_name: Set the -M name when it differs from the QOM type +* @mc: Machine class +* @name: Name used by -M lookup, help, and migration +* +* machine_class_base_init sets MachineClass::name from the QOM type with +* the -machine suffix removed. Call this from board class_init when the +* CLI name must stay stable after the QOM type is uniquified. +*/ +void machine_class_set_name (MachineClass *mc,const char *name);
add machine_class_set_name() to the comment example around line 484:
Add after the existing mc->desc line in the example:
* machine_class_set_name(mc, "virt-" MACHINE_VER_STR(__VA_ARGS__)); \
And update the example's type name from "virt" to show a prefixed name like "arm-virt" so it matches the real usage pattern.
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 2/9 hw/riscv/virt: use unique QOM name
In reply to Yonggang LuoUse TYPE_RISCV_VIRT_MACHINE so the RISC-V virt QOM type does not collide with ARM virt in a combined qemu-system binary. Keep the -M / help / migration name as virt via machine_class_set_name().
--- hw/riscv/virt.c | 3 ++- include/hw/riscv/virt.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
hw/riscv/virt.c +2 -1
@@ -1134,6 +1134,7 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc); mc->desc ="RISC-V VirtIO board" ; +machine_class_set_name (mc,"virt" ); mc->init = virt_machine_init; mc->max_cpus =VIRT_CPUS_MAX ; mc->default_cpu_type =TYPE_RISCV_CPU_BASE ;
@@ -1197,7 +1198,7 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data) }static const TypeInfo virt_machine_typeinfo = { - .name =MACHINE_TYPE_NAME ("virt" ), + .name =TYPE_RISCV_VIRT_MACHINE , .parent =TYPE_MACHINE , .class_init = virt_machine_class_init, .instance_init = virt_machine_instance_init,
include/hw/riscv/virt.h +1 -1
@@ -30,7 +30,7 @@#define VIRT_SOCKETS_MAX_BITS 2#define VIRT_SOCKETS_MAX (1 << VIRT_SOCKETS_MAX_BITS) -#define TYPE_RISCV_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +#define TYPE_RISCV_VIRT_MACHINE MACHINE_TYPE_NAME("riscv-virt")typedef struct RISCVVirtState RISCVVirtState ;DECLARE_INSTANCE_CHECKER (RISCVVirtState,RISCV_VIRT_MACHINE ,TYPE_RISCV_VIRT_MACHINE )
Signature · 1 line
2.52.0.windows.1
Re: [PATCH v2 2/9] hw/riscv/virt: use unique QOM name
Quoted 3 lines · Yonggang Luo
Use
TYPE_RISCV_VIRT_MACHINEso the RISC-V virt QOM type does not collide with ARM virt in a combined qemu-system binary. Keep the -M / help / migration name as virt viamachine_class_set_name().
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 3/9 hw/arm/virt: use unique QOM name
In reply to Yonggang LuoSet TYPE_VIRT_MACHINE to MACHINE_TYPE_NAME("arm-virt") so ARM virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt-* via machine_class_set_name().
--- hw/arm/virt.c | 3 ++- include/hw/arm/virt.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
hw/arm/virt.c +2 -1
@@ -123,13 +123,14 @@ static void arm_virt_compat_default_set(MachineClass *mc)MACHINE_VER_SYM (options, virt, __VA_ARGS__)(mc); \ mc->desc = "QEMU " MACHINE_VER_STR(__VA_ARGS__) " ARM Virtual Machine"; \MACHINE_VER_DEPRECATION (__VA_ARGS__); \ +machine_class_set_name (mc,"virt-" MACHINE_VER_STR (__VA_ARGS__)); \if (latest) { \ mc->alias ="virt" ; \ } \ } \static const TypeInfo MACHINE_VER_SYM (info ,virt ,__VA_ARGS__ ) = \ { \ - .name =MACHINE_VER_TYPE_NAME ("virt" , __VA_ARGS__), \ + .name =MACHINE_VER_TYPE_NAME ("arm-virt" , __VA_ARGS__), \ .parent =TYPE_VIRT_MACHINE , \ .class_init =MACHINE_VER_SYM (class_init, virt, __VA_ARGS__), \ }; \
include/hw/arm/virt.h +1 -1
@@ -215,7 +215,7 @@ struct VirtMachineState {#define VIRT_ECAM_ID (high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) -#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("arm-virt") OBJECT_DECLARE_TYPE(VirtMachineState, VirtMachineClass, VIRT_MACHINE)void virt_acpi_setup (VirtMachineState *vms);
Signature · 1 line
2.52.0.windows.1
Re: [PATCH v2 3/9] hw/arm/virt: use unique QOM name
Quoted 4 lines · Yonggang Luo
Set
TYPE_VIRT_MACHINEtoMACHINE_TYPE_NAME("arm-virt")so ARM virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt-* viamachine_class_set_name().
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 4/9 hw/or1k/virt: use unique QOM name
In reply to Yonggang LuoSet TYPE_VIRT_MACHINE to MACHINE_TYPE_NAME("or1k-virt") so OpenRISC virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt via machine_class_set_name().
--- hw/or1k/virt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/or1k/virt.c +2 -1
@@ -34,7 +34,7 @@#define VIRT_CPUS_MAX 4#define VIRT_CLK_MHZ 20000000 -#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("or1k-virt")#define VIRT_MACHINE (obj) \ OBJECT_CHECK(OR1KVirtState, (obj), TYPE_VIRT_MACHINE)
@@ -548,6 +548,7 @@ static void openrisc_virt_machine_init(ObjectClass *oc, const void *data)MachineClass *mc =MACHINE_CLASS (oc); mc->desc ="or1k virtual machine" ; +machine_class_set_name (mc,"virt" ); mc->init = openrisc_virt_init; mc->max_cpus =VIRT_CPUS_MAX ; mc->is_default = false;
Signature · 1 line
2.52.0.windows.1
Re: [PATCH v2 4/9] hw/or1k/virt: use unique QOM name
Quoted 13 lines
Set
TYPE_VIRT_MACHINEtoMACHINE_TYPE_NAME("or1k-virt")so OpenRISC virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt viamachine_class_set_name().Signed-off-by Yonggang Luo <[email protected]>Message-ID: <[email protected]>
hw/or1k/virt.c +0
-0
hw/or1k/virt.c line 39
Quoted 7 lines
hw/or1k/virt.c +1
-1@@ -34,7 +34,7 @@#define VIRT_CPUS_MAX 4#define VIRT_CLK_MHZ 20000000 -#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("or1k-virt")#define VIRT_MACHINE (obj) \ OBJECT_CHECK(OR1KVirtState, (obj), TYPE_VIRT_MACHINE)
While at it, rename it to TYPE_OR1K_VIRT_MACHINE?
hw/or1k/virt.c static void openrisc_virt_machine_init(ObjectClass *oc, const void *data) · line 554
Quoted 9 lines
hw/or1k/virt.c +1
-0@@ -548,6 +548,7 @@ static void openrisc_virt_machine_init(ObjectClass *oc, const void *data)MachineClass *mc =MACHINE_CLASS (oc); mc->desc ="or1k virtual machine" ; +machine_class_set_name (mc,"virt" ); mc->init = openrisc_virt_init; mc->max_cpus =VIRT_CPUS_MAX ; mc->is_default = false;
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 5/9 hw/hexagon/virt: use unique QOM name
In reply to Yonggang LuoSet TYPE_HEXAGON_VIRT_MACHINE to MACHINE_TYPE_NAME("hexagon-virt") so Hexagon virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt via machine_class_set_name().
--- hw/hexagon/virt.c | 1 + include/hw/hexagon/virt.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
hw/hexagon/virt.c +1 -0
@@ -359,6 +359,7 @@ static void virt_class_init(ObjectClass *oc, const void *data)MachineClass *mc =MACHINE_CLASS (oc); mc->desc ="Hexagon Virtual Machine" ; +machine_class_set_name (mc,"virt" ); mc->init = virt_init; mc->default_cpu_type =HEXAGON_CPU_TYPE_NAME ("v68" ); mc->default_ram_size =4 * GiB;
include/hw/hexagon/virt.h +1 -1
@@ -26,7 +26,7 @@ struct HexagonVirtMachineState {void hexagon_load_fdt (const struct HexagonVirtMachineState *vms); -#define TYPE_HEXAGON_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +#define TYPE_HEXAGON_VIRT_MACHINE MACHINE_TYPE_NAME("hexagon-virt") OBJECT_DECLARE_SIMPLE_TYPE(HexagonVirtMachineState, HEXAGON_VIRT_MACHINE)#endif /* HW_HEXAGONVIRT_H */
Signature · 1 line
2.52.0.windows.1
Re: [PATCH v2 5/9] hw/hexagon/virt: use unique QOM name
Quoted 4 lines · Yonggang Luo
Set
TYPE_HEXAGON_VIRT_MACHINEtoMACHINE_TYPE_NAME("hexagon-virt")so Hexagon virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt viamachine_class_set_name().
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 6/9 hw/loongarch/virt: use unique QOM name
In reply to Yonggang LuoSet TYPE_LOONGARCH_VIRT_MACHINE to MACHINE_TYPE_NAME("loongarch-virt") so LoongArch virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt-* via machine_class_set_name().
--- hw/loongarch/virt.c | 3 ++- include/hw/loongarch/virt.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
hw/loongarch/virt.c +2 -1
@@ -1543,6 +1543,7 @@ static void virt_class_init(ObjectClass *oc, const void *data)MACHINE_VER_SYM (options, virt, __VA_ARGS__)(mc); \ mc->desc = "QEMU " MACHINE_VER_STR(__VA_ARGS__) " LoongArch Virtual Machine"; \MACHINE_VER_DEPRECATION (__VA_ARGS__); \ +machine_class_set_name (mc,"virt-" MACHINE_VER_STR (__VA_ARGS__)); \if (latest) { \ mc->alias ="virt" ; \ mc->is_default = true; \
@@ -1550,7 +1551,7 @@ static void virt_class_init(ObjectClass *oc, const void *data) } \static const TypeInfo MACHINE_VER_SYM (info ,virt ,__VA_ARGS__ ) = \ { \ - .name =MACHINE_VER_TYPE_NAME ("virt" , __VA_ARGS__), \ + .name =MACHINE_VER_TYPE_NAME ("loongarch-virt" , __VA_ARGS__), \ .parent =TYPE_LOONGARCH_VIRT_MACHINE , \ .class_init =MACHINE_VER_SYM (class_init, virt, __VA_ARGS__), \ }; \
include/hw/loongarch/virt.h +1 -1
@@ -130,7 +130,7 @@ struct LoongArchVirtMachineState {bool highmem_mmio; }; -#define TYPE_LOONGARCH_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +#define TYPE_LOONGARCH_VIRT_MACHINE MACHINE_TYPE_NAME("loongarch-virt") OBJECT_DECLARE_SIMPLE_TYPE(LoongArchVirtMachineState, LOONGARCH_VIRT_MACHINE)void virt_acpi_setup (LoongArchVirtMachineState *lvms);void virt_fdt_setup (LoongArchVirtMachineState *lvms);
Signature · 1 line
2.52.0.windows.1
Re: [PATCH v2 6/9] hw/loongarch/virt: use unique QOM name
Quoted 4 lines · Yonggang Luo
Set
TYPE_LOONGARCH_VIRT_MACHINEtoMACHINE_TYPE_NAME("loongarch-virt")so LoongArch virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt-* viamachine_class_set_name().
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 7/9 hw/m68k/virt: use unique QOM name
In reply to Yonggang LuoSet the parent and versioned QOM types to m68k-virt so M68K virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt-* via machine_class_set_name().
--- hw/m68k/virt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
hw/m68k/virt.c +4 -3
@@ -323,7 +323,7 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data) }static const TypeInfo virt_machine_info = { - .name =MACHINE_TYPE_NAME ("virt" ), + .name =MACHINE_TYPE_NAME ("m68k-virt" ), .parent =TYPE_MACHINE , .abstract = true, .class_init = virt_machine_class_init,
@@ -345,14 +345,15 @@ type_init(virt_machine_register_types)MACHINE_VER_SYM (options, virt, __VA_ARGS__)(mc); \ mc->desc = "QEMU " MACHINE_VER_STR(__VA_ARGS__) " M68K Virtual Machine"; \MACHINE_VER_DEPRECATION (__VA_ARGS__); \ +machine_class_set_name (mc,"virt-" MACHINE_VER_STR (__VA_ARGS__)); \if (latest) { \ mc->alias ="virt" ; \ } \ } \static const TypeInfo MACHINE_VER_SYM (info ,virt ,__VA_ARGS__ ) = \ { \ - .name =MACHINE_VER_TYPE_NAME ("virt" , __VA_ARGS__), \ - .parent =MACHINE_TYPE_NAME ("virt" ), \ + .name =MACHINE_VER_TYPE_NAME ("m68k-virt" , __VA_ARGS__), \ + .parent =MACHINE_TYPE_NAME ("m68k-virt" ), \ .class_init =MACHINE_VER_SYM (class_init, virt, __VA_ARGS__), \ }; \ static void MACHINE_VER_SYM(register, virt, __VA_ARGS__)(void) \
Signature · 1 line
2.52.0.windows.1
Re: [PATCH v2 7/9] hw/m68k/virt: use unique QOM name
Quoted 4 lines · Yonggang Luo
Set the parent and versioned QOM types to m68k-virt so M68K virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt-* via
machine_class_set_name().
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 8/9 hw/xtensa/virt: use unique QOM name
In reply to Yonggang LuoRegister the board as xtensa-virt so Xtensa virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt via machine_class_set_name().
--- hw/xtensa/virt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/xtensa/virt.c +2 -1
@@ -118,10 +118,11 @@ static void xtensa_virt_init(MachineState *machine)static void xtensa_virt_machine_init (MachineClass *mc) { mc->desc ="virt machine (" XTENSA_DEFAULT_CPU_MODEL ")" ; +machine_class_set_name (mc,"virt" ); mc->init = xtensa_virt_init; mc->max_cpus =32 ; mc->default_cpu_type =XTENSA_DEFAULT_CPU_TYPE ; mc->default_nic ="virtio-net-pci" ; } -DEFINE_MACHINE ("virt" , xtensa_virt_machine_init) +DEFINE_MACHINE ("xtensa-virt" , xtensa_virt_machine_init)
Signature · 1 line
2.52.0.windows.1
Re: [PATCH v2 8/9] hw/xtensa/virt: use unique QOM name
Quoted 3 lines · Yonggang Luo
Register the board as xtensa-virt so Xtensa virt no longer collides with other virt-machine types in one process. Keep the -M / help / migration name as virt via
machine_class_set_name().
Signature · 1 line
Marc-André Lureau <[email protected]>
PATCH v2 9/9 qapi: return MachineInfo typename from query-machines
In reply to Yonggang Luoquery-machines returned only the -M name, so management apps inferred the QOM type as that name plus "-machine". A prefixed type such as arm-virt-11.1-machine no longer matches -M virt-11.1. Return the QOM type in MachineInfo typename from object_class_get_name() in qmp_query_machines(). test_query_machines_typename checks that qom-list-properties accepts it.
--- hw/core/machine-qmp-cmds.c | 1 + qapi/machine.json | 6 +++- tests/qtest/qom-test.c | 65 ++++++++++++++++++++++++++++++++++---- 3 files changed, 65 insertions(+), 7 deletions(-)
hw/core/machine-qmp-cmds.c +1 -0
@@ -116,6 +116,7 @@ MachineInfoList *qmp_query_machines(bool has_compat_props, bool compat_props, } info->name =g_strdup (mc->name); + info->q_typename =g_strdup (object_class_get_name (OBJECT_CLASS (mc))); info->cpu_max = !mc->max_cpus ?1 : mc->max_cpus; info->hotpluggable_cpus = mc->has_hotpluggable_cpus; info->numa_mem_supported = mc->numa_mem_supported;
qapi/machine.json +5 -1
@@ -168,6 +168,9 @@ # # @name: the name of the machine # +# @typename: QOM type name of the machine, for qom-list-properties +# (since 11.2) +# # @alias: an alias for the machine name # # @is-default: whether the machine is default
@@ -208,7 +211,7 @@ # Since: 1.2 ## { 'struct': 'MachineInfo', - 'data': { 'name': 'str', '*alias': 'str', + 'data': { 'name': 'str', 'typename': 'str', '*alias': 'str', '*is-default': 'bool', 'cpu-max': 'int', 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool', 'deprecated': 'bool', '*default-cpu-type': 'str',
@@ -238,6 +241,7 @@ # { # "hotpluggable-cpus": true, # "name": "pc-q35-6.2", +# "typename": "pc-q35-6.2-machine", # "compat-props": [ # { # "qom-type": "virtio-mem",
tests/qtest/qom-test.c +59 -6
84 lines not on this page · raw message
Signature · 1 line
2.52.0.windows.1
Re: [PATCH v2 9/9] qapi: return MachineInfo typename from query-machines
Quoted 7 lines · Yonggang Luo
query-machines returned only the -M name, so management apps inferred the QOM type as that name plus "-machine". A prefixed type such as arm-virt-11.1-machine no longer matches -M virt-11.1. Return the QOM type in MachineInfo typename from
object_class_get_name()inqmp_query_machines().test_query_machines_typenamechecks that qom-list-properties accepts it.
Quoted 6 lines
Signed-off-by Yonggang Luo <[email protected]>--- hw/core/machine-qmp-cmds.c | 1 + qapi/machine.json | 6 +++- tests/qtest/qom-test.c | 65 ++++++++++++++++++++++++++++++++++---- 3 files changed, 65 insertions(+), 7 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH v2 9/9] qapi: return MachineInfo typename from query-machines
In reply to Yonggang LuoQuoted 8 lines · Yonggang Luo
query-machines returned only the -M name, so management apps inferred the QOM type as that name plus "-machine". A prefixed type such as arm-virt-11.1-machine no longer matches -M virt-11.1. Return the QOM type in MachineInfo typename from
object_class_get_name()inqmp_query_machines().test_query_machines_typenamechecks that qom-list-properties accepts it.[...]
Signature · 1 line
Marc-André Lureau <[email protected]>