File 0c67a11a-qemu-support-bootindex-vfioccw-mdev-devices.patch of Package libvirt.14190

commit 0c67a11a4a30c85feae4d8671834941bdd78e896
Author: Boris Fiuczynski <fiuczy@linux.ibm.com>
Date:   Tue Aug 27 16:19:23 2019 +0200

    qemu: support bootindex on vfio-ccw mdev devices
    
    Add support to specify a boot order on vfio-ccw passthrough devices.
    
    Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
    Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
    Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
    Reviewed-by: Ján Tomko <jtomko@redhat.com>
    Signed-off-by: Ján Tomko <jtomko@redhat.com>

Index: libvirt-5.1.0/src/qemu/qemu_command.c
===================================================================
--- libvirt-5.1.0.orig/src/qemu/qemu_command.c
+++ libvirt-5.1.0/src/qemu/qemu_command.c
@@ -5489,6 +5489,7 @@ qemuBuildChrChardevStr(virLogManagerPtr
     return ret;
 }
 
+
 char *
 qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
                                virDomainHostdevDefPtr dev,
@@ -5518,6 +5519,9 @@ qemuBuildHostdevMediatedDevStr(const vir
     if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
         goto cleanup;
 
+    if (dev->info->bootIndex)
+        virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex);
+
     if (virBufferCheckError(&buf) < 0)
         goto cleanup;
 
Index: libvirt-5.1.0/src/qemu/qemu_domain.c
===================================================================
--- libvirt-5.1.0.orig/src/qemu/qemu_domain.c
+++ libvirt-5.1.0/src/qemu/qemu_domain.c
@@ -4719,6 +4719,15 @@ qemuDomainMdevDefVFIOPCIValidate(const v
 {
     const virDomainHostdevSubsysMediatedDev *dev;
 
+    /* VFIO-PCI does not support boot */
+    if (hostdev->info->bootIndex) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("booting from assigned devices is not "
+                         "supported by mediated devices of "
+                         "model vfio-pci"));
+        return -1;
+    }
+
     dev = &hostdev->source.subsys.u.mdev;
     if (dev->display == VIR_TRISTATE_SWITCH_ABSENT)
         return 0;
@@ -4752,12 +4761,21 @@ qemuDomainMdevDefVFIOPCIValidate(const v
 
 
 static int
-qemuDomainMdevDefVFIOAPValidate(const virDomainHostdevDef *hostdev ATTRIBUTE_UNUSED,
+qemuDomainMdevDefVFIOAPValidate(const virDomainHostdevDef *hostdev,
                                 const virDomainDef *def)
 {
     size_t i;
     bool vfioap_found = false;
 
+    /* VFIO-AP does not support boot */
+    if (hostdev->info->bootIndex) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("booting from assigned devices is not "
+                         "supported by mediated devices of "
+                         "model vfio-ap"));
+        return -1;
+    }
+
     /* VFIO-AP is restricted to a single mediated device only */
     for (i = 0; i < def->nhostdevs; i++) {
         virDomainHostdevDefPtr hdev = def->hostdevs[i];
@@ -4833,12 +4851,6 @@ qemuDomainDeviceDefValidateHostdev(const
             }
             break;
         case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
-            if (hostdev->info->bootIndex) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("booting from assigned devices is not "
-                                 "supported by mediated devices"));
-                return -1;
-            }
             return qemuDomainMdevDefValidate(hostdev, def, qemuCaps);
         case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
         default:
Index: libvirt-5.1.0/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-boot.s390x-latest.args
===================================================================
--- /dev/null
+++ libvirt-5.1.0/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-boot.s390x-latest.args
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
+-m 512 \
+-realtime mlock=off \
+-smp 2,sockets=2,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device vfio-ccw,id=hostdev0,\
+sysfsdev=/sys/bus/mdev/devices/90c6c135-ad44-41d0-b1b7-bae47de48627,\
+devno=fe.0.0000,bootindex=1 \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-msg timestamp=on
Index: libvirt-5.1.0/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-boot.xml
===================================================================
--- /dev/null
+++ libvirt-5.1.0/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-boot.xml
@@ -0,0 +1,23 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>2</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <hostdev mode='subsystem' type='mdev' model='vfio-ccw'>
+      <source>
+        <address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
+      </source>
+      <boot order='1'/>
+    </hostdev>
+  </devices>
+</domain>
Index: libvirt-5.1.0/tests/qemuxml2argvtest.c
===================================================================
--- libvirt-5.1.0.orig/tests/qemuxml2argvtest.c
+++ libvirt-5.1.0/tests/qemuxml2argvtest.c
@@ -1653,6 +1653,8 @@ mymain(void)
             QEMU_CAPS_CCW,
             QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
             QEMU_CAPS_DEVICE_VFIO_CCW);
+    DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ccw-boot",
+                             "s390x");
     DO_TEST_FAILURE("hostdev-subsys-mdev-vfio-ccw",
             QEMU_CAPS_CCW,
             QEMU_CAPS_CCW_CSSID_UNRESTRICTED);
Index: libvirt-5.1.0/tests/qemuxml2xmltest.c
===================================================================
--- libvirt-5.1.0.orig/tests/qemuxml2xmltest.c
+++ libvirt-5.1.0/tests/qemuxml2xmltest.c
@@ -969,6 +969,11 @@ mymain(void)
             QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
             QEMU_CAPS_DEVICE_VFIO_CCW);
 
+    DO_TEST("hostdev-subsys-mdev-vfio-ccw-boot",
+            QEMU_CAPS_CCW,
+            QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
+            QEMU_CAPS_DEVICE_VFIO_CCW);
+
     DO_TEST("s390-defaultconsole",
             QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
     DO_TEST("s390-panic",
Index: libvirt-5.1.0/tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw-boot.xml
===================================================================
--- /dev/null
+++ libvirt-5.1.0/tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw-boot.xml
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>2</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-ccw'>
+      <source>
+        <address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
+      </source>
+      <boot order='1'/>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+    </hostdev>
+    <memballoon model='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+    </memballoon>
+    <panic model='s390'/>
+  </devices>
+</domain>
openSUSE Build Service is sponsored by