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