]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Run devicePostParse() again for the first serial device
authorAndrea Bolognani <abologna@redhat.com>
Wed, 8 Nov 2017 16:40:13 +0000 (17:40 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 28 Nov 2017 14:46:31 +0000 (15:46 +0100)
The devicePostParse() callback is invoked for all devices so that
drivers have a chance to set their own specific values; however,
virDomainDefAddImplicitDevices() runs *after* the devicePostParse()
callbacks have been invoked and can add new devices, in which case
the driver wouldn't have a chance to customize them.

Work around the issue by invoking the devicePostParse() callback
after virDomainDefAddImplicitDevices(), only for the first serial
devices, which might have been added by it. The same was already
happening for the first video device for the very same reason.

This will become important later on, when we will change
virDomainDefAddConsoleCompat() not to set a targetType for
automatically added serial devices.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/conf/domain_conf.c

index 66536653b6839d824307e87480c06a6cf08357a5..83c121b0238c99996f7df464638016f117f38275 100644 (file)
@@ -4946,6 +4946,18 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
             return -1;
     }
 
+    if (def->nserials != 0) {
+        virDomainDeviceDef device = {
+            .type = VIR_DOMAIN_DEVICE_CHR,
+            .data.chr = def->serials[0],
+        };
+
+        /* serials[0] might have been added in AddImplicitDevices, after we've
+         * done the per-device post-parse */
+        if (virDomainDefPostParseDeviceIterator(def, &device, NULL, data) < 0)
+            return -1;
+    }
+
     /* clean up possibly duplicated metadata entries */
     virXMLNodeSanitizeNamespaces(def->metadata);