diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 86199623cc..4cda131254 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5467,11 +5467,14 @@ virDomainChrSourceDefValidate(const virDomainChrSourceDef *def, break; case VIR_DOMAIN_CHR_TYPE_UNIX: - /* path can be auto generated */ + /* The source path can be auto generated for certain specific + * types of channels, but in most cases we should report an + * error if the user didn't provide it */ if (!def->data.nix.path && - (!chr_def || - (chr_def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN && - chr_def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO))) { + !(chr_def && + chr_def->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && + (chr_def->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN || + chr_def->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source path attribute for char device")); return -1; diff --git a/tests/qemuxml2argvdata/serial-unix-missing-source.xml b/tests/qemuxml2argvdata/serial-unix-missing-source.xml new file mode 100644 index 0000000000..1e1221f12d --- /dev/null +++ b/tests/qemuxml2argvdata/serial-unix-missing-source.xml @@ -0,0 +1,15 @@ + + guest + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1 + + hvm + + + /usr/bin/qemu-system-aarch64 + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 35df63b2ac..949b203998 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1417,6 +1417,7 @@ mymain(void) DO_TEST("serial-unix-chardev", QEMU_CAPS_DEVICE_ISA_SERIAL); DO_TEST_CAPS_LATEST("serial-unix-chardev"); + DO_TEST_PARSE_ERROR("serial-unix-missing-source", NONE); DO_TEST("serial-tcp-chardev", QEMU_CAPS_DEVICE_ISA_SERIAL); DO_TEST("serial-udp-chardev",