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