[libvirt] [PATCH 04/14] conf: Run devicePostParse() again for the first serial device

Andrea Bolognani posted 14 patches 7 years, 6 months ago
There is a newer version of this series
[libvirt] [PATCH 04/14] conf: Run devicePostParse() again for the first serial device
Posted by Andrea Bolognani 7 years, 6 months ago
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.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/conf/domain_conf.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9da8dd646..bd3a23c0a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4937,6 +4937,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);
 
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 04/14] conf: Run devicePostParse() again for the first serial device
Posted by Pavel Hrdina 7 years, 5 months ago
On Wed, Nov 15, 2017 at 12:50:07PM +0100, Andrea Bolognani wrote:
> 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.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  src/conf/domain_conf.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

So far this was not required but following patches will change how the
"implicit" serial device is added.  Might be nice to mention it in the
commit message.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list