diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2015-08-20 14:54:36 -0700 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2015-09-19 16:39:28 +0200 |
commit | 98cec76a7076c4a38e16f1a9de170a7942b3be54 (patch) | |
tree | 22f0ef15c6c434a10033aeaf77717851e4fc3127 | |
parent | dcb3d601115eed77aef543fe3a920adc17544e06 (diff) |
machine: Set MachineClass::name automatically
Now 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.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
[AF/ehabkost: Updated for s390-ccw machines]
[AF: Cleanup of intermediate virt and vexpress name handling]
Signed-off-by: Andreas Färber <afaerber@suse.de>
-rw-r--r-- | hw/arm/vexpress.c | 8 | ||||
-rw-r--r-- | hw/arm/virt.c | 4 | ||||
-rw-r--r-- | hw/core/machine.c | 3 | ||||
-rw-r--r-- | hw/ppc/mac_newworld.c | 1 | ||||
-rw-r--r-- | hw/ppc/spapr.c | 4 | ||||
-rw-r--r-- | hw/s390x/s390-virtio-ccw.c | 2 | ||||
-rw-r--r-- | hw/s390x/s390-virtio.c | 1 | ||||
-rw-r--r-- | vl.c | 1 |
8 files changed, 6 insertions, 18 deletions
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 2bcd312453..058abbde3f 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -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) \ @@ -760,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 = VEXPRESS_A9_MACHINE_NAME; mc->desc = "ARM Versatile Express for Cortex-A9"; vmc->daughterboard = &a9_daughterboard; @@ -771,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 = VEXPRESS_A15_MACHINE_NAME; mc->desc = "ARM Versatile Express for Cortex-A15"; vmc->daughterboard = &a15_daughterboard; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index fba259529b..6bf0d6d591 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -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) \ @@ -1074,7 +1073,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; diff --git a/hw/core/machine.c b/hw/core/machine.c index 3c1f248e80..f4db340468 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -319,8 +319,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)); } } diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 31c40c9ff0..e1c5ed76bd 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -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; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 012b6ede3c..05926a3eb2 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -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; diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index e738b5b06a..36f78b417c 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -252,7 +252,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; } @@ -267,7 +266,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; diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index a1eca0958c..bc013eb3d4 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -319,7 +319,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; @@ -1437,7 +1437,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; |