Blame SOURCES/libvirt-qemu-domain-Move-video-device-validation-into-separate-function.patch

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