提交 07e3af9a 编写于 作者: P Paul Brook

Virtio-blk qdev conversion

Signed-off-by: NPaul Brook <paul@codesourcery.com>
上级 b4496b13
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "boards.h" #include "boards.h"
#include "monitor.h" #include "monitor.h"
#include "fw_cfg.h" #include "fw_cfg.h"
#include "virtio-blk.h"
#include "virtio-balloon.h" #include "virtio-balloon.h"
#include "virtio-console.h" #include "virtio-console.h"
#include "hpet_emul.h" #include "hpet_emul.h"
...@@ -1136,7 +1135,7 @@ static void pc_init1(ram_addr_t ram_size, ...@@ -1136,7 +1135,7 @@ static void pc_init1(ram_addr_t ram_size,
int unit_id = 0; int unit_id = 0;
while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) { while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
virtio_blk_init(pci_bus, drives_table[index].bdrv); pci_create_simple(pci_bus, -1, "virtio-blk");
unit_id++; unit_id++;
} }
} }
......
...@@ -120,7 +120,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus, ...@@ -120,7 +120,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus,
opaque = pci_create_simple(pci_bus, -1, "lsi53c895a"); opaque = pci_create_simple(pci_bus, -1, "lsi53c895a");
break; break;
case IF_VIRTIO: case IF_VIRTIO:
opaque = virtio_blk_init (pci_bus, drives_table[drive_idx].bdrv); opaque = pci_create_simple(pci_bus, -1, "virtio-blk");
qdev_init(opaque);
break; break;
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "net.h" #include "net.h"
#include "hw.h" #include "hw.h"
#include "pci.h" #include "pci.h"
#include "virtio-blk.h"
#include "virtio-console.h" #include "virtio-console.h"
#include "boards.h" #include "boards.h"
#include "sysemu.h" #include "sysemu.h"
...@@ -113,7 +112,7 @@ static void bamboo_init(ram_addr_t ram_size, ...@@ -113,7 +112,7 @@ static void bamboo_init(ram_addr_t ram_size,
/* Add virtio block devices. */ /* Add virtio block devices. */
while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) { while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
virtio_blk_init(pcibus, drives_table[i].bdrv); pci_create_simple(pcibus, -1, "virtio-blk");
unit_id++; unit_id++;
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "hw.h" #include "hw.h"
#include "pc.h" #include "pc.h"
#include "pci.h" #include "pci.h"
#include "virtio-blk.h"
#include "boards.h" #include "boards.h"
#include "sysemu.h" #include "sysemu.h"
#include "kvm.h" #include "kvm.h"
...@@ -221,7 +220,7 @@ static void mpc8544ds_init(ram_addr_t ram_size, ...@@ -221,7 +220,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
/* Add virtio block devices. */ /* Add virtio block devices. */
while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) { while ((i = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) {
virtio_blk_init(pci_bus, drives_table[i].bdrv); pci_create_simple(pci_bus, -1, "virtio-blk");
unit_id++; unit_id++;
} }
......
...@@ -348,19 +348,14 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) ...@@ -348,19 +348,14 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
return 0; return 0;
} }
void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs) static void virtio_blk_init(PCIDevice *pci_dev)
{ {
VirtIOBlock *s; VirtIOBlock *s;
int cylinders, heads, secs; int cylinders, heads, secs;
static int virtio_blk_id; static int virtio_blk_id;
PCIDevice *d; BlockDriverState *bs;
d = pci_register_device(bus, "virtio-blk", sizeof(VirtIOBlock),
-1, NULL, NULL);
if (!d)
return NULL;
s = (VirtIOBlock *)virtio_init_pci(d, "virtio-blk", s = (VirtIOBlock *)virtio_init_pci(pci_dev, "virtio-blk",
PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_BLOCK, PCI_DEVICE_ID_VIRTIO_BLOCK,
PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_VENDOR_ID_REDHAT_QUMRANET,
...@@ -368,6 +363,7 @@ void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs) ...@@ -368,6 +363,7 @@ void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs)
PCI_CLASS_STORAGE_OTHER, 0x00, PCI_CLASS_STORAGE_OTHER, 0x00,
sizeof(struct virtio_blk_config)); 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_config = virtio_blk_update_config;
s->vdev.get_features = virtio_blk_get_features; s->vdev.get_features = virtio_blk_get_features;
s->vdev.reset = virtio_blk_reset; s->vdev.reset = virtio_blk_reset;
...@@ -382,6 +378,11 @@ void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs) ...@@ -382,6 +378,11 @@ void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs)
qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s);
register_savevm("virtio-blk", virtio_blk_id++, 2, register_savevm("virtio-blk", virtio_blk_id++, 2,
virtio_blk_save, virtio_blk_load, s); 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)
...@@ -82,6 +82,4 @@ struct virtio_scsi_inhdr ...@@ -82,6 +82,4 @@ struct virtio_scsi_inhdr
uint32_t residual; uint32_t residual;
}; };
void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册