
On 08/30/2017 04:49 PM, Pavel Hrdina wrote:
Currently while parsing domain XML we clear the UNIX path if it matches one of the auto-generated paths by libvirt. After that when the guest is started new path is generated but the mode is also changed to "bind".
In the real-world use-case the mode should not change, it only happens if a user provides a mode='connect' and path that matches one of the auto-generated path or not provides a path at all.
Before *reconnect* feature was introduced there was no issue, but with the new feature we need to make sure that it's used only with "connect" mode, therefore we need to move the mode change into parsing in order to have a proper error reported by validation code.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 8 ++++++++ src/qemu/qemu_domain.c | 6 +++--- ...muxml2argv-chardev-reconnect-generated-path.xml | 23 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 +++ 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-generated-path.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f7574d77b6..9fdd0f90fc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4421,6 +4421,14 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev,
chr->target.port = maxport + 1; } + + /* For UNIX chardev if no path is provided we generate one. + * This also implies that the mode is 'bind'. */ + if (chr->source && + chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX && + !chr->source->data.nix.path) { + chr->source->data.nix.listen = true; + } }
This hunk should go somewhere under src/qemu/ because leaving it here enables this for all the drivers. qemuDomainDeviceDefPostParse() looks like a good candidate. Michal