Virtio-balloon qdev conversion
authorPaul Brook <paul@codesourcery.com>
Thu, 14 May 2009 21:35:08 +0000 (22:35 +0100)
committerPaul Brook <paul@codesourcery.com>
Thu, 14 May 2009 21:35:08 +0000 (22:35 +0100)
Signed-off-by: Paul Brook <paul@codesourcery.com>
hw/pc.c
hw/virtio-balloon.c
hw/virtio-balloon.h

diff --git a/hw/pc.c b/hw/pc.c
index 12065baf6c81b9e295db4f3aebea87eb89b897b2..6c8bb1bbd6e13d36b12b2d83567112b59c7cd78e 100644 (file)
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -33,7 +33,6 @@
 #include "boards.h"
 #include "monitor.h"
 #include "fw_cfg.h"
-#include "virtio-balloon.h"
 #include "virtio-console.h"
 #include "hpet_emul.h"
 #include "watchdog.h"
@@ -1141,8 +1140,9 @@ static void pc_init1(ram_addr_t ram_size,
     }
 
     /* Add virtio balloon device */
-    if (pci_enabled)
-        virtio_balloon_init(pci_bus);
+    if (pci_enabled) {
+        pci_create_simple(pci_bus, -1, "virtio-balloon");
+    }
 
     /* Add virtio console devices */
     if (pci_enabled) {
index b8f9184e110288e0cc3b0a13180f3fe205cf54d0..7fa7e47f7ffdbd7b9ec97328e2e5335a8032a411 100644 (file)
@@ -169,17 +169,11 @@ static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-void *virtio_balloon_init(PCIBus *bus)
+static void virtio_balloon_init(PCIDevice *pci_dev)
 {
     VirtIOBalloon *s;
-    PCIDevice *d;
 
-    d = pci_register_device(bus, "virtio-balloon", sizeof(VirtIOBalloon),
-                            -1, NULL, NULL);
-    if (!d)
-        return NULL;
-
-    s = (VirtIOBalloon *)virtio_init_pci(d, "virtio-balloon",
+    s = (VirtIOBalloon *)virtio_init_pci(pci_dev, "virtio-balloon",
                                          PCI_VENDOR_ID_REDHAT_QUMRANET,
                                          PCI_DEVICE_ID_VIRTIO_BALLOON,
                                          PCI_VENDOR_ID_REDHAT_QUMRANET,
@@ -197,6 +191,12 @@ void *virtio_balloon_init(PCIBus *bus)
     qemu_add_balloon_handler(virtio_balloon_to_target, s);
 
     register_savevm("virtio-balloon", -1, 1, virtio_balloon_save, virtio_balloon_load, s);
+}
 
-    return &s->vdev;
+static void virtio_balloon_register_devices(void)
+{
+    pci_qdev_register("virtio-balloon", sizeof(VirtIOBalloon),
+                      virtio_balloon_init);
 }
+
+device_init(virtio_balloon_register_devices)
index c71f9709bfe9446c276add2bd8e596cda858eba6..9a0d119e4243bce1e1515c7eb08812ba1354097a 100644 (file)
@@ -37,6 +37,4 @@ struct virtio_balloon_config
     uint32_t actual;
 };
 
-void *virtio_balloon_init(PCIBus *bus);
-
 #endif