render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c1c534
From 413eb4cbdddfd7ecc3fd12320a59033c76f878cc Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <413eb4cbdddfd7ecc3fd12320a59033c76f878cc@dist-git>
c1c534
From: Peter Krempa <pkrempa@redhat.com>
c1c534
Date: Thu, 23 Nov 2017 19:02:15 +0100
c1c534
Subject: [PATCH] qemu: domain: Move hostdev validation into separate function
c1c534
c1c534
(cherry picked from commit a6936ec0987f6b014516e4d51b44c9c9de57a6cb)
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1511480
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/qemu/qemu_domain.c | 30 ++++++++++++++++++++----------
c1c534
 1 file changed, 20 insertions(+), 10 deletions(-)
c1c534
c1c534
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
c1c534
index 30a602a1e9..13b96368c1 100644
c1c534
--- a/src/qemu/qemu_domain.c
c1c534
+++ b/src/qemu/qemu_domain.c
c1c534
@@ -3649,6 +3649,23 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
c1c534
 }
c1c534
 
c1c534
 
c1c534
+static int
c1c534
+qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
c1c534
+                                   const virDomainDef *def)
c1c534
+{
c1c534
+    /* forbid capabilities mode hostdev in this kind of hypervisor */
c1c534
+    if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
c1c534
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
c1c534
+                       _("hostdev mode 'capabilities' is not "
c1c534
+                         "supported in %s"),
c1c534
+                       virDomainVirtTypeToString(def->virtType));
c1c534
+        return -1;
c1c534
+    }
c1c534
+
c1c534
+    return 0;
c1c534
+}
c1c534
+
c1c534
+
c1c534
 static int
c1c534
 qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
c1c534
                             const virDomainDef *def,
c1c534
@@ -3674,16 +3691,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
c1c534
     } else if (dev->type == VIR_DOMAIN_DEVICE_WATCHDOG) {
c1c534
         if (qemuDomainWatchdogDefValidate(dev->data.watchdog, def) < 0)
c1c534
             goto cleanup;
c1c534
-    }
c1c534
-
c1c534
-    /* forbid capabilities mode hostdev in this kind of hypervisor */
c1c534
-    if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
c1c534
-        dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
c1c534
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
c1c534
-                       _("hostdev mode 'capabilities' is not "
c1c534
-                         "supported in %s"),
c1c534
-                       virDomainVirtTypeToString(def->virtType));
c1c534
-        goto cleanup;
c1c534
+    } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
c1c534
+        if (qemuDomainDeviceDefValidateHostdev(dev->data.hostdev, def) < 0)
c1c534
+            goto cleanup;
c1c534
     }
c1c534
 
c1c534
     if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
c1c534
-- 
c1c534
2.15.0
c1c534