51d9a2
From 0cfcffc74781daef4ca6c08d0db78df786b8c7f5 Mon Sep 17 00:00:00 2001
51d9a2
Message-Id: <0cfcffc74781daef4ca6c08d0db78df786b8c7f5@dist-git>
51d9a2
From: Erik Skultety <eskultet@redhat.com>
51d9a2
Date: Thu, 19 Jul 2018 15:03:52 +0200
51d9a2
Subject: [PATCH] conf: Introduce virDomainDefPostParseVideo helper
51d9a2
MIME-Version: 1.0
51d9a2
Content-Type: text/plain; charset=UTF-8
51d9a2
Content-Transfer-Encoding: 8bit
51d9a2
51d9a2
Move the video post parse bits into a separate helper as the logic is
51d9a2
going to be extended in the future.
51d9a2
51d9a2
Signed-off-by: Erik Skultety <eskultet@redhat.com>
51d9a2
Reviewed-by: John Ferlan <jferlan@redhat.com>
51d9a2
(cherry picked from commit 75aa179ad68f5845955128b9f047a43c8e5c9066)
51d9a2
51d9a2
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
51d9a2
Signed-off-by: Erik Skultety <eskultet@redhat.com>
51d9a2
Reviewed-by: Ján Tomko <jtomko@redhat.com>
51d9a2
---
51d9a2
 src/conf/domain_conf.c | 45 ++++++++++++++++++++++++++++--------------
51d9a2
 1 file changed, 30 insertions(+), 15 deletions(-)
51d9a2
51d9a2
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
51d9a2
index d23b2861ef..db8e17dac4 100644
51d9a2
--- a/src/conf/domain_conf.c
51d9a2
+++ b/src/conf/domain_conf.c
51d9a2
@@ -5097,6 +5097,34 @@ virDomainDefBootOrderPostParse(virDomainDefPtr def)
51d9a2
 }
51d9a2
 
51d9a2
 
51d9a2
+static int
51d9a2
+virDomainDefPostParseVideo(virDomainDefPtr def,
51d9a2
+                           void *opaque)
51d9a2
+{
51d9a2
+    if (def->nvideos == 0)
51d9a2
+        return 0;
51d9a2
+
51d9a2
+    virDomainDeviceDef device = {
51d9a2
+        .type = VIR_DOMAIN_DEVICE_VIDEO,
51d9a2
+        .data.video = def->videos[0],
51d9a2
+    };
51d9a2
+
51d9a2
+    /* Mark the first video as primary. If the user specified
51d9a2
+     * primary="yes", the parser already inserted the device at
51d9a2
+     * def->videos[0]
51d9a2
+     */
51d9a2
+    def->videos[0]->primary = true;
51d9a2
+
51d9a2
+    /* videos[0] might have been added in AddImplicitDevices, after we've
51d9a2
+     * done the per-device post-parse */
51d9a2
+    if (virDomainDefPostParseDeviceIterator(def, &device,
51d9a2
+                                            NULL, opaque) < 0)
51d9a2
+        return -1;
51d9a2
+
51d9a2
+    return 0;
51d9a2
+}
51d9a2
+
51d9a2
+
51d9a2
 static int
51d9a2
 virDomainDefPostParseCommon(virDomainDefPtr def,
51d9a2
                             struct virDomainDefPostParseDeviceIteratorData *data)
51d9a2
@@ -5133,21 +5161,8 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
51d9a2
     if (virDomainDefAddImplicitDevices(def) < 0)
51d9a2
         return -1;
51d9a2
 
51d9a2
-    if (def->nvideos != 0) {
51d9a2
-        virDomainDeviceDef device = {
51d9a2
-            .type = VIR_DOMAIN_DEVICE_VIDEO,
51d9a2
-            .data.video = def->videos[0],
51d9a2
-        };
51d9a2
-
51d9a2
-        /* Mark the first video as primary. If the user specified primary="yes",
51d9a2
-         * the parser already inserted the device at def->videos[0] */
51d9a2
-        def->videos[0]->primary = true;
51d9a2
-
51d9a2
-        /* videos[0] might have been added in AddImplicitDevices, after we've
51d9a2
-         * done the per-device post-parse */
51d9a2
-        if (virDomainDefPostParseDeviceIterator(def, &device, NULL, data) < 0)
51d9a2
-            return -1;
51d9a2
-    }
51d9a2
+    if (virDomainDefPostParseVideo(def, data) < 0)
51d9a2
+        return -1;
51d9a2
 
51d9a2
     if (def->nserials != 0) {
51d9a2
         virDomainDeviceDef device = {
51d9a2
-- 
51d9a2
2.18.0
51d9a2