c1c534
From 0c9561ff6de749954395f562cbb8e3d12954566c Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <0c9561ff6de749954395f562cbb8e3d12954566c@dist-git>
c1c534
From: Andrea Bolognani <abologna@redhat.com>
c1c534
Date: Wed, 29 Nov 2017 16:22:57 +0100
c1c534
Subject: [PATCH] conf: Run devicePostParse() again for the first serial device
c1c534
c1c534
The devicePostParse() callback is invoked for all devices so that
c1c534
drivers have a chance to set their own specific values; however,
c1c534
virDomainDefAddImplicitDevices() runs *after* the devicePostParse()
c1c534
callbacks have been invoked and can add new devices, in which case
c1c534
the driver wouldn't have a chance to customize them.
c1c534
c1c534
Work around the issue by invoking the devicePostParse() callback
c1c534
after virDomainDefAddImplicitDevices(), only for the first serial
c1c534
devices, which might have been added by it. The same was already
c1c534
happening for the first video device for the very same reason.
c1c534
c1c534
This will become important later on, when we will change
c1c534
virDomainDefAddConsoleCompat() not to set a targetType for
c1c534
automatically added serial devices.
c1c534
c1c534
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
c1c534
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
c1c534
(cherry picked from commit 2628afc143224d38e6ef8c06a8fbec1d0f69fb86)
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1449265
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1511421
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1512929
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1512934
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/conf/domain_conf.c | 12 ++++++++++++
c1c534
 1 file changed, 12 insertions(+)
c1c534
c1c534
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
c1c534
index 4b5e7c214f..41674a85af 100644
c1c534
--- a/src/conf/domain_conf.c
c1c534
+++ b/src/conf/domain_conf.c
c1c534
@@ -4948,6 +4948,18 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
c1c534
             return -1;
c1c534
     }
c1c534
 
c1c534
+    if (def->nserials != 0) {
c1c534
+        virDomainDeviceDef device = {
c1c534
+            .type = VIR_DOMAIN_DEVICE_CHR,
c1c534
+            .data.chr = def->serials[0],
c1c534
+        };
c1c534
+
c1c534
+        /* serials[0] might have been added in AddImplicitDevices, after we've
c1c534
+         * done the per-device post-parse */
c1c534
+        if (virDomainDefPostParseDeviceIterator(def, &device, NULL, data) < 0)
c1c534
+            return -1;
c1c534
+    }
c1c534
+
c1c534
     /* clean up possibly duplicated metadata entries */
c1c534
     virXMLNodeSanitizeNamespaces(def->metadata);
c1c534
 
c1c534
-- 
c1c534
2.15.1
c1c534