render / rpms / libvirt

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