aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-pci.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-12-07 21:34:16 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2012-02-03 10:41:06 -0600
commit39bffca2030950ef6efe57c2fac8327a45ae1015 (patch)
tree325262f44978e6116c9e43f688c900e08ee83738 /hw/virtio-pci.c
parent212ad111683a5b5a79a74d6141a4b75f532a4c8f (diff)
qdev: register all types natively through QEMU Object Model
This was done in a mostly automated fashion. I did it in three steps and then rebased it into a single step which avoids repeatedly touching every file in the tree. The first step was a sed-based addition of the parent type to the subclass registration functions. The second step was another sed-based removal of subclass registration functions while also adding virtual functions from the base class into a class_init function as appropriate. Finally, a python script was used to convert the DeviceInfo structures and qdev_register_subclass functions to TypeInfo structures, class_init functions, and type_register_static calls. We are almost fully converted to QOM after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-pci.c')
-rw-r--r--hw/virtio-pci.c76
1 files changed, 44 insertions, 32 deletions
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 126fb087be..bc96552072 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -818,6 +818,7 @@ static Property virtio_blk_properties[] = {
static void virtio_blk_class_init(ObjectClass *klass, void *data)
{
+ DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = virtio_blk_init_pci;
@@ -826,15 +827,16 @@ static void virtio_blk_class_init(ObjectClass *klass, void *data)
k->device_id = PCI_DEVICE_ID_VIRTIO_BLOCK;
k->revision = VIRTIO_PCI_ABI_VERSION;
k->class_id = PCI_CLASS_STORAGE_SCSI;
+ dc->alias = "virtio-blk";
+ dc->reset = virtio_pci_reset;
+ dc->props = virtio_blk_properties;
}
-static DeviceInfo virtio_blk_info = {
- .name = "virtio-blk-pci",
- .alias = "virtio-blk",
- .size = sizeof(VirtIOPCIProxy),
- .props = virtio_blk_properties,
- .reset = virtio_pci_reset,
- .class_init = virtio_blk_class_init,
+static TypeInfo virtio_blk_info = {
+ .name = "virtio-blk-pci",
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(VirtIOPCIProxy),
+ .class_init = virtio_blk_class_init,
};
static Property virtio_net_properties[] = {
@@ -850,6 +852,7 @@ static Property virtio_net_properties[] = {
static void virtio_net_class_init(ObjectClass *klass, void *data)
{
+ DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = virtio_net_init_pci;
@@ -859,15 +862,16 @@ static void virtio_net_class_init(ObjectClass *klass, void *data)
k->device_id = PCI_DEVICE_ID_VIRTIO_NET;
k->revision = VIRTIO_PCI_ABI_VERSION;
k->class_id = PCI_CLASS_NETWORK_ETHERNET;
+ dc->alias = "virtio-net";
+ dc->reset = virtio_pci_reset;
+ dc->props = virtio_net_properties;
}
-static DeviceInfo virtio_net_info = {
- .name = "virtio-net-pci",
- .alias = "virtio-net",
- .size = sizeof(VirtIOPCIProxy),
- .props = virtio_net_properties,
- .reset = virtio_pci_reset,
- .class_init = virtio_net_class_init,
+static TypeInfo virtio_net_info = {
+ .name = "virtio-net-pci",
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(VirtIOPCIProxy),
+ .class_init = virtio_net_class_init,
};
static Property virtio_serial_properties[] = {
@@ -881,6 +885,7 @@ static Property virtio_serial_properties[] = {
static void virtio_serial_class_init(ObjectClass *klass, void *data)
{
+ DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = virtio_serial_init_pci;
@@ -889,15 +894,16 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data)
k->device_id = PCI_DEVICE_ID_VIRTIO_CONSOLE;
k->revision = VIRTIO_PCI_ABI_VERSION;
k->class_id = PCI_CLASS_COMMUNICATION_OTHER;
+ dc->alias = "virtio-serial";
+ dc->reset = virtio_pci_reset;
+ dc->props = virtio_serial_properties;
}
-static DeviceInfo virtio_serial_info = {
- .name = "virtio-serial-pci",
- .alias = "virtio-serial",
- .size = sizeof(VirtIOPCIProxy),
- .props = virtio_serial_properties,
- .reset = virtio_pci_reset,
- .class_init = virtio_serial_class_init,
+static TypeInfo virtio_serial_info = {
+ .name = "virtio-serial-pci",
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(VirtIOPCIProxy),
+ .class_init = virtio_serial_class_init,
};
static Property virtio_balloon_properties[] = {
@@ -907,6 +913,7 @@ static Property virtio_balloon_properties[] = {
static void virtio_balloon_class_init(ObjectClass *klass, void *data)
{
+ DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = virtio_balloon_init_pci;
@@ -915,23 +922,28 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data)
k->device_id = PCI_DEVICE_ID_VIRTIO_BALLOON;
k->revision = VIRTIO_PCI_ABI_VERSION;
k->class_id = PCI_CLASS_MEMORY_RAM;
+ dc->alias = "virtio-balloon";
+ dc->reset = virtio_pci_reset;
+ dc->props = virtio_balloon_properties;
}
-static DeviceInfo virtio_balloon_info = {
- .name = "virtio-balloon-pci",
- .alias = "virtio-balloon",
- .size = sizeof(VirtIOPCIProxy),
- .props = virtio_balloon_properties,
- .reset = virtio_pci_reset,
- .class_init = virtio_balloon_class_init,
+static TypeInfo virtio_balloon_info = {
+ .name = "virtio-balloon-pci",
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(VirtIOPCIProxy),
+ .class_init = virtio_balloon_class_init,
};
static void virtio_pci_register_devices(void)
{
- pci_qdev_register(&virtio_blk_info);
- pci_qdev_register(&virtio_net_info);
- pci_qdev_register(&virtio_serial_info);
- pci_qdev_register(&virtio_balloon_info);
+ type_register_static(&virtio_blk_info);
+ type_register_static_alias(&virtio_blk_info, "virtio-blk");
+ type_register_static(&virtio_net_info);
+ type_register_static_alias(&virtio_net_info, "virtio-net");
+ type_register_static(&virtio_serial_info);
+ type_register_static_alias(&virtio_serial_info, "virtio-serial");
+ type_register_static(&virtio_balloon_info);
+ type_register_static_alias(&virtio_balloon_info, "virtio-balloon");
}
device_init(virtio_pci_register_devices)