diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bf57f94a50..cbee151f5d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3766,8 +3766,17 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, /* clear auto generated unix socket path for inactive definitions */ if ((parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && dev->type == VIR_DOMAIN_DEVICE_CHR) { - if (qemuDomainChrDefDropDefaultPath(dev->data.chr, driver) < 0) + virDomainChrDefPtr chr = dev->data.chr; + if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0) goto cleanup; + + /* 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; + } } if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) { @@ -7441,8 +7450,6 @@ qemuDomainPrepareChannel(virDomainChrDefPtr channel, return -1; } - channel->source->data.nix.listen = true; - return 0; } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-generated-path.xml b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-generated-path.xml new file mode 100644 index 0000000000..3cb67ecdcc --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-chardev-reconnect-generated-path.xml @@ -0,0 +1,23 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 1 + + hvm + + + + /usr/bin/qemu-system-i686 + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 0c0bd16f94..18f06e5aa5 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1351,6 +1351,9 @@ mymain(void) DO_TEST_PARSE_ERROR("chardev-reconnect-invalid-timeout", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_CHARDEV_RECONNECT); + DO_TEST_PARSE_ERROR("chardev-reconnect-generated-path", + QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_CHARDEV_RECONNECT); DO_TEST("usb-controller", QEMU_CAPS_NODEFCONFIG);