mirror of https://gitee.com/openkylin/qemu.git
Virtio-blk qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
parent
b4496b13bb
commit
07e3af9ac3
3
hw/pc.c
3
hw/pc.c
|
@ -33,7 +33,6 @@
|
|||
#include "boards.h"
|
||||
#include "monitor.h"
|
||||
#include "fw_cfg.h"
|
||||
#include "virtio-blk.h"
|
||||
#include "virtio-balloon.h"
|
||||
#include "virtio-console.h"
|
||||
#include "hpet_emul.h"
|
||||
|
@ -1136,7 +1135,7 @@ static void pc_init1(ram_addr_t ram_size,
|
|||
int unit_id = 0;
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,8 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus,
|
|||
opaque = pci_create_simple(pci_bus, -1, "lsi53c895a");
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "net.h"
|
||||
#include "hw.h"
|
||||
#include "pci.h"
|
||||
#include "virtio-blk.h"
|
||||
#include "virtio-console.h"
|
||||
#include "boards.h"
|
||||
#include "sysemu.h"
|
||||
|
@ -113,7 +112,7 @@ static void bamboo_init(ram_addr_t ram_size,
|
|||
|
||||
/* Add virtio block devices. */
|
||||
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++;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "hw.h"
|
||||
#include "pc.h"
|
||||
#include "pci.h"
|
||||
#include "virtio-blk.h"
|
||||
#include "boards.h"
|
||||
#include "sysemu.h"
|
||||
#include "kvm.h"
|
||||
|
@ -221,7 +220,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
|
|||
|
||||
/* Add virtio block devices. */
|
||||
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++;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
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_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)
|
||||
|
|
|
@ -82,6 +82,4 @@ struct virtio_scsi_inhdr
|
|||
uint32_t residual;
|
||||
};
|
||||
|
||||
void *virtio_blk_init(PCIBus *bus, BlockDriverState *bs);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue