]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: domain: Move video device validation into separate function
authorPeter Krempa <pkrempa@redhat.com>
Tue, 14 Nov 2017 13:38:14 +0000 (14:38 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 23 Nov 2017 17:26:25 +0000 (18:26 +0100)
src/qemu/qemu_domain.c

index 0875ad3102657fa010aa6f22ad034a7c8d728780..9c4da492313b7678bc2c487882c4a7ce3a557dec 100644 (file)
@@ -3701,6 +3701,29 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
 }
 
 
+static int
+qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video)
+{
+    if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
+        video->vgamem) {
+        if (video->vgamem < 1024) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("value for 'vgamem' must be at least 1 MiB "
+                             "(1024 KiB)"));
+            return -1;
+        }
+
+        if (video->vgamem != VIR_ROUND_UP_POWER_OF_TWO(video->vgamem)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("value for 'vgamem' must be power of two"));
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+
 static int
 qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                             const virDomainDef *def,
@@ -3729,23 +3752,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
         if (qemuDomainDeviceDefValidateHostdev(dev->data.hostdev, def) < 0)
             goto cleanup;
-    }
-
-    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
-        if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
-            dev->data.video->vgamem) {
-            if (dev->data.video->vgamem < 1024) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("value for 'vgamem' must be at least 1 MiB "
-                                 "(1024 KiB)"));
-                goto cleanup;
-            }
-            if (dev->data.video->vgamem != VIR_ROUND_UP_POWER_OF_TWO(dev->data.video->vgamem)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("value for 'vgamem' must be power of two"));
-                goto cleanup;
-            }
-        }
+    } else if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
+        if (qemuDomainDeviceDefValidateVideo(dev->data.video) < 0)
+            goto cleanup;
     }
 
     ret = 0;