diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6213fd9f31..404489c9c9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1249,11 +1249,23 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && dev->data.chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO && dev->data.chr->source.type == VIR_DOMAIN_CHR_TYPE_UNIX && - !dev->data.chr->source.data.nix.path && cfg) { - if (virAsprintf(&dev->data.chr->source.data.nix.path, "%s/%s.%s", - cfg->channelTargetDir, - def->name, dev->data.chr->target.name) < 0) + !dev->data.chr->source.data.nix.path) { + if (!cfg) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("cannot generate UNIX socket path")); goto cleanup; + } + + if (dev->data.chr->target.name) { + if (virAsprintf(&dev->data.chr->source.data.nix.path, "%s/%s.%s", + cfg->channelTargetDir, + def->name, dev->data.chr->target.name) < 0) + goto cleanup; + } else { + if (virAsprintf(&dev->data.chr->source.data.nix.path, "%s/%s", + cfg->channelTargetDir, def->name) < 0) + goto cleanup; + } dev->data.chr->source.data.nix.listen = true; } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args new file mode 100644 index 0000000000..43a34ced80 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args @@ -0,0 +1,19 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-no-acpi \ +-boot c \ +-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \ +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 \ +-usb \ +-hda /dev/HostVG/QEMUGuest1 \ +-chardev socket,id=charchannel0,path=\ +/tmp/QEMUGuest1.org.qemu.guest_agent.0,server,nowait \ +-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,\ +name=org.qemu.guest_agent.0 \ +-chardev socket,id=charchannel1,path=/tmp/QEMUGuest1,server,nowait \ +-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1 \ +-chardev socket,id=charchannel2,path=/tmp/QEMUGuest1.ble,server,nowait \ +-device virtserialport,bus=virtio-serial0.0,nr=3,chardev=charchannel2,id=channel2,\ +name=ble diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml new file mode 100644 index 0000000000..7fac943389 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml @@ -0,0 +1,37 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + +
+ + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index f85f63b333..574777b998 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -519,6 +519,9 @@ mymain(void) driver.config->spiceTLS = 1; if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0) return EXIT_FAILURE; + VIR_FREE(driver.config->channelTargetDir); + if (VIR_STRDUP_QUIET(driver.config->channelTargetDir, "/tmp") < 0) + return EXIT_FAILURE; # define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, ...) \ do { \ @@ -1113,6 +1116,8 @@ mymain(void) DO_TEST("channel-virtio-default", QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC); + DO_TEST("channel-virtio-unix", + QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG); DO_TEST("smartcard-host", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,