]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: domain: Extract video device def post parse code
authorPeter Krempa <pkrempa@redhat.com>
Thu, 24 May 2018 15:01:55 +0000 (17:01 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 24 May 2018 16:25:30 +0000 (18:25 +0200)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c

index dbdd94de2fdd4458590ab2eaa8318d1a2acb9119..e9a8b0c33295f4cf1606dee72e3b26ad60e4f0c3 100644 (file)
@@ -5743,6 +5743,28 @@ qemuDomainDeviceNetDefPostParse(virDomainNetDefPtr net,
 }
 
 
+static int
+qemuDomainDeviceVideoDefPostParse(virDomainVideoDefPtr video,
+                                  const virDomainDef *def)
+{
+    if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
+        if (ARCH_IS_PPC64(def->os.arch))
+            video->type = VIR_DOMAIN_VIDEO_TYPE_VGA;
+        else if (qemuDomainIsVirt(def) || ARCH_IS_S390(def->os.arch))
+            video->type = VIR_DOMAIN_VIDEO_TYPE_VIRTIO;
+        else
+            video->type = VIR_DOMAIN_VIDEO_TYPE_CIRRUS;
+    }
+
+    if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
+        !video->vgamem) {
+        video->vgamem = QEMU_QXL_VGAMEM_DEFAULT;
+    }
+
+    return 0;
+}
+
+
 static int
 qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
                              const virDomainDef *def,
@@ -5767,21 +5789,9 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
         qemuDomainDeviceDiskDefPostParse(dev->data.disk, cfg) < 0)
         goto cleanup;
 
-    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
-        if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
-            if (ARCH_IS_PPC64(def->os.arch))
-                dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_VGA;
-            else if (qemuDomainIsVirt(def) || ARCH_IS_S390(def->os.arch))
-                dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_VIRTIO;
-            else
-                dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_CIRRUS;
-        }
-
-        if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
-            !dev->data.video->vgamem) {
-            dev->data.video->vgamem = QEMU_QXL_VGAMEM_DEFAULT;
-        }
-    }
+    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO &&
+        qemuDomainDeviceVideoDefPostParse(dev->data.video, def) < 0)
+        goto cleanup;
 
     if (dev->type == VIR_DOMAIN_DEVICE_PANIC &&
         dev->data.panic->model == VIR_DOMAIN_PANIC_MODEL_DEFAULT) {