Blame SOURCES/libvirt-qemu-Extract-MDEV-VFIO-PCI-validation-code-into-a-separate-helper.patch

9c6c51
From 46dc4f557546c024c273e0e21110698cdfffe8ae Mon Sep 17 00:00:00 2001
9c6c51
Message-Id: <46dc4f557546c024c273e0e21110698cdfffe8ae@dist-git>
9c6c51
From: Erik Skultety <eskultet@redhat.com>
9c6c51
Date: Fri, 30 Nov 2018 15:49:25 +0100
9c6c51
Subject: [PATCH] qemu: Extract MDEV VFIO PCI validation code into a separate
9c6c51
 helper
9c6c51
9c6c51
Since we'll need to validate other models apart from VFIO PCI too,
9c6c51
having a helper for each model should keep the code base cleaner.
9c6c51
9c6c51
Signed-off-by: Erik Skultety <eskultet@redhat.com>
9c6c51
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
9c6c51
(cherry picked from commit 208d6e6f5aafa102d04ce300c6338b0736bb52df)
9c6c51
9c6c51
https://bugzilla.redhat.com/show_bug.cgi?id=1508146
9c6c51
9c6c51
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
9c6c51
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
9c6c51
---
9c6c51
 src/qemu/qemu_domain.c | 35 +++++++++++++++++++++++++++++------
9c6c51
 1 file changed, 29 insertions(+), 6 deletions(-)
9c6c51
9c6c51
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
9c6c51
index d80f9b393e..4898d58733 100644
9c6c51
--- a/src/qemu/qemu_domain.c
9c6c51
+++ b/src/qemu/qemu_domain.c
9c6c51
@@ -4451,11 +4451,11 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
9c6c51
 
9c6c51
 
9c6c51
 static int
9c6c51
-qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
9c6c51
-                          const virDomainDef *def,
9c6c51
-                          virQEMUCapsPtr qemuCaps)
9c6c51
+qemuDomainMdevDefVFIOPCIValidate(const virDomainHostdevSubsysMediatedDev *dev,
9c6c51
+                                 const virDomainDef *def,
9c6c51
+                                 virQEMUCapsPtr qemuCaps)
9c6c51
 {
9c6c51
-    if (mdevsrc->display == VIR_TRISTATE_SWITCH_ABSENT)
9c6c51
+    if (dev->display == VIR_TRISTATE_SWITCH_ABSENT)
9c6c51
         return 0;
9c6c51
 
9c6c51
     if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VFIO_PCI_DISPLAY)) {
9c6c51
@@ -4465,7 +4465,7 @@ qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
9c6c51
         return -1;
9c6c51
     }
9c6c51
 
9c6c51
-    if (mdevsrc->model != VIR_MDEV_MODEL_TYPE_VFIO_PCI) {
9c6c51
+    if (dev->model != VIR_MDEV_MODEL_TYPE_VFIO_PCI) {
9c6c51
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
9c6c51
                        _("<hostdev> attribute 'display' is only supported"
9c6c51
                          " with model='vfio-pci'"));
9c6c51
@@ -4473,7 +4473,7 @@ qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
9c6c51
         return -1;
9c6c51
     }
9c6c51
 
9c6c51
-    if (mdevsrc->display == VIR_TRISTATE_SWITCH_ON) {
9c6c51
+    if (dev->display == VIR_TRISTATE_SWITCH_ON) {
9c6c51
         if (def->ngraphics == 0) {
9c6c51
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
9c6c51
                            _("graphics device is needed for attribute value "
9c6c51
@@ -4486,6 +4486,29 @@ qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
9c6c51
 }
9c6c51
 
9c6c51
 
9c6c51
+static int
9c6c51
+qemuDomainMdevDefValidate(const virDomainHostdevSubsysMediatedDev *mdevsrc,
9c6c51
+                          const virDomainDef *def,
9c6c51
+                          virQEMUCapsPtr qemuCaps)
9c6c51
+{
9c6c51
+    switch ((virMediatedDeviceModelType) mdevsrc->model) {
9c6c51
+    case VIR_MDEV_MODEL_TYPE_VFIO_PCI:
9c6c51
+        return qemuDomainMdevDefVFIOPCIValidate(mdevsrc, def, qemuCaps);
9c6c51
+    case VIR_MDEV_MODEL_TYPE_VFIO_AP:
9c6c51
+        break;
9c6c51
+    case VIR_MDEV_MODEL_TYPE_VFIO_CCW:
9c6c51
+        break;
9c6c51
+    case VIR_MDEV_MODEL_TYPE_LAST:
9c6c51
+    default:
9c6c51
+        virReportEnumRangeError(virMediatedDeviceModelType,
9c6c51
+                                mdevsrc->model);
9c6c51
+        return -1;
9c6c51
+    }
9c6c51
+
9c6c51
+    return 0;
9c6c51
+}
9c6c51
+
9c6c51
+
9c6c51
 static int
9c6c51
 qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
9c6c51
                                    const virDomainDef *def,
9c6c51
-- 
9c6c51
2.19.2
9c6c51