diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-07-31 12:25:41 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-08-10 13:05:28 -0500 |
commit | d176c495b6664b72dc1e595f6e89dc5648aa248b (patch) | |
tree | 8007516b5e4a7bc56cd806e92b0be7028ce643bb /hw/virtio-blk.c | |
parent | 14b41872fd4ccdb750d539f1f317ae0e070f73a4 (diff) |
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=<pciaddr>
-device scsi-disk,drive=sda,bus=lsi.0,lun=<n>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Message-Id:
Diffstat (limited to 'hw/virtio-blk.c')
-rw-r--r-- | hw/virtio-blk.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 5036b5b024..c278d2ef0a 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -414,29 +414,27 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) return 0; } -VirtIODevice *virtio_blk_init(DeviceState *dev) +VirtIODevice *virtio_blk_init(DeviceState *dev, DriveInfo *dinfo) { VirtIOBlock *s; int cylinders, heads, secs; static int virtio_blk_id; - BlockDriverState *bs; char *ps; s = (VirtIOBlock *)virtio_common_init("virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config), sizeof(VirtIOBlock)); - bs = qdev_init_bdrv(dev, IF_VIRTIO); s->vdev.get_config = virtio_blk_update_config; s->vdev.get_features = virtio_blk_get_features; s->vdev.reset = virtio_blk_reset; - s->bs = bs; + s->bs = dinfo->bdrv; s->rq = NULL; - if (strlen(ps = (char *)drive_get_serial(bs))) + if (strlen(ps = (char *)drive_get_serial(s->bs))) strncpy(s->serial_str, ps, sizeof(s->serial_str)); else snprintf(s->serial_str, sizeof(s->serial_str), "0"); - bs->private = dev; + s->bs->private = dev; bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); bdrv_set_geometry_hint(s->bs, cylinders, heads, secs); |