]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Forbid non-raw images for disk type='lun' with vitio-blk frontend
authorPeter Krempa <pkrempa@redhat.com>
Thu, 7 May 2020 08:53:51 +0000 (10:53 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 May 2020 04:55:00 +0000 (06:55 +0200)
Historically the virtio-blk frontend by default enabled SCSI emulation
and tried to do SCSI command passthrough. As this was enabled by default
there's a fallback mechanism in place in cases when the backend doesn't
support SCSI for any reason.

This is not the case when disk type=lun is used with 'scsi-block' via
'virtio-scsi'.

We did not restrict configurations when the user picks 'qcow2' or any
other format as format of the disk, in which case the emulation is
disabled as such configuration doesn't make sense.

This patch unifies the approach so that 'raw' is required both when used
via 'virtio-blk' and 'virtio-scsi' so that the user is presented with
the expected configuration. Note that use of <disk type='lun'> is
already very restrictive as it requires a block device or iSCSI storage.

Additionally the scsi emulation is now deprecated by qemu with
virtio-blk as it conflicts with virtio-1 and the alternative is to use
'virtio-scsi' which performs better and is along for a very long time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_validate.c
tests/qemuxml2argvdata/virtio-lun.args
tests/qemuxml2argvdata/virtio-lun.xml
tests/qemuxml2xmloutdata/virtio-lun.xml

index b6806f017bfaf5361601a434afaea37a5e4065bd..4205c42a56677d0387851edda585aa3e7ec236ef 100644 (file)
@@ -10481,6 +10481,12 @@ qemuDomainDefValidateDiskLunSource(const virStorageSource *src)
         return -1;
     }
 
+    if (src->format != VIR_STORAGE_FILE_RAW) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("disk device 'lun' must use 'raw' format"));
+        return -1;
+    }
+
     return 0;
 }
 
index 2cde678ca0631f514b9915b83d87bc57828faff1..f789ed075ad7b068fced3b2e12b37c4dfb4ed0f5 100644 (file)
@@ -1997,14 +1997,6 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
             return -1;
         }
 
-        if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI &&
-            disk->src->format != VIR_STORAGE_FILE_RAW) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("disk device 'lun' using target 'scsi' must use "
-                             "'raw' format"));
-            return -1;
-        }
-
         if (qemuDomainDefValidateDiskLunSource(disk->src) < 0)
             return -1;
 
index 7df1512b9b7e2862b7ce482a824c3e5fdb60b5a0..850501142a3c50d1b5f8c22f0dfe54ae227cf389 100644 (file)
@@ -27,10 +27,10 @@ server,nowait \
 -boot menu=on \
 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 \
 -usb \
--drive file=/dev/sdfake,format=qcow2,if=none,id=drive-virtio-disk0 \
+-drive file=/dev/sdfake,format=raw,if=none,id=drive-virtio-disk0 \
 -device virtio-blk-pci,scsi=on,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\
 id=virtio-disk0,bootindex=2 \
--drive file=/dev/sdfake2,format=qcow2,if=none,id=drive-virtio-disk1 \
+-drive file=/dev/sdfake2,format=raw,if=none,id=drive-virtio-disk1 \
 -device virtio-blk-pci,scsi=on,bus=pci.0,addr=0x5,drive=drive-virtio-disk1,\
 id=virtio-disk1 \
 -netdev user,id=hostnet0 \
index 303131fb619205398cf6a902285311af6923fe79..c802da1838301a4aa71041f4c404e429ca9d0697 100644 (file)
   <devices>
     <emulator>/usr/bin/qemu-system-x86_64</emulator>
     <disk type='block' device='lun' rawio='yes'>
-      <driver name='qemu' type='qcow2'/>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/sdfake'/>
       <target dev='vda' bus='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
     </disk>
     <disk type='block' device='lun'>
-      <driver name='qemu' type='qcow2'/>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/sdfake2'/>
       <target dev='vdb' bus='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
index dbedd4edc09f98f2014947408d0606f99430b0d9..23052cd519f8c41738da46afa59ce0959777cdb2 100644 (file)
   <devices>
     <emulator>/usr/bin/qemu-system-x86_64</emulator>
     <disk type='block' device='lun' rawio='yes'>
-      <driver name='qemu' type='qcow2'/>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/sdfake'/>
       <target dev='vda' bus='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
     </disk>
     <disk type='block' device='lun'>
-      <driver name='qemu' type='qcow2'/>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/sdfake2'/>
       <target dev='vdb' bus='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>