Fix machine class names to use the "-machine" suffix
cover Fix machine class names to use the "-machine" suffix
The machine class names in QEMU are not consistent today. Some of them use the "-machine" suffix, but some use completely different naming conventions. This makes it difficult to implement machine class lookup without iterating through the whole list of machine classes.
This series changes all machines to use "<machine name>-machine" as the class name, so we can simply use object_class_by_name() in the future to lookup machine classes. (This was not done yet because it will also require some changes in the way aliases are handled.)
Eduardo Habkost (10):
machine: MACHINE_TYPE_NAME macro
vexpress: Don't set name on abstract class
vexpress: Rename machine classes to use MACHINE_TYPE_NAME
arm: Rename virt machine class to use MACHINE_TYPE_NAME
pseries: Rename machine class names to use MACHINE_TYPE_NAME
s390-virtio: Rename machine class name to use MACHINE_TYPE_NAME
s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
mac99: Use MACHINE_TYPE_NAME to encode class name
machine: Ensure all TYPE_MACHINE subclasses have the right suffix
machine: Set MachineClass::name automatically
hw/arm/vexpress.c | 7 ++----- hw/arm/virt.c | 4 ++-- hw/core/machine.c | 12 ++++++++++++ hw/ppc/mac_newworld.c | 3 +-- hw/ppc/spapr.c | 12 ++++-------- hw/s390x/s390-virtio-ccw.c | 2 +- hw/s390x/s390-virtio.c | 4 ++-- include/hw/boards.h | 6 ++++++ vl.c | 3 +-- 9 files changed, 31 insertions(+), 22 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/10 machine: MACHINE_TYPE_NAME macro
The macro will be useful to ensure the machine class names follow the right format to make machine class lookup by class name work correctly.
--- include/hw/boards.h | 6 ++++++ vl.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
include/hw/boards.h +6 -0
@@ -40,6 +40,12 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,int qemu_register_machine (QEMUMachine *m);#define TYPE_MACHINE_SUFFIX "-machine" + +/* Machine class name that needs to be used for class-name-based machine +* type lookup to work. +*/ +#define MACHINE_TYPE_NAME (machinename) (machinename TYPE_MACHINE_SUFFIX) +#define TYPE_MACHINE "machine"#undef MACHINE/* BSD defines it and QEMU does not use it */ #define MACHINE (obj) \
vl.c +1 -1
@@ -1447,7 +1447,7 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data)int qemu_register_machine (QEMUMachine *m) { -char *name =g_strconcat (m->name,TYPE_MACHINE_SUFFIX ,NULL ); +char *name =g_strdup_printf (MACHINE_TYPE_NAME ("%s" ), m->name);TypeInfo ti = { .name = name, .parent =TYPE_MACHINE ,
Signature · 1 line
2.1.0
PATCH 2/10 vexpress: Don't set name on abstract class
In reply to Eduardo HabkostThe MachineClass::name field won't be ever be used on TYPE_VEXPRESS, as it is an abstract class and the machine class lookup code explicitly skips abstract classes. We can remove it to make the code simpler.
--- hw/arm/vexpress.c | 1 - 1 file changed, 1 deletion(-)
hw/arm/vexpress.c +0 -1
@@ -747,7 +747,6 @@ static void vexpress_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name =TYPE_VEXPRESS_MACHINE ; mc->desc ="ARM Versatile Express" ; mc->init = vexpress_common_init; mc->block_default_type =IF_SCSI ;
Signature · 1 line
2.1.0
PATCH 3/10 vexpress: Rename machine classes to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostMachine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the vexpress machine classes using the MACHINE_TYPE_NAME macro.
--- hw/arm/vexpress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/vexpress.c +2 -2
@@ -168,8 +168,8 @@ typedef struct { } VexpressMachineState;#define TYPE_VEXPRESS_MACHINE "vexpress" -#define TYPE_VEXPRESS_A9_MACHINE "vexpress-a9" -#define TYPE_VEXPRESS_A15_MACHINE "vexpress-a15" +#define TYPE_VEXPRESS_A9_MACHINE MACHINE_TYPE_NAME("vexpress-a9") +#define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME("vexpress-a15")#define VEXPRESS_MACHINE (obj) \ OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)#define VEXPRESS_MACHINE_GET_CLASS (obj) \
Signature · 1 line
2.1.0
PATCH 4/10 arm: Rename virt machine class to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostMachine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the arm virt machine class using the MACHINE_TYPE_NAME macro.
--- hw/arm/virt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/arm/virt.c +3 -2
@@ -81,7 +81,8 @@ typedef struct {bool secure; } VirtMachineState; -#define TYPE_VIRT_MACHINE "virt" +#define VIRT_MACHINE_NAME "virt" +#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME(VIRT_MACHINE_NAME)#define VIRT_MACHINE (obj) \ OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE)#define VIRT_MACHINE_GET_CLASS (obj) \
@@ -959,7 +960,7 @@ static void virt_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name =TYPE_VIRT_MACHINE ; + mc->name =VIRT_MACHINE_NAME ; mc->desc ="ARM Virtual Machine" , mc->init = machvirt_init; mc->max_cpus =8 ;
Signature · 1 line
2.1.0
PATCH 5/10 pseries: Rename machine class names to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostMachine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the the pseries machine classes using the MACHINE_TYPE_NAME macro.
--- hw/ppc/spapr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/ppc/spapr.c +4 -4
@@ -1925,7 +1925,7 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data) }static const TypeInfo spapr_machine_2_1_info = { - .name =TYPE_SPAPR_MACHINE "2.1" , + .name =MACHINE_TYPE_NAME ("pseries-2.1" ), .parent =TYPE_SPAPR_MACHINE , .class_init = spapr_machine_2_1_class_init, .instance_init = spapr_machine_2_1_instance_init,
@@ -1945,7 +1945,7 @@ static void spapr_machine_2_2_class_init(ObjectClass *oc, void *data) }static const TypeInfo spapr_machine_2_2_info = { - .name =TYPE_SPAPR_MACHINE "2.2" , + .name =MACHINE_TYPE_NAME ("pseries-2.2" ), .parent =TYPE_SPAPR_MACHINE , .class_init = spapr_machine_2_2_class_init, .instance_init = spapr_machine_2_2_instance_init,
@@ -1965,7 +1965,7 @@ static void spapr_machine_2_3_class_init(ObjectClass *oc, void *data) }static const TypeInfo spapr_machine_2_3_info = { - .name =TYPE_SPAPR_MACHINE "2.3" , + .name =MACHINE_TYPE_NAME ("pseries-2.3" ), .parent =TYPE_SPAPR_MACHINE , .class_init = spapr_machine_2_3_class_init, .instance_init = spapr_machine_2_3_instance_init,
@@ -1982,7 +1982,7 @@ static void spapr_machine_2_4_class_init(ObjectClass *oc, void *data) }static const TypeInfo spapr_machine_2_4_info = { - .name =TYPE_SPAPR_MACHINE "2.4" , + .name =MACHINE_TYPE_NAME ("pseries-2.4" ), .parent =TYPE_SPAPR_MACHINE , .class_init = spapr_machine_2_4_class_init, };
Signature · 1 line
2.1.0
PATCH 6/10 s390-virtio: Rename machine class name to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostMachine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the s390-virtio machine class using the MACHINE_TYPE_NAME macro.
--- hw/s390x/s390-virtio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/s390x/s390-virtio.c +3 -2
@@ -52,7 +52,8 @@#define MAX_BLK_DEVS 10#define ZIPL_FILENAME "s390-zipl.rom" -#define TYPE_S390_MACHINE "s390-machine" +#define S390_MACHINE "s390-virtio" +#define TYPE_S390_MACHINE MACHINE_TYPE_NAME(S390_MACHINE)#define S390_TOD_CLOCK_VALUE_MISSING 0x00#define S390_TOD_CLOCK_VALUE_PRESENT 0x01
@@ -333,7 +334,7 @@ static void s390_machine_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc);NMIClass *nc =NMI_CLASS (oc); - mc->name ="s390-virtio" ; + mc->name =S390_MACHINE ; mc->alias ="s390" ; mc->desc ="VirtIO based S390 machine" ; mc->init = s390_init;
Signature · 1 line
2.1.0
PATCH 9/10 machine: Ensure all TYPE_MACHINE subclasses have the right suffix
In reply to Eduardo HabkostNow that all non-abstract TYPE_MACHINE subclasses have the -machine suffix, add an assert to ensure this will be always true.
--- hw/core/machine.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/core/machine.c +9 -0
@@ -302,6 +302,14 @@ static void machine_class_init(ObjectClass *oc, void *data) mc->default_ram_size =128 *M_BYTE ; } +static void machine_class_base_init (ObjectClass *oc,void *data) +{ +if (!object_class_is_abstract (oc)) { +const char *cname =object_class_get_name (oc); +assert (g_str_has_suffix (cname,TYPE_MACHINE_SUFFIX )); + } +} +static void machine_initfn (Object *obj) {MachineState *ms =MACHINE (obj);
@@ -472,6 +480,7 @@ static const TypeInfo machine_info = { .abstract = true, .class_size = sizeof(MachineClass), .class_init = machine_class_init, + .class_base_init = machine_class_base_init, .instance_size = sizeof(MachineState), .instance_init = machine_initfn, .instance_finalize = machine_finalize,
Signature · 1 line
2.1.0
PATCH 8/10 mac99: Use MACHINE_TYPE_NAME to encode class name
In reply to Eduardo HabkostIt will result in exactly the same class name, but it will make the code consistent with the other classes.
--- hw/ppc/mac_newworld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/mac_newworld.c +1 -1
@@ -517,7 +517,7 @@ static void core99_machine_class_init(ObjectClass *oc, void *data) }static const TypeInfo core99_machine_info = { - .name ="mac99-machine" , + .name =MACHINE_TYPE_NAME ("mac99" ), .parent =TYPE_MACHINE , .class_init = core99_machine_class_init, };
Signature · 1 line
2.1.0
PATCH 7/10 s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostMachine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the s390-ccw-virtio-2.4 machine class using the MACHINE_TYPE_NAME macro.
--- hw/s390x/s390-virtio-ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +1 -1
@@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) }static const TypeInfo ccw_machine_2_4_info = { - .name =TYPE_S390_CCW_MACHINE "2.4" , + .name =MACHINE_TYPE_NAME ("s390-ccw-virtio-2.4" ), .parent =TYPE_S390_CCW_MACHINE , .class_init = ccw_machine_2_4_class_init, };
Signature · 1 line
2.1.0
PATCH 10/10 machine: Set MachineClass::name automatically
In reply to Eduardo HabkostNow all TYPE_MACHINE subclasses use MACHINE_TYPE_NAME to generate the class name. So instead of requiring each subclass to set MachineClass::name manually, we can now set it automatically at the TYPE_MACHINE class_base_init() function.
--- hw/arm/vexpress.c | 2 -- hw/arm/virt.c | 1 - hw/core/machine.c | 3 +++ hw/ppc/mac_newworld.c | 1 - hw/ppc/spapr.c | 4 ---- hw/s390x/s390-virtio.c | 1 - vl.c | 1 - 7 files changed, 3 insertions(+), 10 deletions(-)
hw/arm/vexpress.c +0 -2
@@ -758,7 +758,6 @@ static void vexpress_a9_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc);VexpressMachineClass *vmc =VEXPRESS_MACHINE_CLASS (oc); - mc->name =TYPE_VEXPRESS_A9_MACHINE ; mc->desc ="ARM Versatile Express for Cortex-A9" ; vmc->daughterboard = &a9_daughterboard;;
@@ -769,7 +768,6 @@ static void vexpress_a15_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc);VexpressMachineClass *vmc =VEXPRESS_MACHINE_CLASS (oc); - mc->name =TYPE_VEXPRESS_A15_MACHINE ; mc->desc ="ARM Versatile Express for Cortex-A15" ; vmc->daughterboard = &a15_daughterboard;
hw/arm/virt.c +0 -1
@@ -960,7 +960,6 @@ static void virt_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name =VIRT_MACHINE_NAME ; mc->desc ="ARM Virtual Machine" , mc->init = machvirt_init; mc->max_cpus =8 ;
hw/core/machine.c +3 -0
@@ -305,8 +305,11 @@ static void machine_class_init(ObjectClass *oc, void *data)static void machine_class_base_init (ObjectClass *oc,void *data) {if (!object_class_is_abstract (oc)) { +MachineClass *mc =MACHINE_CLASS (oc);const char *cname =object_class_get_name (oc);assert (g_str_has_suffix (cname,TYPE_MACHINE_SUFFIX )); + mc->name =g_strndup (cname, +strlen (cname) -strlen (TYPE_MACHINE_SUFFIX )); } }
hw/ppc/mac_newworld.c +0 -1
@@ -508,7 +508,6 @@ static void core99_machine_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name ="mac99" ; mc->desc ="Mac99 based PowerMAC" ; mc->init = ppc_core99_init; mc->max_cpus =MAX_CPUS ;
hw/ppc/spapr.c +0 -4
@@ -1919,7 +1919,6 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data) {/* end of list */ } }; - mc->name ="pseries-2.1" ; mc->desc ="pSeries Logical Partition (PAPR compliant) v2.1" ; mc->compat_props = compat_props; }
@@ -1939,7 +1938,6 @@ static void spapr_machine_2_2_class_init(ObjectClass *oc, void *data) };MachineClass *mc =MACHINE_CLASS (oc); - mc->name ="pseries-2.2" ; mc->desc ="pSeries Logical Partition (PAPR compliant) v2.2" ; mc->compat_props = compat_props; }
@@ -1959,7 +1957,6 @@ static void spapr_machine_2_3_class_init(ObjectClass *oc, void *data) };MachineClass *mc =MACHINE_CLASS (oc); - mc->name ="pseries-2.3" ; mc->desc ="pSeries Logical Partition (PAPR compliant) v2.3" ; mc->compat_props = compat_props; }
@@ -1975,7 +1972,6 @@ static void spapr_machine_2_4_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name ="pseries-2.4" ; mc->desc ="pSeries Logical Partition (PAPR compliant) v2.4" ; mc->alias ="pseries" ; mc->is_default =1 ;
hw/s390x/s390-virtio.c +0 -1
@@ -334,7 +334,6 @@ static void s390_machine_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc);NMIClass *nc =NMI_CLASS (oc); - mc->name =S390_MACHINE ; mc->alias ="s390" ; mc->desc ="VirtIO based S390 machine" ; mc->init = s390_init;
vl.c +0 -1
@@ -1432,7 +1432,6 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc);QEMUMachine *qm = data; - mc->name = qm->name; mc->desc = qm->desc; mc->init = qm->init; mc->kvm_type = qm->kvm_type;
Signature · 1 line
2.1.0
Quoted 9 lines · On Thu, 20 Aug 2015 14:54:26 -0700 Eduardo Habkost <[email protected]> wrote:
The machine class names in QEMU are not consistent today. Some of them use the "-machine" suffix, but some use completely different naming conventions. This makes it difficult to implement machine class lookup without iterating through the whole list of machine classes.
This series changes all machines to use "<machine name>-machine" as the class name, so we can simply use
object_class_by_name()in the future to lookup machine classes. (This was not done yet because it will also require some changes in the way aliases are handled.)
I've played around with the s390 machines a bit and it seems to do the right thing using the same commandlines as before.
One question: info qom-tree shows the new machine class names - is there anybody (other than a human looking at it) making use of that information?
Quoted 13 lines · Cornelia Huck
Quoted 9 lines · On Thu, 20 Aug 2015 14:54:26 -0700 Eduardo Habkost <[email protected]> wrote:
The machine class names in QEMU are not consistent today. Some of them use the "-machine" suffix, but some use completely different naming conventions. This makes it difficult to implement machine class lookup without iterating through the whole list of machine classes.
This series changes all machines to use "<machine name>-machine" as the class name, so we can simply use
object_class_by_name()in the future to lookup machine classes. (This was not done yet because it will also require some changes in the way aliases are handled.)
Quoted 6 lines
I've played around with the s390 machines a bit and it seems to do the right thing using the same commandlines as before.
One question: info qom-tree shows the new machine class names - is there anybody (other than a human looking at it) making use of that information?
I don't believe anybody is using it. It would be possible to use the class name for something useful if machines were user-creatable objects, but they aren't.
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
In reply to Eduardo HabkostQuoted 130 lines · Eduardo Habkost
Now all
TYPE_MACHINEsubclasses useMACHINE_TYPE_NAMEto generate the class name. So instead of requiring each subclass to setMachineClass::namemanually, we can now set it automatically at theTYPE_MACHINEclass_base_init()function.Signed-off-by Eduardo Habkost <[email protected]>--- hw/arm/vexpress.c | 2 -- hw/arm/virt.c | 1 - hw/core/machine.c | 3 +++ hw/ppc/mac_newworld.c | 1 - hw/ppc/spapr.c | 4 ---- hw/s390x/s390-virtio.c | 1 - vl.c | 1 - 7 files changed, 3 insertions(+), 10 deletions(-)hw/arm/vexpress.c +0
-2@@ -758,7 +758,6 @@ static void vexpress_a9_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc);VexpressMachineClass *vmc =VEXPRESS_MACHINE_CLASS (oc); - mc->name =TYPE_VEXPRESS_A9_MACHINE ; mc->desc ="ARM Versatile Express for Cortex-A9" ; vmc->daughterboard = &a9_daughterboard;;@@ -769,7 +768,6 @@ static void vexpress_a15_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc);VexpressMachineClass *vmc =VEXPRESS_MACHINE_CLASS (oc); - mc->name =TYPE_VEXPRESS_A15_MACHINE ; mc->desc ="ARM Versatile Express for Cortex-A15" ; vmc->daughterboard = &a15_daughterboard;hw/arm/virt.c +0
-1@@ -960,7 +960,6 @@ static void virt_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name =VIRT_MACHINE_NAME ; mc->desc ="ARM Virtual Machine" , mc->init = machvirt_init; mc->max_cpus =8 ;hw/core/machine.c +3
-0@@ -305,8 +305,11 @@ static void machine_class_init(ObjectClass *oc, void *data)static void machine_class_base_init (ObjectClass *oc,void *data) {if (!object_class_is_abstract (oc)) { +MachineClass *mc =MACHINE_CLASS (oc);const char *cname =object_class_get_name (oc);assert (g_str_has_suffix (cname,TYPE_MACHINE_SUFFIX )); + mc->name =g_strndup (cname, +strlen (cname) -strlen (TYPE_MACHINE_SUFFIX )); } }hw/ppc/mac_newworld.c +0
-1@@ -508,7 +508,6 @@ static void core99_machine_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name ="mac99" ; mc->desc ="Mac99 based PowerMAC" ; mc->init = ppc_core99_init; mc->max_cpus =MAX_CPUS ;hw/ppc/spapr.c +0
-4@@ -1919,7 +1919,6 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data) {/* end of list */ } }; - mc->name ="pseries-2.1" ; mc->desc ="pSeries Logical Partition (PAPR compliant) v2.1" ; mc->compat_props = compat_props; }@@ -1939,7 +1938,6 @@ static void spapr_machine_2_2_class_init(ObjectClass *oc, void *data) };MachineClass *mc =MACHINE_CLASS (oc); - mc->name ="pseries-2.2" ; mc->desc ="pSeries Logical Partition (PAPR compliant) v2.2" ; mc->compat_props = compat_props; }@@ -1959,7 +1957,6 @@ static void spapr_machine_2_3_class_init(ObjectClass *oc, void *data) };MachineClass *mc =MACHINE_CLASS (oc); - mc->name ="pseries-2.3" ; mc->desc ="pSeries Logical Partition (PAPR compliant) v2.3" ; mc->compat_props = compat_props; }@@ -1975,7 +1972,6 @@ static void spapr_machine_2_4_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name ="pseries-2.4" ; mc->desc ="pSeries Logical Partition (PAPR compliant) v2.4" ; mc->alias ="pseries" ; mc->is_default =1 ;hw/s390x/s390-virtio.c +0
-1@@ -334,7 +334,6 @@ static void s390_machine_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc);NMIClass *nc =NMI_CLASS (oc); - mc->name =S390_MACHINE ; mc->alias ="s390" ; mc->desc ="VirtIO based S390 machine" ; mc->init = s390_init;vl.c +0
-0
vl.c static void qemu_machine_class_init(ObjectClass *oc, void *data) · line 1437
Quoted 7 lines
vl.c +0
-1@@ -1432,7 +1432,6 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc);QEMUMachine *qm = data; - mc->name = qm->name; mc->desc = qm->desc; mc->init = qm->init; mc->kvm_type = qm->kvm_type;
Nice!
Please forget the possible stupid question, but what happens with *all* other machine types? Why don't we have to remove the "name" assignment from the other machine types too?
Thanks,
Marcel
Re: [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro
In reply to Eduardo HabkostQuoted 32 lines · Eduardo Habkost
The macro will be useful to ensure the machine class names follow the right format to make machine class lookup by class name work correctly.
Signed-off-by Eduardo Habkost <[email protected]>--- include/hw/boards.h | 6 ++++++ vl.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)include/hw/boards.h +6
-0@@ -40,6 +40,12 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,int qemu_register_machine (QEMUMachine *m);#define TYPE_MACHINE_SUFFIX "-machine" + +/* Machine class name that needs to be used for class-name-based machine +* type lookup to work. +*/ +#define MACHINE_TYPE_NAME (machinename) (machinename TYPE_MACHINE_SUFFIX) +#define TYPE_MACHINE "machine"#undef MACHINE/* BSD defines it and QEMU does not use it */ #define MACHINE (obj) \vl.c +0
-0
vl.c static void qemu_machine_class_init(ObjectClass *oc, void *data) · line 1453
Quoted 8 lines
vl.c +1
-1@@ -1447,7 +1447,7 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data)int qemu_register_machine (QEMUMachine *m) { -char *name =g_strconcat (m->name,TYPE_MACHINE_SUFFIX ,NULL ); +char *name =g_strdup_printf (MACHINE_TYPE_NAME ("%s" ), m->name);TypeInfo ti = { .name = name, .parent =TYPE_MACHINE ,
Thanks,
Marcel
Re: [Qemu-devel] [PATCH 09/10] machine: Ensure all TYPE_MACHINE subclasses have the right suffix
In reply to Eduardo HabkostQuoted 29 lines · Eduardo Habkost
Now that all non-abstract
TYPE_MACHINEsubclasses have the -machine suffix, add an assert to ensure this will be always true.Signed-off-by Eduardo Habkost <[email protected]>--- hw/core/machine.c | 9 +++++++++ 1 file changed, 9 insertions(+)hw/core/machine.c +8
-0@@ -302,6 +302,14 @@ static void machine_class_init(ObjectClass *oc, void *data) mc->default_ram_size =128 *M_BYTE ; } +static void machine_class_base_init (ObjectClass *oc,void *data) +{ +if (!object_class_is_abstract (oc)) { +const char *cname =object_class_get_name (oc); +assert (g_str_has_suffix (cname,TYPE_MACHINE_SUFFIX )); + } +} +static void machine_initfn (Object *obj) {MachineState *ms =MACHINE (obj);
hw/core/machine.c static const TypeInfo machine_info = { · line 486
Quoted 7 lines
hw/core/machine.c +1
-0@@ -472,6 +480,7 @@ static const TypeInfo machine_info = { .abstract = true, .class_size = sizeof(MachineClass), .class_init = machine_class_init, + .class_base_init = machine_class_base_init, .instance_size = sizeof(MachineState), .instance_init = machine_initfn, .instance_finalize = machine_finalize,
Thanks,
Marcel
Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
In reply to Marcel ApfelbaumQuoted 16 lines · Marcel Apfelbaum
Quoted 15 lines · Eduardo Habkost
Now all
TYPE_MACHINEsubclasses useMACHINE_TYPE_NAMEto generate the class name. So instead of requiring each subclass to setMachineClass::namemanually, we can now set it automatically at theTYPE_MACHINEclass_base_init()function.Signed-off-by Eduardo Habkost <[email protected]>--- hw/arm/vexpress.c | 2 -- hw/arm/virt.c | 1 - hw/core/machine.c | 3 +++ hw/ppc/mac_newworld.c | 1 - hw/ppc/spapr.c | 4 ---- hw/s390x/s390-virtio.c | 1 - vl.c | 1 - 7 files changed, 3 insertions(+), 10 deletions(-)
[...]
Quoted 16 lines
vl.c static void qemu_machine_class_init(ObjectClass *oc, void *data) · line 1437
Quoted 13 lines
vl.c +0
-1@@ -1432,7 +1432,6 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc);QEMUMachine *qm = data; - mc->name = qm->name; mc->desc = qm->desc; mc->init = qm->init; mc->kvm_type = qm->kvm_type;Nice!
Quoted 3 lines
Please forget the possible stupid question, but what happens with *all* other machine types? Why don't we have to remove the "name" assignment from the other machine types too?
Unless I made a mistake and missed something when grepping the code, all machine-types were changed. Most of them use qemu_register_machine() (which uses qemu_machine_class_init(), changed above).
Signature · 1 line
Eduardo
Marcel Apfelbaum
Reviewed-byRe: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
Quoted 34 lines · Eduardo Habkost
Quoted 16 lines · Marcel Apfelbaum
Quoted 15 lines · Eduardo Habkost
Now all
TYPE_MACHINEsubclasses useMACHINE_TYPE_NAMEto generate the class name. So instead of requiring each subclass to setMachineClass::namemanually, we can now set it automatically at theTYPE_MACHINEclass_base_init()function.Signed-off-by Eduardo Habkost <[email protected]>--- hw/arm/vexpress.c | 2 -- hw/arm/virt.c | 1 - hw/core/machine.c | 3 +++ hw/ppc/mac_newworld.c | 1 - hw/ppc/spapr.c | 4 ---- hw/s390x/s390-virtio.c | 1 - vl.c | 1 - 7 files changed, 3 insertions(+), 10 deletions(-)[...]
Quoted 16 lines
vl.c static void qemu_machine_class_init(ObjectClass *oc, void *data) · line 1437
Quoted 13 lines
vl.c +0
-1@@ -1432,7 +1432,6 @@ static void qemu_machine_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc);QEMUMachine *qm = data; - mc->name = qm->name; mc->desc = qm->desc; mc->init = qm->init; mc->kvm_type = qm->kvm_type;Nice!
Quoted 8 lines
Quoted 3 lines
Please forget the possible stupid question, but what happens with *all* other machine types? Why don't we have to remove the "name" assignment from the other machine types too?
Unless I made a mistake and missed something when grepping the code, all machine-types were changed. Most of them use
qemu_register_machine()(which usesqemu_machine_class_init(), changed above).
OK, thanks for the answer.
Thanks,
Marcel
Re: [Qemu-devel] [PATCH 01/10] machine: MACHINE_TYPE_NAME macro
In reply to Eduardo HabkostQuoted 4 lines · Eduardo Habkost
The macro will be useful to ensure the machine class names follow the right format to make machine class lookup by class name work correctly.
Signed-off-by Eduardo Habkost <[email protected]>
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 02/10] vexpress: Don't set name on abstract class
In reply to Eduardo HabkostQuoted 6 lines · Eduardo Habkost
The
MachineClass::namefield won't be ever be used onTYPE_VEXPRESS, as it is an abstract class and the machine class lookup code explicitly skips abstract classes. We can remove it to make the code simpler.Cc Peter Maydell <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 04/10] arm: Rename virt machine class to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostQuoted 6 lines · Eduardo Habkost
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the arm virt machine class using the
MACHINE_TYPE_NAMEmacro.Cc Peter Maydell <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 06/10] s390-virtio: Rename machine class name to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostQuoted 7 lines · Eduardo Habkost
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the s390-virtio machine class using the
MACHINE_TYPE_NAMEmacro.Cc Alexander Graf <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Quoted 27 lines
--- hw/s390x/s390-virtio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)hw/s390x/s390-virtio.c +3
-2@@ -52,7 +52,8 @@#define MAX_BLK_DEVS 10#define ZIPL_FILENAME "s390-zipl.rom" -#define TYPE_S390_MACHINE "s390-machine" +#define S390_MACHINE "s390-virtio" +#define TYPE_S390_MACHINE MACHINE_TYPE_NAME(S390_MACHINE)#define S390_TOD_CLOCK_VALUE_MISSING 0x00#define S390_TOD_CLOCK_VALUE_PRESENT 0x01@@ -333,7 +334,7 @@ static void s390_machine_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc);NMIClass *nc =NMI_CLASS (oc); - mc->name ="s390-virtio" ; + mc->name =S390_MACHINE ; mc->alias ="s390" ; mc->desc ="VirtIO based S390 machine" ; mc->init = s390_init;
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostQuoted 6 lines · Eduardo Habkost
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the vexpress machine classes using the
MACHINE_TYPE_NAMEmacro.Cc Peter Maydell <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 05/10] pseries: Rename machine class names to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostQuoted 7 lines · Eduardo Habkost
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the the pseries machine classes using the
MACHINE_TYPE_NAMEmacro.Cc Alexander Graf <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
I'm also happy to take this through by spapr-next tree if that's useful to do.
Quoted 44 lines
--- hw/ppc/spapr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)hw/ppc/spapr.c +4
-4@@ -1925,7 +1925,7 @@ static void spapr_machine_2_1_class_init(ObjectClass *oc, void *data) }static const TypeInfo spapr_machine_2_1_info = { - .name =TYPE_SPAPR_MACHINE "2.1" , + .name =MACHINE_TYPE_NAME ("pseries-2.1" ), .parent =TYPE_SPAPR_MACHINE , .class_init = spapr_machine_2_1_class_init, .instance_init = spapr_machine_2_1_instance_init,@@ -1945,7 +1945,7 @@ static void spapr_machine_2_2_class_init(ObjectClass *oc, void *data) }static const TypeInfo spapr_machine_2_2_info = { - .name =TYPE_SPAPR_MACHINE "2.2" , + .name =MACHINE_TYPE_NAME ("pseries-2.2" ), .parent =TYPE_SPAPR_MACHINE , .class_init = spapr_machine_2_2_class_init, .instance_init = spapr_machine_2_2_instance_init,@@ -1965,7 +1965,7 @@ static void spapr_machine_2_3_class_init(ObjectClass *oc, void *data) }static const TypeInfo spapr_machine_2_3_info = { - .name =TYPE_SPAPR_MACHINE "2.3" , + .name =MACHINE_TYPE_NAME ("pseries-2.3" ), .parent =TYPE_SPAPR_MACHINE , .class_init = spapr_machine_2_3_class_init, .instance_init = spapr_machine_2_3_instance_init,@@ -1982,7 +1982,7 @@ static void spapr_machine_2_4_class_init(ObjectClass *oc, void *data) }static const TypeInfo spapr_machine_2_4_info = { - .name =TYPE_SPAPR_MACHINE "2.4" , + .name =MACHINE_TYPE_NAME ("pseries-2.4" ), .parent =TYPE_SPAPR_MACHINE , .class_init = spapr_machine_2_4_class_init, };
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostQuoted 9 lines · Eduardo Habkost
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the s390-ccw-virtio-2.4 machine class using the
MACHINE_TYPE_NAMEmacro.Cc Alexander Graf <[email protected]>Cc Cornelia Huck <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Quoted 17 lines
--- hw/s390x/s390-virtio-ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/s390x/s390-virtio-ccw.c +1
-1@@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) }static const TypeInfo ccw_machine_2_4_info = { - .name =TYPE_S390_CCW_MACHINE "2.4" , + .name =MACHINE_TYPE_NAME ("s390-ccw-virtio-2.4" ), .parent =TYPE_S390_CCW_MACHINE , .class_init = ccw_machine_2_4_class_init, };
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH 08/10] mac99: Use MACHINE_TYPE_NAME to encode class name
In reply to Eduardo HabkostQuoted 6 lines · Eduardo Habkost
It will result in exactly the same class name, but it will make the code consistent with the other classes.
Cc Alexander Graf <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Quoted 17 lines
--- hw/ppc/mac_newworld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/ppc/mac_newworld.c +1
-1@@ -517,7 +517,7 @@ static void core99_machine_class_init(ObjectClass *oc, void *data) }static const TypeInfo core99_machine_info = { - .name ="mac99-machine" , + .name =MACHINE_TYPE_NAME ("mac99" ), .parent =TYPE_MACHINE , .class_init = core99_machine_class_init, };
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Ping?
Andreas, should this go through your QOM tree?
Quoted 44 lines · Eduardo Habkost
The machine class names in QEMU are not consistent today. Some of them use the "-machine" suffix, but some use completely different naming conventions. This makes it difficult to implement machine class lookup without iterating through the whole list of machine classes.
This series changes all machines to use "<machine name>-machine" as the class name, so we can simply use
object_class_by_name()in the future to lookup machine classes. (This was not done yet because it will also require some changes in the way aliases are handled.)Cc Alexander Graf <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Cornelia Huck <[email protected]>Cc Peter Maydell <[email protected]>Cc Richard Henderson <[email protected]>Eduardo Habkost (10):
machine:MACHINE_TYPE_NAMEmacro
vexpress: Don't set name on abstract class
vexpress: Rename machine classes to useMACHINE_TYPE_NAME
arm: Rename virt machine class to useMACHINE_TYPE_NAME
pseries: Rename machine class names to useMACHINE_TYPE_NAME
s390-virtio: Rename machine class name to useMACHINE_TYPE_NAME
s390: Rename s390-ccw-virtio-2.4 class name to useMACHINE_TYPE_NAME
mac99: UseMACHINE_TYPE_NAMEto encode class name
machine: Ensure allTYPE_MACHINEsubclasses have the right suffix
machine: SetMachineClass::nameautomaticallyhw/arm/vexpress.c | 7 ++----- hw/arm/virt.c | 4 ++-- hw/core/machine.c | 12 ++++++++++++ hw/ppc/mac_newworld.c | 3 +-- hw/ppc/spapr.c | 12 ++++-------- hw/s390x/s390-virtio-ccw.c | 2 +- hw/s390x/s390-virtio.c | 4 ++-- include/hw/boards.h | 6 ++++++ vl.c | 3 +-- 9 files changed, 31 insertions(+), 22 deletions(-)Signature · 1 line
2.1.0
Signature · 1 line
Eduardo
Cornelia Huck
Acked-byQuoted 1 line · On Wed, 2 Sep 2015 16:58:45 -0300 Eduardo Habkost <[email protected]> wrote:
Ping?
In case that helps:
Quoted 49 lines
Andreas, should this go through your QOM tree?
Quoted 44 lines · Eduardo Habkost
The machine class names in QEMU are not consistent today. Some of them use the "-machine" suffix, but some use completely different naming conventions. This makes it difficult to implement machine class lookup without iterating through the whole list of machine classes.
This series changes all machines to use "<machine name>-machine" as the class name, so we can simply use
object_class_by_name()in the future to lookup machine classes. (This was not done yet because it will also require some changes in the way aliases are handled.)Cc Alexander Graf <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Cornelia Huck <[email protected]>Cc Peter Maydell <[email protected]>Cc Richard Henderson <[email protected]>Eduardo Habkost (10):
machine:MACHINE_TYPE_NAMEmacro
vexpress: Don't set name on abstract class
vexpress: Rename machine classes to useMACHINE_TYPE_NAME
arm: Rename virt machine class to useMACHINE_TYPE_NAME
pseries: Rename machine class names to useMACHINE_TYPE_NAME
s390-virtio: Rename machine class name to useMACHINE_TYPE_NAME
s390: Rename s390-ccw-virtio-2.4 class name to useMACHINE_TYPE_NAME
mac99: UseMACHINE_TYPE_NAMEto encode class name
machine: Ensure allTYPE_MACHINEsubclasses have the right suffix
machine: SetMachineClass::nameautomaticallyhw/arm/vexpress.c | 7 ++----- hw/arm/virt.c | 4 ++-- hw/core/machine.c | 12 ++++++++++++ hw/ppc/mac_newworld.c | 3 +-- hw/ppc/spapr.c | 12 ++++-------- hw/s390x/s390-virtio-ccw.c | 2 +- hw/s390x/s390-virtio.c | 4 ++-- include/hw/boards.h | 6 ++++++ vl.c | 3 +-- 9 files changed, 31 insertions(+), 22 deletions(-)Signature · 1 line
2.1.0
Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostAm 20.08.2015 um 23:54 schrieb Eduardo Habkost:
Quoted 19 lines
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the s390-ccw-virtio-2.4 machine class using the
MACHINE_TYPE_NAMEmacro.Cc Alexander Graf <[email protected]>Cc Cornelia Huck <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/s390x/s390-virtio-ccw.c +0
-0
hw/s390x/s390-virtio-ccw.c static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) · line 299
Quoted 8 lines
hw/s390x/s390-virtio-ccw.c +1
-1@@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) }static const TypeInfo ccw_machine_2_4_info = { - .name =TYPE_S390_CCW_MACHINE "2.4" , + .name =MACHINE_TYPE_NAME ("s390-ccw-virtio-2.4" ), .parent =TYPE_S390_CCW_MACHINE , .class_init = ccw_machine_2_4_class_init, };
Since yesterday you also need to adopt the 2.5 machine....
Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
Quoted 21 lines · Christian Borntraeger
Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
Quoted 20 lines
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the s390-ccw-virtio-2.4 machine class using the
MACHINE_TYPE_NAMEmacro.Cc Alexander Graf <[email protected]>Cc Cornelia Huck <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/s390x/s390-virtio-ccw.c +0
-0@@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) }
Quoted 9 lines
hw/s390x/s390-virtio-ccw.c static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) · line 299
Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +1
-1static const TypeInfo ccw_machine_2_4_info = { - .name =TYPE_S390_CCW_MACHINE "2.4" , + .name =MACHINE_TYPE_NAME ("s390-ccw-virtio-2.4" ), .parent =TYPE_S390_CCW_MACHINE , .class_init = ccw_machine_2_4_class_init, };Since yesterday you also need to adopt the 2.5 machine....
Thanks for for noting! I will rebase and resubmit.
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
Am 04.09.2015 um 16:54 schrieb Eduardo Habkost:
Quoted 32 lines · Christian Borntraeger
Quoted 21 lines
Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
Quoted 20 lines
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the s390-ccw-virtio-2.4 machine class using the
MACHINE_TYPE_NAMEmacro.Cc Alexander Graf <[email protected]>Cc Cornelia Huck <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/s390x/s390-virtio-ccw.c +0
-0@@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) }Quoted 9 lines
hw/s390x/s390-virtio-ccw.c static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) · line 299
Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +1
-1static const TypeInfo ccw_machine_2_4_info = { - .name =TYPE_S390_CCW_MACHINE "2.4" , + .name =MACHINE_TYPE_NAME ("s390-ccw-virtio-2.4" ), .parent =TYPE_S390_CCW_MACHINE , .class_init = ccw_machine_2_4_class_init, };Since yesterday you also need to adopt the 2.5 machine....
Quoted 1 line
Thanks for for noting! I will rebase and resubmit.
If it's just a single line addition I can edit that when applying. Anything else in need of changes?
Regards,
Andreas
Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
Quoted 33 lines · Andreas Färber
Am 04.09.2015 um 16:54 schrieb Eduardo Habkost:
Quoted 32 lines · Christian Borntraeger
Quoted 30 lines
Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
Quoted 19 lines
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the s390-ccw-virtio-2.4 machine class using the
MACHINE_TYPE_NAMEmacro.Cc Alexander Graf <[email protected]>Cc Cornelia Huck <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/s390x/s390-virtio-ccw.c +0
-0hw/s390x/s390-virtio-ccw.c static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) · line 299
Quoted 8 lines
hw/s390x/s390-virtio-ccw.c +1
-1@@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) }static const TypeInfo ccw_machine_2_4_info = { - .name =TYPE_S390_CCW_MACHINE "2.4" , + .name =MACHINE_TYPE_NAME ("s390-ccw-virtio-2.4" ), .parent =TYPE_S390_CCW_MACHINE , .class_init = ccw_machine_2_4_class_init, };Since yesterday you also need to adopt the 2.5 machine....
Quoted 3 lines
Quoted 1 line
Thanks for for noting! I will rebase and resubmit.
If it's just a single line addition I can edit that when applying.
Thanks!
Quoted 1 line
Anything else in need of changes?
That's the only needed change, unless other machine classes were added since I have submitted this patch. But missing a few classes won't break bisectability, and can be fixed by a follow-up patch if necessary.
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 07/10] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME
Quoted 38 lines · Eduardo Habkost
Quoted 33 lines · Andreas Färber
Am 04.09.2015 um 16:54 schrieb Eduardo Habkost:
Quoted 32 lines · Christian Borntraeger
Quoted 30 lines
Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
Quoted 19 lines
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the s390-ccw-virtio-2.4 machine class using the
MACHINE_TYPE_NAMEmacro.Cc Alexander Graf <[email protected]>Cc Cornelia Huck <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Richard Henderson <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/s390x/s390-virtio-ccw.c +0
-0hw/s390x/s390-virtio-ccw.c static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) · line 299
Quoted 8 lines
hw/s390x/s390-virtio-ccw.c +1
-1@@ -293,7 +293,7 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) }static const TypeInfo ccw_machine_2_4_info = { - .name =TYPE_S390_CCW_MACHINE "2.4" , + .name =MACHINE_TYPE_NAME ("s390-ccw-virtio-2.4" ), .parent =TYPE_S390_CCW_MACHINE , .class_init = ccw_machine_2_4_class_init, };Since yesterday you also need to adopt the 2.5 machine....
Quoted 3 lines
Quoted 1 line
Thanks for for noting! I will rebase and resubmit.
If it's just a single line addition I can edit that when applying.
Quoted 7 lines
Thanks!
Quoted 1 line
Anything else in need of changes?
That's the only needed change, unless other machine classes were added since I have submitted this patch. But missing a few classes won't break bisectability, and can be fixed by a follow-up patch if necessary.
I have just double-checked that there are no other machine classes that need to be renamed. For reference, this is the patch that needs to be squashed into this one:
hw/s390x/s390-virtio-ccw.c +1 -1
@@ -319,7 +319,7 @@ static void ccw_machine_2_5_class_init(ObjectClass *oc, void *data) }static const TypeInfo ccw_machine_2_5_info = { - .name =TYPE_S390_CCW_MACHINE "2.5" , + .name =MACHINE_TYPE_NAME ("s390-ccw-virtio-2.5" ), .parent =TYPE_S390_CCW_MACHINE , .class_init = ccw_machine_2_5_class_init, };
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
In reply to Eduardo HabkostQuoted 6 lines · Eduardo Habkost
Now all
TYPE_MACHINEsubclasses useMACHINE_TYPE_NAMEto generate the class name. So instead of requiring each subclass to setMachineClass::namemanually, we can now set it automatically at theTYPE_MACHINEclass_base_init()function.Signed-off-by Eduardo Habkost <[email protected]>
The s390-virtio-ccw machines are missing from this patch. The following patch can be squashed into this one.
If a more formal follow-up patch or v2 patch is preferred, please let me know.
---
hw/s390x/s390-virtio-ccw.c +0 -2
@@ -297,7 +297,6 @@ static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data) {/* end of list */ } }; - mc->name ="s390-ccw-virtio-2.4" ; mc->desc ="VirtIO-ccw based S390 machine v2.4" ; mc->compat_props = compat_props; }
@@ -312,7 +311,6 @@ static void ccw_machine_2_5_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name ="s390-ccw-virtio-2.5" ; mc->alias ="s390-ccw-virtio" ; mc->desc ="VirtIO-ccw based S390 machine v2.5" ; mc->is_default =1 ;
Signature · 1 line
Eduardo
Am 02.09.2015 um 21:58 schrieb Eduardo Habkost:
Quoted 3 lines
Ping?
Andreas, should this go through your QOM tree?
Long-term I would prefer a separate machine maintainer (Marcel?) to handle this, but as discussed in Seattle, I'm applying this series to qom-next and will look at the follow-up series next.
https://github.com/afaerber/qemu-cpu/commits/qom-next
Thanks,
Andreas
Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
Quoted 6 lines · Andreas Färber
Am 02.09.2015 um 21:58 schrieb Eduardo Habkost:
Quoted 3 lines
Ping?
Andreas, should this go through your QOM tree?
Long-term I would prefer a separate machine maintainer (Marcel?)
Hi Andreas,
I can be the machine maintainer, sure.
I should start maintaining contribution anyway, this could be a start.
Thanks,
Marcel
to
Quoted 8 lines
handle this, but as discussed in Seattle, I'm applying this series to qom-next and will look at the follow-up series next.
https://github.com/afaerber/qemu-cpu/commits/qom-next
Thanks,
Andreas
Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
In reply to Eduardo HabkostAm 20.08.2015 um 23:54 schrieb Eduardo Habkost:
hw/arm/virt.c static void virt_class_init(ObjectClass *oc, void *data) · line 965
Quoted 12 lines
hw/arm/virt.c +0
-1@@ -960,7 +960,6 @@ static void virt_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name =VIRT_MACHINE_NAME ; mc->desc ="ARM Virtual Machine" , mc->init = machvirt_init; mc->max_cpus =8 ;
I am going to squash the following cleanup reverting 04/10 change:
hw/arm/virt.c +1 -2
@@ -83,8 +83,7 @@ typedef struct {bool highmem; } VirtMachineState; -#define VIRT_MACHINE_NAME "virt" -#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME(VIRT_MACHINE_NAME) +#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt")#define VIRT_MACHINE (obj) \ OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE)#define VIRT_MACHINE_GET_CLASS (obj) \
Regards,
Andreas
Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
Re: [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME
In reply to Eduardo HabkostAm 20.08.2015 um 23:54 schrieb Eduardo Habkost:
Quoted 15 lines
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the vexpress machine classes using the
MACHINE_TYPE_NAMEmacro.Cc Peter Maydell <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>--- hw/arm/vexpress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/arm/vexpress.c +0
-0
hw/arm/vexpress.c typedef struct { · line 175
Quoted 10 lines
hw/arm/vexpress.c +2
-2@@ -168,8 +168,8 @@ typedef struct { } VexpressMachineState;#define TYPE_VEXPRESS_MACHINE "vexpress" -#define TYPE_VEXPRESS_A9_MACHINE "vexpress-a9" -#define TYPE_VEXPRESS_A15_MACHINE "vexpress-a15" +#define TYPE_VEXPRESS_A9_MACHINE MACHINE_TYPE_NAME("vexpress-a9") +#define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME("vexpress-a15")#define VEXPRESS_MACHINE (obj) \ OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)#define VEXPRESS_MACHINE_GET_CLASS (obj) \
This is temporarily changing MachineClass::name to ...-machine. Fixing as follows, as was done for virt in 04/10:
hw/arm/vexpress.c +3 -2
@@ -168,8 +168,10 @@ typedef struct { } VexpressMachineState;#define TYPE_VEXPRESS_MACHINE "vexpress" -#define TYPE_VEXPRESS_A9_MACHINE MACHINE_TYPE_NAME("vexpress-a9") -#define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME("vexpress-a15") +#define VEXPRESS_A9_MACHINE_NAME "vexpress-a9" +#define VEXPRESS_A15_MACHINE_NAME "vexpress-a15" +#define TYPE_VEXPRESS_A9_MACHINE
MACHINE_TYPE_NAME(VEXPRESS_A9_MACHINE_NAME)
+#define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME(VEXPRESS_A15_MACHINE_NAME)
#define VEXPRESS_MACHINE(obj) \
OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)
#define VEXPRESS_MACHINE_GET_CLASS(obj) \
@@ -786,13 +788,13 @@ static const TypeInfo vexpress_info = {
};
static const TypeInfo vexpress_a9_info = {
- .name = TYPE_VEXPRESS_A9_MACHINE,
+ .name = VEXPRESS_A9_MACHINE_NAME,
.parent = TYPE_VEXPRESS_MACHINE,
.class_init = vexpress_a9_class_init,
};
static const TypeInfo vexpress_a15_info = {
- .name = TYPE_VEXPRESS_A15_MACHINE,
+ .name = VEXPRESS_A15_MACHINE_NAME,
.parent = TYPE_VEXPRESS_MACHINE,
.class_init = vexpress_a15_class_init,
};
To be reverted in 10/10.
Regards,
Andreas
Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
Re: [Qemu-devel] [PATCH 03/10] vexpress: Rename machine classes to use MACHINE_TYPE_NAME
Am 19.09.2015 um 08:30 schrieb Andreas Färber:
Quoted 55 lines
Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
Quoted 15 lines
Machine class names should use the "-machine" suffix to allow class-name-based machine class lookup to work. Rename the vexpress machine classes using the
MACHINE_TYPE_NAMEmacro.Cc Peter Maydell <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>--- hw/arm/vexpress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/arm/vexpress.c +0
-0hw/arm/vexpress.c typedef struct { · line 175
Quoted 10 lines
hw/arm/vexpress.c +2
-2@@ -168,8 +168,8 @@ typedef struct { } VexpressMachineState;#define TYPE_VEXPRESS_MACHINE "vexpress" -#define TYPE_VEXPRESS_A9_MACHINE "vexpress-a9" -#define TYPE_VEXPRESS_A15_MACHINE "vexpress-a15" +#define TYPE_VEXPRESS_A9_MACHINE MACHINE_TYPE_NAME("vexpress-a9") +#define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME("vexpress-a15")#define VEXPRESS_MACHINE (obj) \ OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)#define VEXPRESS_MACHINE_GET_CLASS (obj) \This is temporarily changing
MachineClass::nameto ...-machine. Fixing as follows, as was done for virt in 04/10:hw/arm/vexpress.c +4
-2@@ -168,8 +168,10 @@ typedef struct { } VexpressMachineState;#define TYPE_VEXPRESS_MACHINE "vexpress" -#define TYPE_VEXPRESS_A9_MACHINE MACHINE_TYPE_NAME("vexpress-a9") -#define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME("vexpress-a15") +#define VEXPRESS_A9_MACHINE_NAME "vexpress-a9" +#define VEXPRESS_A15_MACHINE_NAME "vexpress-a15" +#define TYPE_VEXPRESS_A9_MACHINE MACHINE_TYPE_NAME(VEXPRESS_A9_MACHINE_NAME) +#define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME (VEXPRESS_A15_MACHINE_NAME) #define VEXPRESS_MACHINE(obj) \
OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)
#defineVEXPRESS_MACHINE_GET_CLASS(obj)\hw/arm/vexpress.c +1
-1@@ -786,13 +788,13 @@ static const TypeInfo vexpress_info = { };static const TypeInfo vexpress_a9_info = { - .name =TYPE_VEXPRESS_A9_MACHINE , + .name =VEXPRESS_A9_MACHINE_NAME ,
hw/arm/vexpress.c static const TypeInfo vexpress_info = { · line 800
Quoted 10 lines
hw/arm/vexpress.c +1
-1.parent = TYPE_VEXPRESS_MACHINE, .class_init = vexpress_a9_class_init, };static const TypeInfo vexpress_a15_info = { - .name =TYPE_VEXPRESS_A15_MACHINE , + .name =VEXPRESS_A15_MACHINE_NAME , .parent =TYPE_VEXPRESS_MACHINE , .class_init = vexpress_a15_class_init, };
Doh, wrong place, not my time of day...
hw/arm/vexpress.c +0 -0
@@ -760,7 +760,7 @@ static void vexpress_a9_class_init(ObjectClass *oc,
void *da
ta)
MachineClass *mc = MACHINE_CLASS(oc);
VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);- mc->name = TYPE_VEXPRESS_A9_MACHINE;
+ mc->name = VEXPRESS_A9_MACHINE_NAME;
mc->desc = "ARM Versatile Express for Cortex-A9";
vmc->daughterboard = &a9_daughterboard;
@@ -771,7 +771,7 @@ static void vexpress_a15_class_init(ObjectClass *oc,
void *data)
MachineClass *mc = MACHINE_CLASS(oc);
VexpressMachineClass *vmc = VEXPRESS_MACHINE_CLASS(oc);- mc->name = TYPE_VEXPRESS_A15_MACHINE;
+ mc->name = VEXPRESS_A15_MACHINE_NAME;
mc->desc = "ARM Versatile Express for Cortex-A15";
vmc->daughterboard = &a15_daughterboard;@@ -788,13 +788,13 @@ static const TypeInfo vexpress_info = {
};
static const TypeInfo vexpress_a9_info = {
- .name = VEXPRESS_A9_MACHINE_NAME,
+ .name = TYPE_VEXPRESS_A9_MACHINE,
.parent = TYPE_VEXPRESS_MACHINE,
.class_init = vexpress_a9_class_init,
};
static const TypeInfo vexpress_a15_info = {
- .name = VEXPRESS_A15_MACHINE_NAME,
+ .name = TYPE_VEXPRESS_A15_MACHINE,
.parent = TYPE_VEXPRESS_MACHINE,
.class_init = vexpress_a15_class_init,
};
Andreas
Quoted 6 lines
To be reverted in 10/10.
Regards,
Andreas
Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
Re: [Qemu-devel] [PATCH 10/10] machine: Set MachineClass::name automatically
In reply to Andreas FärberAm 19.09.2015 um 08:23 schrieb Andreas Färber:
Quoted 21 lines
Am 20.08.2015 um 23:54 schrieb Eduardo Habkost:
hw/arm/virt.c static void virt_class_init(ObjectClass *oc, void *data) · line 965
Quoted 12 lines
hw/arm/virt.c +0
-1@@ -960,7 +960,6 @@ static void virt_class_init(ObjectClass *oc, void *data) {MachineClass *mc =MACHINE_CLASS (oc); - mc->name =VIRT_MACHINE_NAME ; mc->desc ="ARM Virtual Machine" , mc->init = machvirt_init; mc->max_cpus =8 ;I am going to squash the following cleanup reverting 04/10 change:
hw/arm/virt.c +0
-0
hw/arm/virt.c typedef struct { · line 89
Quoted 9 lines
hw/arm/virt.c +1
-2@@ -83,8 +83,7 @@ typedef struct {bool highmem; } VirtMachineState; -#define VIRT_MACHINE_NAME "virt" -#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME(VIRT_MACHINE_NAME) +#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt")#define VIRT_MACHINE (obj) \ OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE)#define VIRT_MACHINE_GET_CLASS (obj) \
And for my corresponding 03/10 change:
hw/arm/vexpress.c +0 -0
@@@ -168,10 -168,10 +168,8 @@@ typedef struct } VexpressMachineState;
#define TYPE_VEXPRESS_MACHINE "vexpress"
--#define VEXPRESS_A9_MACHINE_NAME "vexpress-a9"
--#define VEXPRESS_A15_MACHINE_NAME "vexpress-a15" --#define TYPE_VEXPRESS_A9_MACHINE MACHINE_TYPE_NAME(VEXPRESS_A9_MACHINE_NAME)
--#define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME(VEXPRESS_A15_MACHINE_NAME)
++#define TYPE_VEXPRESS_A9_MACHINE MACHINE_TYPE_NAME("vexpress-a9")
++#define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME("vexpress-a15")
#define VEXPRESS_MACHINE(obj) \
OBJECT_CHECK(VexpressMachineState, (obj), TYPE_VEXPRESS_MACHINE)
#define VEXPRESS_MACHINE_GET_CLASS(obj) \
Quoted 4 lines
Regards,
Andreas
Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)