Skip to content

Commit

Permalink
pc: Eliminate all *_machine_options() functions
Browse files Browse the repository at this point in the history
Finally eliminate all *_machine_options() functions, and instead make
the class_init functions for older machine-types reuse the class_init
functions from newer machine-types.

To allow the class_init reuse, the the PC_COMPAT_* macros were change to
not include the newer PC_COMPAT_* macros, like we did before.

As a side-effect, we fix the duplication on the PC_Q35_COMPAT_* macros,
which were expanded as the tree below:

    PC_Q35_COMPAT_1_4:
        PC_COMPAT_1_4:
            PC_COMPAT_1_5:
                PC_COMPAT_1_6:
                    PC_COMPAT_1_7:
                        PC_COMPAT_2_0:
                            [pc-2.0 vars]
                        [pc-1.7 vars]
                    [pc-1.6 vars]
                [pc-1.5 vars]
            [pc-1.5 vars]
        PC_Q35_COMPAT_1_5:
            PC_COMPAT_1_5:
                PC_COMPAT_1_6:
                    PC_COMPAT_1_7:
                        PC_COMPAT_2_0:
                            [pc-2.0 vars]
                        [pc-1.7 vars]
                    [pc-1.6 vars]
                [pc-1.5 vars]
            PC_Q35_COMPAT_1_6:
                PC_COMPAT_1_6:
                    PC_COMPAT_1_7:
                        PC_COMPAT_2_0:
                            [pc-2.0 vars]
                        [pc-1.7 vars]
                    [pc-1.6 vars]
                PC_Q35_COMPAT_1_7:
                    PC_COMPAT_1_7:
                        PC_COMPAT_2_0:
                            [pc-2.0 vars]
                        [pc-1.7 vars]
                    PC_Q35_COMPAT_2_0:
                        PC_COMPAT_2_0:
                            [pc-2.0 vars]
                        [pc-q35-2.0 vars]
                    [pc-q35-1.7 vars]
                [pc-q35-1.6 vars]
            [pc-q35-1.5 vars]
        [pc-q35-1.4 vars]

In other words, the contents of PC_COMPAT_2_0 appeared 5 times inside
PC_Q35_COMPAT_1_4.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
  • Loading branch information
ehabkost committed Jun 13, 2014
1 parent 0dc1626 commit 9edb1f7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 80 deletions.
90 changes: 28 additions & 62 deletions hw/i386/pc_piix.c
Expand Up @@ -408,16 +408,10 @@ static TypeInfo pc_i440fx_machine_type_info = {
.abstract = true,
};


static void pc_i440fx_2_1_machine_options(MachineClass *mc)
{
mc->default_machine_opts = "firmware=bios-256k.bin";
}

static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
pc_i440fx_2_1_machine_options(mc);
mc->default_machine_opts = "firmware=bios-256k.bin";
mc->alias = "pc";
mc->init = pc_init_pci;
mc->is_default = 1;
Expand All @@ -437,7 +431,9 @@ static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
PC_COMPAT_2_0,
{ /* end of list */ }
};
pc_i440fx_2_1_machine_options(mc);
pc_i440fx_machine_v2_1_class_init(oc, data);
mc->alias = NULL;
mc->is_default = false;
mc->init = pc_init_pci_2_0;
mc->name = "pc-i440fx-2.0";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -449,20 +445,15 @@ static TypeInfo pc_i440fx_machine_v2_0_type_info = {
.class_init = pc_i440fx_machine_v2_0_class_init,
};

static void pc_i440fx_1_7_machine_options(MachineClass *mc)
{
pc_i440fx_2_1_machine_options(mc);
mc->default_machine_opts = NULL;
}

static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_7,
{ /* end of list */ }
};
pc_i440fx_1_7_machine_options(mc);
pc_i440fx_machine_v2_0_class_init(oc, data);
mc->default_machine_opts = NULL;
mc->init = pc_init_pci_1_7;
mc->name = "pc-i440fx-1.7";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -481,7 +472,7 @@ static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_6,
{ /* end of list */ }
};
pc_i440fx_1_7_machine_options(mc);
pc_i440fx_machine_v1_7_class_init(oc, data);
mc->init = pc_init_pci_1_6;
mc->name = "pc-i440fx-1.6";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -500,7 +491,7 @@ static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_5,
{ /* end of list */ }
};
pc_i440fx_1_7_machine_options(mc);
pc_i440fx_machine_v1_6_class_init(oc, data);
mc->init = pc_init_pci_1_5;
mc->name = "pc-i440fx-1.5";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -512,20 +503,15 @@ static TypeInfo pc_i440fx_machine_v1_5_type_info = {
.class_init = pc_i440fx_machine_v1_5_class_init,
};

static void pc_i440fx_1_4_machine_options(MachineClass *mc)
{
pc_i440fx_1_7_machine_options(mc);
mc->hot_add_cpu = NULL;
}

static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_4,
{ /* end of list */ }
};
pc_i440fx_1_4_machine_options(mc);
pc_i440fx_machine_v1_5_class_init(oc, data);
mc->hot_add_cpu = NULL;
mc->init = pc_init_pci_1_4;
mc->name = "pc-i440fx-1.4";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -538,7 +524,6 @@ static TypeInfo pc_i440fx_machine_v1_4_type_info = {
};

#define PC_COMPAT_1_3 \
PC_COMPAT_1_4, \
{\
.driver = "usb-tablet",\
.property = "usb_version",\
Expand All @@ -564,7 +549,7 @@ static void pc_machine_v1_3_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_3,
{ /* end of list */ }
};
pc_i440fx_1_4_machine_options(mc);
pc_i440fx_machine_v1_4_class_init(oc, data);
mc->init = pc_init_pci_1_3;
mc->name = "pc-1.3";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -577,7 +562,6 @@ static TypeInfo pc_machine_v1_3_type_info = {
};

#define PC_COMPAT_1_2 \
PC_COMPAT_1_3,\
{\
.driver = "nec-usb-xhci",\
.property = "msi",\
Expand All @@ -604,20 +588,15 @@ static TypeInfo pc_machine_v1_3_type_info = {
.value = "off",\
}

static void pc_i440fx_1_2_machine_options(MachineClass *mc)
{
pc_i440fx_1_4_machine_options(mc);
mc->init = pc_init_pci_1_2;
}

static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_1_2,
{ /* end of list */ }
};
pc_i440fx_1_2_machine_options(mc);
pc_machine_v1_3_class_init(oc, data);
mc->init = pc_init_pci_1_2;
mc->name = "pc-1.2";
machine_class_register_compat_props_array(mc, compat_props);
}
Expand All @@ -629,7 +608,6 @@ static TypeInfo pc_machine_v1_2_type_info = {
};

#define PC_COMPAT_1_1 \
PC_COMPAT_1_2,\
{\
.driver = "virtio-scsi-pci",\
.property = "hotplug",\
Expand Down Expand Up @@ -667,7 +645,7 @@ static void pc_machine_v1_1_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_1,
{ /* end of list */ }
};
pc_i440fx_1_2_machine_options(mc);
pc_machine_v1_2_class_init(oc, data);
mc->name = "pc-1.1";
machine_class_register_compat_props_array(mc, compat_props);
}
Expand Down Expand Up @@ -705,7 +683,7 @@ static void pc_machine_v1_0_class_init(ObjectClass *oc, void *data)
PC_COMPAT_1_0,
{ /* end of list */ }
};
pc_i440fx_1_2_machine_options(mc);
pc_machine_v1_1_class_init(oc, data);
mc->hw_version = "1.0";
mc->name = "pc-1.0";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -717,20 +695,12 @@ static TypeInfo pc_machine_v1_0_type_info = {
.class_init = pc_machine_v1_0_class_init,
};

#define PC_COMPAT_0_15 \
PC_COMPAT_1_0

static void pc_machine_v0_15_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_0_15,
{ /* end of list */ }
};
pc_i440fx_1_2_machine_options(mc);
pc_machine_v1_0_class_init(oc, data);
mc->hw_version = "0.15";
mc->name = "pc-0.15";
machine_class_register_compat_props_array(mc, compat_props);
}

static TypeInfo pc_machine_v0_15_type_info = {
Expand All @@ -740,7 +710,6 @@ static TypeInfo pc_machine_v0_15_type_info = {
};

#define PC_COMPAT_0_14 \
PC_COMPAT_0_15,\
{\
.driver = "virtio-blk-pci",\
.property = "event_idx",\
Expand Down Expand Up @@ -775,7 +744,7 @@ static void pc_machine_v0_14_class_init(ObjectClass *oc, void *data)
},
{ /* end of list */ }
};
pc_i440fx_1_2_machine_options(mc);
pc_machine_v0_15_class_init(oc, data);
mc->hw_version = "0.14";
mc->name = "pc-0.14";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -788,7 +757,6 @@ static TypeInfo pc_machine_v0_14_type_info = {
};

#define PC_COMPAT_0_13 \
PC_COMPAT_0_14,\
{\
.driver = TYPE_PCI_DEVICE,\
.property = "command_serr_enable",\
Expand All @@ -799,17 +767,12 @@ static TypeInfo pc_machine_v0_14_type_info = {
.value = stringify(1),\
}

static void pc_i440fx_0_13_machine_options(MachineClass *mc)
{
pc_i440fx_1_2_machine_options(mc);
mc->init = pc_init_pci_no_kvmclock;
}

static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_0_13,
/*FIXME: why the heck is the following outside PC_COMPAT_0_13? */
{
.driver = "virtio-9p-pci",
.property = "vectors",
Expand All @@ -825,7 +788,8 @@ static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
},
{ /* end of list */ }
};
pc_i440fx_0_13_machine_options(mc);
pc_machine_v0_14_class_init(oc, data);
mc->init = pc_init_pci_no_kvmclock;
mc->hw_version = "0.13";
mc->name = "pc-0.13";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -838,7 +802,6 @@ static TypeInfo pc_machine_v0_13_type_info = {
};

#define PC_COMPAT_0_12 \
PC_COMPAT_0_13,\
{\
.driver = "virtio-serial-pci",\
.property = "max_ports",\
Expand Down Expand Up @@ -866,6 +829,7 @@ static void pc_machine_v0_12_class_init(ObjectClass *oc, void *data)
MachineClass *mc = MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_0_12,
/*FIXME: why this is outside PC_COMPAT_0_12? */
{
.driver = "VGA",
.property = "rombar",
Expand All @@ -877,7 +841,8 @@ static void pc_machine_v0_12_class_init(ObjectClass *oc, void *data)
},
{ /* end of list */ }
};
pc_i440fx_0_13_machine_options(mc);
/*FIXME: v0_13 class_init has additional props. why? */
pc_machine_v0_13_class_init(oc, data);
mc->hw_version = "0.12";
mc->name = "pc-0.12";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -890,7 +855,6 @@ static TypeInfo pc_machine_v0_12_type_info = {
};

#define PC_COMPAT_0_11 \
PC_COMPAT_0_12,\
{\
.driver = "virtio-blk-pci",\
.property = "vectors",\
Expand All @@ -906,6 +870,7 @@ static void pc_machine_v0_11_class_init(ObjectClass *oc, void *data)
MachineClass *mc = MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_0_11,
/*FIXME: not-reused props again. why? */
{
.driver = "ide-drive",
.property = "ver",
Expand All @@ -917,7 +882,8 @@ static void pc_machine_v0_11_class_init(ObjectClass *oc, void *data)
},
{ /* end of list */ }
};
pc_i440fx_0_13_machine_options(mc);
/*FIXME: v0_12 class_init has additional props. why? */
pc_machine_v0_12_class_init(oc, data);
mc->hw_version = "0.11";
mc->name = "pc-0.11";
machine_class_register_compat_props_array(mc, compat_props);
Expand All @@ -933,7 +899,6 @@ static void pc_machine_v0_10_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
PC_COMPAT_0_11,
{
.driver = "virtio-blk-pci",
.property = "class",
Expand All @@ -957,7 +922,8 @@ static void pc_machine_v0_10_class_init(ObjectClass *oc, void *data)
},
{ /* end of list */ }
};
pc_i440fx_0_13_machine_options(mc);
/*FIXME: additional props */
pc_machine_v0_11_class_init(oc, data);
mc->hw_version = "0.10";
mc->name = "pc-0.10";
machine_class_register_compat_props_array(mc, compat_props);
Expand Down
15 changes: 8 additions & 7 deletions hw/i386/pc_q35.c
Expand Up @@ -322,15 +322,10 @@ static TypeInfo pc_q35_machine_type_info = {
.abstract = true,
};

static void pc_q35_2_1_machine_options(MachineClass *mc)
{
mc->default_machine_opts = "firmware=bios-256k.bin";
}

static void pc_q35_machine_v2_1_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
pc_q35_2_1_machine_options(mc);
mc->default_machine_opts = "firmware=bios-256k.bin";
mc->alias = "q35";
mc->init = pc_q35_init;
mc->name = "pc-q35-2.1";
Expand All @@ -349,7 +344,8 @@ static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
PC_Q35_COMPAT_2_0,
{ /* end of list */ }
};
pc_q35_2_1_machine_options(mc);
pc_q35_machine_v2_1_class_init(oc, data);
mc->alias = NULL;
mc->init = pc_q35_init_2_0;
machine_class_register_compat_props_array(mc, compat_props);
mc->name = "pc-q35-2.0";
Expand All @@ -368,6 +364,8 @@ static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
PC_Q35_COMPAT_1_7,
{ /* end of list */ }
};
pc_q35_machine_v2_0_class_init(oc, data);
mc->default_machine_opts = NULL;
mc->init = pc_q35_init_1_7;
machine_class_register_compat_props_array(mc, compat_props);
mc->name = "pc-q35-1.7";
Expand All @@ -386,6 +384,7 @@ static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
PC_Q35_COMPAT_1_6,
{ /* end of list */ }
};
pc_q35_machine_v1_7_class_init(oc, data);
mc->init = pc_q35_init_1_6;
machine_class_register_compat_props_array(mc, compat_props);
mc->name = "pc-q35-1.6";
Expand All @@ -404,6 +403,7 @@ static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)
PC_Q35_COMPAT_1_5,
{ /* end of list */ }
};
pc_q35_machine_v1_6_class_init(oc, data);
mc->init = pc_q35_init_1_5;
machine_class_register_compat_props_array(mc, compat_props);
mc->name = "pc-q35-1.5";
Expand All @@ -422,6 +422,7 @@ static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data)
PC_Q35_COMPAT_1_4,
{ /* end of list */ }
};
pc_q35_machine_v1_5_class_init(oc, data);
mc->hot_add_cpu = NULL;
mc->init = pc_q35_init_1_4;
machine_class_register_compat_props_array(mc, compat_props);
Expand Down

0 comments on commit 9edb1f7

Please sign in to comment.