Even though we never format the device on the QEMU command line,
as it's a platform serial device that's not user-instantiable,
we should still make sure it's available before using it.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_command.c | 12 ++++++++++++
tests/qemuxml2argvtest.c | 9 +++++++++
2 files changed, 21 insertions(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 49503fb2c..c78f1b83b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9240,6 +9240,7 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel
targetModel)
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
return QEMU_CAPS_DEVICE_SCLPLMCONSOLE;
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
+ return QEMU_CAPS_DEVICE_PL011;
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
break;
@@ -9332,6 +9333,17 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager,
if (qemuBuildChrDeviceCommandLine(cmd, def, serial, qemuCaps) < 0)
return -1;
} else {
+ virQEMUCapsFlags caps;
+
+ caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
+
+ if (caps && !virQEMUCapsGet(qemuCaps, caps)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("'%s' is not supported in this QEMU
binary"),
+
virDomainChrSerialTargetModelTypeToString(serial->targetModel));
+ return -1;
+ }
+
virCommandAddArg(cmd, "-serial");
virCommandAddArgFormat(cmd, "chardev:char%s",
serial->info.alias);
}
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index cd6c66b3f..7a606cef9 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1924,10 +1924,13 @@ mymain(void)
DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);
DO_TEST("mach-virt-serial-native",
+ QEMU_CAPS_DEVICE_PL011,
QEMU_CAPS_NODEFCONFIG);
DO_TEST("mach-virt-serial+console-native",
+ QEMU_CAPS_DEVICE_PL011,
QEMU_CAPS_NODEFCONFIG);
DO_TEST("mach-virt-serial-compat",
+ QEMU_CAPS_DEVICE_PL011,
QEMU_CAPS_NODEFCONFIG);
DO_TEST("mach-virt-serial-pci",
QEMU_CAPS_NODEFCONFIG,
@@ -1945,6 +1948,7 @@ mymain(void)
QEMU_CAPS_DEVICE_QEMU_XHCI,
QEMU_CAPS_DEVICE_USB_SERIAL);
DO_TEST("mach-virt-console-native",
+ QEMU_CAPS_DEVICE_PL011,
QEMU_CAPS_NODEFCONFIG);
DO_TEST("mach-virt-console-virtio",
QEMU_CAPS_NODEFCONFIG);
@@ -2506,11 +2510,13 @@ mymain(void)
DO_TEST("arm-virt-virtio",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
QEMU_CAPS_DEVICE_VIRTIO_MMIO,
+ QEMU_CAPS_DEVICE_PL011,
QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
DO_TEST("aarch64-virt-virtio",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
QEMU_CAPS_DEVICE_VIRTIO_MMIO,
+ QEMU_CAPS_DEVICE_PL011,
QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
/* Demonstrates the virtio-pci default... namely that there isn't any!
@@ -2526,6 +2532,7 @@ mymain(void)
QEMU_CAPS_PCI_MULTIFUNCTION,
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
QEMU_CAPS_DEVICE_IOH3420,
+ QEMU_CAPS_DEVICE_PL011,
QEMU_CAPS_VIRTIO_SCSI);
DO_TEST("aarch64-virt-2.6-virtio-pci-default",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
@@ -2534,6 +2541,7 @@ mymain(void)
QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
QEMU_CAPS_PCI_MULTIFUNCTION,
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+ QEMU_CAPS_DEVICE_PL011,
QEMU_CAPS_DEVICE_IOH3420);
/* Example of using virtio-pci with no explicit PCI controller
but with manual PCI addresses */
@@ -2652,6 +2660,7 @@ mymain(void)
QEMU_CAPS_MACH_VIRT_GIC_VERSION);
DO_TEST("aarch64-kvm-32-on-64",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
+ QEMU_CAPS_DEVICE_PL011,
QEMU_CAPS_KVM, QEMU_CAPS_CPU_AARCH64_OFF);
DO_TEST_FAILURE("aarch64-kvm-32-on-64",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
--
2.14.3