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>
This commit is contained in:
Eduardo Habkost 2015-08-20 14:54:36 -07:00 committed by Andreas Färber
parent dcb3d60111
commit 98cec76a70
8 changed files with 6 additions and 18 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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));
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

1
vl.c
View File

@ -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;