Commit 2d72c5727f8343a39862b8fca3b53a2bce26a7ca

Authored by Paul Brook
1 parent 07e3af9a

Virtio-balloon qdev conversion

Signed-off-by: Paul Brook <paul@codesourcery.com>
... ... @@ -33,7 +33,6 @@
33 33 #include "boards.h"
34 34 #include "monitor.h"
35 35 #include "fw_cfg.h"
36   -#include "virtio-balloon.h"
37 36 #include "virtio-console.h"
38 37 #include "hpet_emul.h"
39 38 #include "watchdog.h"
... ... @@ -1141,8 +1140,9 @@ static void pc_init1(ram_addr_t ram_size,
1141 1140 }
1142 1141  
1143 1142 /* Add virtio balloon device */
1144   - if (pci_enabled)
1145   - virtio_balloon_init(pci_bus);
  1143 + if (pci_enabled) {
  1144 + pci_create_simple(pci_bus, -1, "virtio-balloon");
  1145 + }
1146 1146  
1147 1147 /* Add virtio console devices */
1148 1148 if (pci_enabled) {
... ...
hw/virtio-balloon.c
... ... @@ -169,17 +169,11 @@ static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
169 169 return 0;
170 170 }
171 171  
172   -void *virtio_balloon_init(PCIBus *bus)
  172 +static void virtio_balloon_init(PCIDevice *pci_dev)
173 173 {
174 174 VirtIOBalloon *s;
175   - PCIDevice *d;
176 175  
177   - d = pci_register_device(bus, "virtio-balloon", sizeof(VirtIOBalloon),
178   - -1, NULL, NULL);
179   - if (!d)
180   - return NULL;
181   -
182   - s = (VirtIOBalloon *)virtio_init_pci(d, "virtio-balloon",
  176 + s = (VirtIOBalloon *)virtio_init_pci(pci_dev, "virtio-balloon",
183 177 PCI_VENDOR_ID_REDHAT_QUMRANET,
184 178 PCI_DEVICE_ID_VIRTIO_BALLOON,
185 179 PCI_VENDOR_ID_REDHAT_QUMRANET,
... ... @@ -197,6 +191,12 @@ void *virtio_balloon_init(PCIBus *bus)
197 191 qemu_add_balloon_handler(virtio_balloon_to_target, s);
198 192  
199 193 register_savevm("virtio-balloon", -1, 1, virtio_balloon_save, virtio_balloon_load, s);
  194 +}
200 195  
201   - return &s->vdev;
  196 +static void virtio_balloon_register_devices(void)
  197 +{
  198 + pci_qdev_register("virtio-balloon", sizeof(VirtIOBalloon),
  199 + virtio_balloon_init);
202 200 }
  201 +
  202 +device_init(virtio_balloon_register_devices)
... ...
hw/virtio-balloon.h
... ... @@ -37,6 +37,4 @@ struct virtio_balloon_config
37 37 uint32_t actual;
38 38 };
39 39  
40   -void *virtio_balloon_init(PCIBus *bus);
41   -
42 40 #endif
... ...