From d176c495b6664b72dc1e595f6e89dc5648aa248b Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 31 Jul 2009 12:25:41 +0200 Subject: qdev-ify virtio-blk. First user of the new drive property. With this patch applied host and guest config can be specified separately, like this: -drive if=none,id=disk1,file=/path/to/disk.img -device virtio-blk-pci,drive=disk1 You can set any property for virtio-blk-pci now. You can set the pci address via addr=. You can switch the device into 0.10 compat mode using class=0x0180. As this is per device you can have one 0.10 and one 0.11 virtio block device in a single virtual machine. Old syntax continues to work. Internally it does the same as the two lines above though. One side effect this has is a different initialization order, which might result in a different pci address being assigned by default. Long term plan here is to have this working for all block devices, i.e. once all scsi is properly qdev-ified you will be able to do something like this: -drive if=none,id=sda,file=/path/to/disk.img -device lsi,id=lsi,addr= -device scsi-disk,drive=sda,bus=lsi.0,lun= Signed-off-by: Gerd Hoffmann Signed-off-by: Anthony Liguori Message-Id: --- hw/virtio-pci.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'hw/virtio-pci.c') diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 703f4fe53..8cf4b57a3 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -17,7 +17,7 @@ #include "virtio.h" #include "pci.h" -//#include "sysemu.h" +#include "sysemu.h" #include "msix.h" #include "net.h" @@ -89,6 +89,7 @@ typedef struct { uint32_t addr; uint32_t class_code; uint32_t nvectors; + DriveInfo *dinfo; } VirtIOPCIProxy; /* virtio device */ @@ -432,7 +433,10 @@ static void virtio_blk_init_pci(PCIDevice *pci_dev) proxy->class_code != PCI_CLASS_STORAGE_OTHER) proxy->class_code = PCI_CLASS_STORAGE_SCSI; - vdev = virtio_blk_init(&pci_dev->qdev); + if (!proxy->dinfo) { + fprintf(stderr, "drive property not set\n"); + } + vdev = virtio_blk_init(&pci_dev->qdev, proxy->dinfo); virtio_init_pci(proxy, vdev, PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_BLOCK, @@ -502,6 +506,10 @@ static PCIDeviceInfo virtio_info[] = { .name = "class", .info = &qdev_prop_hex32, .offset = offsetof(VirtIOPCIProxy, class_code), + },{ + .name = "drive", + .info = &qdev_prop_drive, + .offset = offsetof(VirtIOPCIProxy, dinfo), }, {/* end of list */} }, -- cgit v1.2.3