diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2209cf68eb..9b06a4924e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6427,7 +6427,9 @@ qemuBuildVirtioSerialPortDevStr(virDomainDefPtr def, virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC))) { virBufferAsprintf(&buf, ",chardev=char%s,id=%s", dev->info.alias, dev->info.alias); - if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL) { + if (dev->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && + (dev->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC || + dev->target.name)) { virBufferAsprintf(&buf, ",name=%s", dev->target.name ? dev->target.name : "com.redhat.spice.0"); } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-default.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-default.args new file mode 100644 index 0000000000..7908445f03 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-default.args @@ -0,0 +1,16 @@ +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 pty,id=charchannel0 \ +-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0 \ +-chardev spicevmc,id=charchannel1,name=vdagent \ +-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,\ +name=com.redhat.spice.0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-default.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-default.xml new file mode 100644 index 0000000000..74badedc81 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-default.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + +
+ + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a212d30e32..4154601d82 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1110,6 +1110,9 @@ mymain(void) DO_TEST("channel-spicevmc-old", QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_SPICEVMC); + DO_TEST("channel-virtio-default", + QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC); DO_TEST("smartcard-host", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,