From 162bcd046eee91f30e63a46678cbb36d29eb9de8 Mon Sep 17 00:00:00 2001 From: Xiao Wang Date: Mon, 10 Aug 2015 05:09:31 +0200 Subject: [PATCH 10/16] virtio-blk: fail get_features when both scsi and 1.0 were set Message-id: <1439183375-4841-11-git-send-email-jasowang@redhat.com> Patchwork-id: 67437 O-Subject: [RHEL7.2 qemu-kvm-rhev PATCH 10/14] virtio-blk: fail get_features when both scsi and 1.0 were set Bugzilla: 1248312 RH-Acked-by: Vlad Yasevich RH-Acked-by: Paolo Bonzini RH-Acked-by: Michael S. Tsirkin SCSI passthrough was no longer supported in virtio 1.0, so this patch fail the get_features() when both 1.0 and scsi is set. And also only advertise VIRTIO_BLK_F_SCSI for legacy virtio-blk device. Signed-off-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Paolo Bonzini (cherry picked from commit efb8206ca7f19f5a6ece1f2851a73a29de309b1e) Signed-off-by: Miroslav Rezanina --- hw/block/virtio-blk.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 0e13530..5f9297a 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -727,8 +727,16 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features, virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY); virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY); virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE); - virtio_add_feature(&features, VIRTIO_BLK_F_SCSI); virtio_clear_feature(&features, VIRTIO_F_ANY_LAYOUT); + if (__virtio_has_feature(features, VIRTIO_F_VERSION_1)) { + if (s->conf.scsi) { + error_setg(errp, "Please set scsi=off for virtio-blk devices in order to use virtio 1.0"); + return 0; + } + virtio_add_feature(&features, VIRTIO_F_ANY_LAYOUT); + } else { + virtio_add_feature(&features, VIRTIO_BLK_F_SCSI); + } if (s->conf.config_wce) { virtio_add_feature(&features, VIRTIO_BLK_F_CONFIG_WCE); -- 1.8.3.1