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