[RFC PATCH] Use disable-modern=on for disk device='lun'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.redhat.com/show_bug.cgi?id=1365823

For virtio-blk, scsi=on has been deprecated in virtio-1,
so <disk type='block' device='lun'> no longer works with
with a virtio-blk-pci device with machine types newer than 2.7:
https://bugzilla.redhat.com/show_bug.cgi?id=1245453
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=9a4c0e22

Add disable-modern=on on the QEMU command line to prolong
the suffering for a while longer.
---
The alternative would be using the QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY
capability to report an error, instead of waiting until QEMU fails with
an error, since it's the first commit when the following error should
be reachable via libvirt-generated command line:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=efb8206c

 src/qemu/qemu_command.c                            | 12 +++++
 .../qemuxml2argv-virtio-lun-legacy.args            | 30 +++++++++++++
 .../qemuxml2argv-virtio-lun-legacy.xml             | 52 ++++++++++++++++++++++
 tests/qemuxml2argvtest.c                           |  3 ++
 4 files changed, 97 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-lun-legacy.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-lun-legacy.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 051a0bc..03dc20e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2075,6 +2075,18 @@ qemuBuildDriveDevStr(const virDomainDef *def,
             virBufferAddLit(&opt, "virtio-blk-pci");
             if (disk->iothread)
                 virBufferAsprintf(&opt, ",iothread=iothread%u", disk->iothread);
+
+            /*
+             * SCSI command passthrough was deprecated in virtio 1.0,
+             * see https://bugzilla.redhat.com/show_bug.cgi?id=1365823
+             */
+            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_SCSI) &&
+                disk->device == VIR_DOMAIN_DISK_DEVICE_LUN &&
+                virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) {
+                VIR_WARN("lun type devices are deprecated for virtio-blk-pci devices, "
+                         "consider using disks on a virtio-scsi controller");
+                virBufferAddLit(&opt, ",disable-modern=on");
+            }
         }
         qemuBuildIoEventFdStr(&opt, disk->ioeventfd, qemuCaps);
         if (disk->event_idx &&
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-lun-legacy.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-lun-legacy.args
new file mode 100644
index 0000000..d1ff31c
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-lun-legacy.args
@@ -0,0 +1,30 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name test \
+-S \
+-M pc-0.13 \
+-m 1024 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid bba65c0e-c049-934f-b6aa-4e2c0582acdf \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-test/monitor.sock,server,nowait \
+-no-acpi \
+-boot dc \
+-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 \
+-device virtio-blk-pci,disable-modern=on,scsi=on,bus=pci.0,addr=0x4,\
+drive=drive-virtio-disk0,id=virtio-disk0 \
+-drive file=/dev/sdfake2,format=qcow2,if=none,id=drive-virtio-disk1 \
+-device virtio-blk-pci,disable-modern=on,scsi=on,bus=pci.0,addr=0x5,\
+drive=drive-virtio-disk1,id=virtio-disk1 \
+-device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:e5:48:58,bus=pci.0,addr=0x3 \
+-net user,vlan=0,name=hostnet0 \
+-serial pty \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-lun-legacy.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-lun-legacy.xml
new file mode 100644
index 0000000..63dbfda
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-lun-legacy.xml
@@ -0,0 +1,52 @@
+<domain type='qemu'>
+  <name>test</name>
+  <uuid>bba65c0e-c049-934f-b6aa-4e2c0582acdf</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <currentMemory unit='KiB'>1048576</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc-0.13'>hvm</type>
+    <boot dev='cdrom'/>
+    <boot dev='hd'/>
+    <bootmenu enable='yes'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='lun' rawio='yes'>
+      <driver name='qemu' type='qcow2'/>
+      <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'/>
+      <source dev='/dev/sdfake2'/>
+      <target dev='vdb' bus='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='virtio-serial' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+    </controller>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <interface type='user'>
+      <mac address='52:54:00:e5:48:58'/>
+      <model type='virtio'/>
+      <driver name='vhost' event_idx='off'/>
+    </interface>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+    </console>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e854077..afe3073 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -931,6 +931,9 @@ mymain(void)
             QEMU_CAPS_VIRTIO_BLK_SCSI);
     DO_TEST("virtio-lun",
             QEMU_CAPS_VIRTIO_BLK_SCSI);
+    DO_TEST("virtio-lun-legacy",
+            QEMU_CAPS_VIRTIO_BLK_SCSI,
+            QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY);
     DO_TEST("disk-scsi-lun-passthrough",
             QEMU_CAPS_SCSI_BLOCK,
             QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI);
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]