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