From 7bc7304ca5ae7de2c68e5b40fa5f2aced1cbb3eb Mon Sep 17 00:00:00 2001 From: shenjiatong Date: Sat, 22 Jan 2022 12:10:35 +0800 Subject: [PATCH] qemu: Remove scsi parameter for vhost-user-blk for qemu < 4.2 When trying to attach vhost-user-blk device to virtual machine using qemu < 4.2 libvirt would mistakenly add a scsi=off parameter, which is not supported by qemu. Fixes: https://gitlab.com/libvirt/libvirt/-/issues/265 Signed-off-by: shenjiatong Signed-off-by: Peter Krempa Reviewed-by: Peter Krempa --- src/qemu/qemu_command.c | 3 ++- tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 662d15e28e..52ea148a0f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2234,7 +2234,8 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, if (disk->iothread > 0) iothread = g_strdup_printf("iothread%u", disk->iothread); - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_SCSI)) { + if (virStorageSourceGetActualType(disk->src) != VIR_STORAGE_TYPE_VHOST_USER && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_SCSI)) { /* if sg_io is true but the scsi option isn't supported, * that means it's just always on in this version of qemu. */ diff --git a/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args b/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args index 6c5d6de46b..4480266e75 100644 --- a/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args +++ b/tests/qemuxml2argvdata/disk-vhostuser-numa.x86_64-4.2.0.args @@ -30,9 +30,9 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -boot strict=on \ -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ -chardev socket,id=chr-vu-virtio-disk0,path=/tmp/vhost1.sock \ --device vhost-user-blk-pci,scsi=off,bus=pci.0,addr=0x2,chardev=chr-vu-virtio-disk0,id=virtio-disk0,bootindex=1 \ +-device vhost-user-blk-pci,bus=pci.0,addr=0x2,chardev=chr-vu-virtio-disk0,id=virtio-disk0,bootindex=1 \ -chardev socket,id=chr-vu-virtio-disk1,path=/tmp/vhost1.sock,reconnect=10 \ --device vhost-user-blk-pci,iommu_platform=on,ats=on,packed=on,scsi=off,bus=pci.0,addr=0x3,chardev=chr-vu-virtio-disk1,id=virtio-disk1 \ +-device vhost-user-blk-pci,iommu_platform=on,ats=on,packed=on,bus=pci.0,addr=0x3,chardev=chr-vu-virtio-disk1,id=virtio-disk1 \ -audiodev '{"id":"audio1","driver":"none"}' \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \