Commit bce54474 authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Andreas Färber
Browse files

qdev: Move bus properties to abstract superclasses



In qdev, each bus in practice identified an abstract superclass, but
this was mostly hidden.  In QOM, instead, these abstract classes are
explicit so we can move bus properties there.

All bus property walks are removed, and all device property walks
are changed to look along the class hierarchy instead.

We would have duplicates if class A defines some properties and its
subclass B does not define any, because class_b->props will be
left equal to class_a->props.

The solution here is to reintroduce the class_base_init TypeInfo
callback, that was present in one of the early QOM versions but
removed (on my request...) before committing.

This breaks global bus properties, an obscure feature when used
with the command-line which is actually useful and used when used by
backwards-compatible machine types.  So this patch also adjusts the
global bus properties in hw/pc_piix.c to refer to the abstract class.

Globals and other properties must be modified in the same patch to
avoid complications related to initialization ordering.

Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarAndreas Färber <afaerber@suse.de>
parent 3cb75a7c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ static Property i2c_props[] = {
static struct BusInfo i2c_bus_info = {
    .name = "I2C",
    .size = sizeof(i2c_bus),
    .props = i2c_props,
};

static void i2c_bus_pre_save(void *opaque)
@@ -221,6 +220,7 @@ static void i2c_slave_class_init(ObjectClass *klass, void *data)
    DeviceClass *k = DEVICE_CLASS(klass);
    k->init = i2c_slave_qdev_init;
    k->bus_info = &i2c_bus_info;
    k->props = i2c_props;
}

static TypeInfo i2c_slave_type_info = {
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ static struct BusInfo ide_bus_info = {
    .name  = "IDE",
    .size  = sizeof(IDEBus),
    .get_fw_dev_path = idebus_get_fw_dev_path,
    .props = ide_props,
};

void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id)
@@ -251,6 +250,7 @@ static void ide_device_class_init(ObjectClass *klass, void *data)
    DeviceClass *k = DEVICE_CLASS(klass);
    k->init = ide_qdev_init;
    k->bus_info = &ide_bus_info;
    k->props = ide_props;
}

static TypeInfo ide_device_type_info = {
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ static Property hda_props[] = {
static struct BusInfo hda_codec_bus_info = {
    .name      = "HDA",
    .size      = sizeof(HDACodecBus),
    .props     = hda_props,
};

void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus,
@@ -1278,6 +1277,7 @@ static void hda_codec_device_class_init(ObjectClass *klass, void *data)
    k->init = hda_codec_dev_init;
    k->exit = hda_codec_dev_exit;
    k->bus_info = &hda_codec_bus_info;
    k->props = hda_props;
}

static TypeInfo hda_codec_device_type_info = {
+4 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include "apic.h"
#include "pci.h"
#include "pci_ids.h"
#include "usb.h"
#include "net.h"
#include "boards.h"
#include "ide.h"
@@ -374,7 +375,7 @@ static QEMUMachine pc_machine_v1_1 = {
            .property = "vapic",\
            .value    = "off",\
        },{\
            .driver   = "USB",\
            .driver   = TYPE_USB_DEVICE,\
            .property = "full-path",\
            .value    = "no",\
        }
@@ -447,7 +448,7 @@ static QEMUMachine pc_machine_v0_14 = {
#define PC_COMPAT_0_13 \
        PC_COMPAT_0_14,\
        {\
            .driver   = "PCI",\
            .driver   = TYPE_PCI_DEVICE,\
            .property = "command_serr_enable",\
            .value    = "off",\
        },{\
@@ -519,7 +520,7 @@ static QEMUMachine pc_machine_v0_12 = {
            .property = "vectors",\
            .value    = stringify(0),\
        },{\
            .driver   = "PCI",\
            .driver   = TYPE_PCI_DEVICE,\
            .property = "rombar",\
            .value    = stringify(0),\
        }
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ struct BusInfo pci_bus_info = {
    .get_dev_path = pcibus_get_dev_path,
    .get_fw_dev_path = pcibus_get_fw_dev_path,
    .reset      = pcibus_reset,
    .props      = pci_props,
};

static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num);
@@ -2003,6 +2002,7 @@ static void pci_device_class_init(ObjectClass *klass, void *data)
    k->unplug = pci_unplug_device;
    k->exit = pci_unregister_device;
    k->bus_info = &pci_bus_info;
    k->props = pci_props;
}

static TypeInfo pci_device_type_info = {
Loading