File 1219f0ca-qemu-refactor-mdev-validation-method-signatures.patch of Package libvirt.16761

commit 1219f0cadc93aa0953cc5ad31e9f8675b546675c
Author: Boris Fiuczynski <fiuczy@linux.ibm.com>
Date:   Tue Aug 27 16:19:22 2019 +0200

    qemu: refactor mdev validation method signatures
    
    Refactoring the method signatures in preparation for
    checking boot index of the mediated devices.
    
    Reviewed-by: Ján Tomko <jtomko@redhat.com>
    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>
    Signed-off-by: Ján Tomko <jtomko@redhat.com>

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
@@ -4713,10 +4713,13 @@ qemuDomainDeviceDefValidateNetwork(const
 
 
 static int
-qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevSubsysMediatedDev *dev,
+qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevDef *hostdev,
                                  const virDomainDef *def,
                                  virQEMUCapsPtr qemuCaps)
 {
+    const virDomainHostdevSubsysMediatedDev *dev;
+
+    dev = &hostdev->source.subsys.u.mdev;
     if (dev->display == VIR_TRISTATE_SWITCH_ABSENT)
         return 0;
 
@@ -4749,17 +4752,18 @@ qemuDomainMdevDefVFIOPCIValidate(const v
 
 
 static int
-qemuDomainMdevDefVFIOAPValidate(const virDomainDef *def)
+qemuDomainMdevDefVFIOAPValidate(const virDomainHostdevDef *hostdev ATTRIBUTE_UNUSED,
+                                const virDomainDef *def)
 {
     size_t i;
     bool vfioap_found = false;
 
     /* VFIO-AP is restricted to a single mediated device only */
     for (i = 0; i < def->nhostdevs; i++) {
-        virDomainHostdevDefPtr hostdev = def->hostdevs[i];
+        virDomainHostdevDefPtr hdev = def->hostdevs[i];
 
-        if (virHostdevIsMdevDevice(hostdev) &&
-            hostdev->source.subsys.u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP) {
+        if (virHostdevIsMdevDevice(hdev) &&
+            hdev->source.subsys.u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP) {
             if (vfioap_found) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("Only one hostdev of model vfio-ap is "
@@ -4775,15 +4779,18 @@ qemuDomainMdevDefVFIOAPValidate(const vi
 
 
 static int
-qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
+qemuDomainMdevDefValidate(const virDomainHostdevDef *hostdev,
                           const virDomainDef *def,
                           virQEMUCapsPtr qemuCaps)
 {
+    const virDomainHostdevSubsysMediatedDev *mdevsrc;
+
+    mdevsrc = &hostdev->source.subsys.u.mdev;
     switch ((virMediatedDeviceModelType) mdevsrc->model) {
     case VIR_MDEV_MODEL_TYPE_VFIO_PCI:
-        return qemuDomainMdevDefVFIOPCIValidate(mdevsrc, def, qemuCaps);
+        return qemuDomainMdevDefVFIOPCIValidate(hostdev, def, qemuCaps);
     case VIR_MDEV_MODEL_TYPE_VFIO_AP:
-        return qemuDomainMdevDefVFIOAPValidate(def);
+        return qemuDomainMdevDefVFIOAPValidate(hostdev, def);
     case VIR_MDEV_MODEL_TYPE_VFIO_CCW:
         break;
     case VIR_MDEV_MODEL_TYPE_LAST:
@@ -4802,8 +4809,6 @@ qemuDomainDeviceDefValidateHostdev(const
                                    const virDomainDef *def,
                                    virQEMUCapsPtr qemuCaps)
 {
-    const virDomainHostdevSubsysMediatedDev *mdevsrc;
-
     /* forbid capabilities mode hostdev in this kind of hypervisor */
     if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -4834,8 +4839,7 @@ qemuDomainDeviceDefValidateHostdev(const
                                  "supported by mediated devices"));
                 return -1;
             }
-            mdevsrc = &hostdev->source.subsys.u.mdev;
-            return qemuDomainMdevDefValidate(mdevsrc, def, qemuCaps);
+            return qemuDomainMdevDefValidate(hostdev, def, qemuCaps);
         case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
         default:
             virReportEnumRangeError(virDomainHostdevSubsysType,
openSUSE Build Service is sponsored by