On 11/12/2026 5:30 AM, Daniel P. Berrangé wrote: > Stop setting 'alias' in the MachineClass and instead set > 'aliases' in the AliasedClass. > > Signed-off-by: Daniel P. Berrangé <[email protected]> > --- > hw/arm/aspeed_ast27x0_evb.c | 7 ++++++- > hw/arm/virt.c | 12 +++++++++++- > hw/arm/xlnx-versal-virt.c | 7 ++++++- > 3 files changed, 23 insertions(+), 3 deletions(-) > > diff --git a/hw/arm/aspeed_ast27x0_evb.c b/hw/arm/aspeed_ast27x0_evb.c > index 460c9ff0d2e..9f7d4395114 100644 > --- a/hw/arm/aspeed_ast27x0_evb.c > +++ b/hw/arm/aspeed_ast27x0_evb.c > @@ -11,6 +11,7 @@ > #include "hw/arm/aspeed.h" > #include "hw/arm/aspeed_soc.h" > #include "hw/sensor/tmp105.h" > +#include "qom/object_interfaces.h" > > /* AST2700 evb hardware value */ > /* SCU HW Strap1 */ > @@ -53,8 +54,12 @@ static void > aspeed_machine_ast2700a2_evb_class_init(ObjectClass *oc, > { > MachineClass *mc = MACHINE_CLASS(oc); > AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); > + AliasedClass *alc = ALIASED_CLASS(oc); > + static const char *const aliases[] = { > + MACHINE_TYPE_NAME("ast2700-evb"), NULL, > + }; > > - mc->alias = "ast2700-evb"; > + alc->aliases = aliases; > mc->desc = "Aspeed AST2700 A2 EVB (Cortex-A35)"; > amc->soc_name = "ast2700-a2"; > amc->hw_strap1 = AST2700_EVB_HW_STRAP1; > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > index e481d0e548b..60385971b6a 100644 > --- a/hw/arm/virt.c > +++ b/hw/arm/virt.c > @@ -94,6 +94,7 @@ > #include "hw/cxl/cxl_host.h" > #include "qemu/guest-random.h" > #include "hw/watchdog/sbsa_gwdt.h" > +#include "qom/object_interfaces.h" > > static GlobalProperty arm_virt_compat_defaults[] = { > { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "48" }, > @@ -139,9 +140,18 @@ static void arm_virt_compat_default_set(MachineClass *mc) > } \ > type_init(MACHINE_VER_SYM(register, virt, __VA_ARGS__)); > > +#define DEFINE_VIRT_MACHINE_ALIASES_LATEST(...) \ > + AliasedClass *alc = ALIASED_CLASS(oc); \ > + static const char *const MACHINE_VER_SYM(aliases, virt, __VA_ARGS__)[] = > \ > + { \ > + MACHINE_TYPE_NAME("virt"), \ > + NULL, \ > + }; \ > + alc->aliases = MACHINE_VER_SYM(aliases, virt, __VA_ARGS__) > + > #define DEFINE_VIRT_MACHINE_AS_LATEST(major, minor) \ > DEFINE_VIRT_MACHINE_IMPL({ \ > - mc->alias = "virt"; \ > + DEFINE_VIRT_MACHINE_ALIASES_LATEST(major, minor); \ > }, major, minor) > #define DEFINE_VIRT_MACHINE(major, minor) \ > DEFINE_VIRT_MACHINE_IMPL({}, major, minor) > diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c > index 4018f2bf7d1..309063d38d8 100644 > --- a/hw/arm/xlnx-versal-virt.c > +++ b/hw/arm/xlnx-versal-virt.c > @@ -23,6 +23,7 @@ > #include "hw/arm/boot.h" > #include "qom/object.h" > #include "target/arm/cpu.h" > +#include "qom/object_interfaces.h" > > #define TYPE_XLNX_VERSAL_VIRT_BASE_MACHINE \ > MACHINE_TYPE_NAME("amd-versal-virt-base") > @@ -368,9 +369,13 @@ static void versal_virt_machine_class_init(ObjectClass > *oc, const void *data) > { > MachineClass *mc = MACHINE_CLASS(oc); > VersalVirtClass *vvc = XLNX_VERSAL_VIRT_BASE_MACHINE_CLASS(oc); > + AliasedClass *alc = ALIASED_CLASS(oc); > + static const char *const aliases[] = { > + MACHINE_TYPE_NAME("xlnx-versal-virt"), NULL, > + }; > > mc->desc = "AMD Versal Virtual development board"; > - mc->alias = "xlnx-versal-virt"; > + alc->aliases = aliases; > vvc->version = VERSAL_VER_VERSAL; > > versal_virt_machine_class_init_common(oc);
Looks good overall, even though a bit verbose. I'm not sure we can really get anything better in C with static variables unfortunately. Reviewed-by: Pierrick Bouvier <[email protected]>
