diff options
author | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:08 +0100 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:08 +0100 |
commit | 07e3af9ac31008a1d7eaaf44d62a13545f01c579 (patch) | |
tree | 743195c13b89452175bcd145c378b613a8330d8a /hw/virtio-blk.c | |
parent | b4496b13bb51884681656c3470ba778c7e888c2b (diff) |
Virtio-blk qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/virtio-blk.c')
-rw-r--r-- | hw/virtio-blk.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index b80302b689..ef091131b8 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -348,19 +348,14 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) return 0; } -void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs) +static void virtio_blk_init(PCIDevice *pci_dev) { VirtIOBlock *s; int cylinders, heads, secs; static int virtio_blk_id; - PCIDevice *d; - - d = pci_register_device(bus, "virtio-blk", sizeof(VirtIOBlock), - -1, NULL, NULL); - if (!d) - return NULL; + BlockDriverState *bs; - s = (VirtIOBlock *)virtio_init_pci(d, "virtio-blk", + s = (VirtIOBlock *)virtio_init_pci(pci_dev, "virtio-blk", PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_BLOCK, PCI_VENDOR_ID_REDHAT_QUMRANET, @@ -368,6 +363,7 @@ void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs) PCI_CLASS_STORAGE_OTHER, 0x00, sizeof(struct virtio_blk_config)); + bs = qdev_init_bdrv(&pci_dev->qdev, IF_VIRTIO); s->vdev.get_config = virtio_blk_update_config; s->vdev.get_features = virtio_blk_get_features; s->vdev.reset = virtio_blk_reset; @@ -382,6 +378,11 @@ void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs) qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); register_savevm("virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); +} - return s; +static void virtio_blk_register_devices(void) +{ + pci_qdev_register("virtio-blk", sizeof(VirtIOBlock), virtio_blk_init); } + +device_init(virtio_blk_register_devices) |