From a6c5c84ae25bc68f22725f77d6d77c98af5c4f9e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 16 May 2012 12:54:06 +0200 Subject: virtio-blk: always enable VIRTIO_BLK_F_SCSI VIRTIO_BLK_F_SCSI is supposed to mean whether the host can *parse* SCSI requests, not *execute* them. You could run QEMU with scsi=on and a file-backed disk, and QEMU would fail all SCSI requests even though it advertises VIRTIO_BLK_F_SCSI. Because we need to do this to fix a migration compatibility problem related to how QEMU is invoked by management, we must do this unconditionally even on older machine types. This more or less assumes that no one ever invoked QEMU with scsi=off. Here is how testing goes: - old QEMU, scsi=on -> new QEMU, scsi=on - new QEMU, scsi=on -> old QEMU, scsi=on - old QEMU, scsi=off -> new QEMU, scsi=on - new QEMU, scsi=off -> old QEMU, scsi=on ok (new QEMU has VIRTIO_BLK_F_SCSI, adding host features is fine) - old QEMU, scsi=off -> new QEMU, scsi=off ok (new QEMU has VIRTIO_BLK_F_SCSI, adding host features is fine) - old QEMU, scsi=on -> new QEMU, scsi=off ok, bug fixed - new QEMU, scsi=on -> old QEMU, scsi=off doesn't work (same as: old QEMU, scsi=on -> old QEMU, scsi=off) - new QEMU, scsi=off -> old QEMU, scsi=off broken by the patch Signed-off-by: Paolo Bonzini Signed-off-by: Anthony Liguori --- hw/virtio-blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'hw/virtio-blk.c') diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 960b9cf..9f605d3 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -170,7 +170,7 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req) */ req->scsi = (void *)req->elem.in_sg[req->elem.in_num - 2].iov_base; - if ((req->dev->vdev.guest_features & (1 << VIRTIO_BLK_F_SCSI)) == 0) { + if (!req->dev->blk->scsi) { status = VIRTIO_BLK_S_UNSUPP; goto fail; } @@ -504,6 +504,7 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features) features |= (1 << VIRTIO_BLK_F_GEOMETRY); features |= (1 << VIRTIO_BLK_F_TOPOLOGY); features |= (1 << VIRTIO_BLK_F_BLK_SIZE); + features |= (1 << VIRTIO_BLK_F_SCSI); if (bdrv_enable_write_cache(s->bs)) features |= (1 << VIRTIO_BLK_F_WCACHE); -- cgit v1.1