render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
404507
From 2cfaf0011f6462310f658a650fbdf998ed575ff0 Mon Sep 17 00:00:00 2001
404507
Message-Id: <2cfaf0011f6462310f658a650fbdf998ed575ff0@dist-git>
404507
From: Peter Krempa <pkrempa@redhat.com>
404507
Date: Thu, 23 Nov 2017 19:02:16 +0100
404507
Subject: [PATCH] qemu: domain: Move video device validation into separate
404507
 function
404507
404507
(cherry picked from commit ab948b6299aa311c07bb46b79c6ccbe7d46fb94e)
404507
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1511480
404507
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
404507
---
404507
 src/qemu/qemu_domain.c | 43 ++++++++++++++++++++++++++-----------------
404507
 1 file changed, 26 insertions(+), 17 deletions(-)
404507
404507
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
404507
index 13b96368c1..1b72d95d7e 100644
404507
--- a/src/qemu/qemu_domain.c
404507
+++ b/src/qemu/qemu_domain.c
404507
@@ -3666,6 +3666,29 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
404507
 }
404507
 
404507
 
404507
+static int
404507
+qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video)
404507
+{
404507
+    if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
404507
+        video->vgamem) {
404507
+        if (video->vgamem < 1024) {
404507
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
404507
+                           _("value for 'vgamem' must be at least 1 MiB "
404507
+                             "(1024 KiB)"));
404507
+            return -1;
404507
+        }
404507
+
404507
+        if (video->vgamem != VIR_ROUND_UP_POWER_OF_TWO(video->vgamem)) {
404507
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
404507
+                           _("value for 'vgamem' must be power of two"));
404507
+            return -1;
404507
+        }
404507
+    }
404507
+
404507
+    return 0;
404507
+}
404507
+
404507
+
404507
 static int
404507
 qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
404507
                             const virDomainDef *def,
404507
@@ -3694,23 +3717,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
404507
     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
404507
         if (qemuDomainDeviceDefValidateHostdev(dev->data.hostdev, def) < 0)
404507
             goto cleanup;
404507
-    }
404507
-
404507
-    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
404507
-        if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
404507
-            dev->data.video->vgamem) {
404507
-            if (dev->data.video->vgamem < 1024) {
404507
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
404507
-                               _("value for 'vgamem' must be at least 1 MiB "
404507
-                                 "(1024 KiB)"));
404507
-                goto cleanup;
404507
-            }
404507
-            if (dev->data.video->vgamem != VIR_ROUND_UP_POWER_OF_TWO(dev->data.video->vgamem)) {
404507
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
404507
-                               _("value for 'vgamem' must be power of two"));
404507
-                goto cleanup;
404507
-            }
404507
-        }
404507
+    } else if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
404507
+        if (qemuDomainDeviceDefValidateVideo(dev->data.video) < 0)
404507
+            goto cleanup;
404507
     }
404507
 
404507
     ret = 0;
404507
-- 
404507
2.15.0
404507