render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c1c534
From ae52a7777eae5936c68ffef6f84280adae80703b Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <ae52a7777eae5936c68ffef6f84280adae80703b@dist-git>
c1c534
From: Andrea Bolognani <abologna@redhat.com>
c1c534
Date: Wed, 29 Nov 2017 16:23:20 +0100
c1c534
Subject: [PATCH] qemu: Require QEMU_CAPS_DEVICE_PL011 for pl011
c1c534
c1c534
Even though we never format the device on the QEMU command line,
c1c534
as it's a platform serial device that's not user-instantiable,
c1c534
we should still make sure it's available before using it.
c1c534
c1c534
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
c1c534
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
c1c534
(cherry picked from commit b2fb483c34390b4c5eeff0304712cea0ace21d88)
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1512929
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/qemu/qemu_command.c  | 12 ++++++++++++
c1c534
 tests/qemuxml2argvtest.c |  9 +++++++++
c1c534
 2 files changed, 21 insertions(+)
c1c534
c1c534
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
c1c534
index 5c246698c0..18977480d9 100644
c1c534
--- a/src/qemu/qemu_command.c
c1c534
+++ b/src/qemu/qemu_command.c
c1c534
@@ -9236,6 +9236,7 @@ qemuChrSerialTargetModelToCaps(virDomainChrSerialTargetModel targetModel)
c1c534
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
c1c534
         return QEMU_CAPS_DEVICE_SCLPLMCONSOLE;
c1c534
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
c1c534
+        return QEMU_CAPS_DEVICE_PL011;
c1c534
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
c1c534
     case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
c1c534
         break;
c1c534
@@ -9328,6 +9329,17 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager,
c1c534
             if (qemuBuildChrDeviceCommandLine(cmd, def, serial, qemuCaps) < 0)
c1c534
                 return -1;
c1c534
         } else {
c1c534
+            virQEMUCapsFlags caps;
c1c534
+
c1c534
+            caps = qemuChrSerialTargetModelToCaps(serial->targetModel);
c1c534
+
c1c534
+            if (caps && !virQEMUCapsGet(qemuCaps, caps)) {
c1c534
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
c1c534
+                               _("'%s' is not supported in this QEMU binary"),
c1c534
+                               virDomainChrSerialTargetModelTypeToString(serial->targetModel));
c1c534
+                return -1;
c1c534
+            }
c1c534
+
c1c534
             virCommandAddArg(cmd, "-serial");
c1c534
             virCommandAddArgFormat(cmd, "chardev:char%s", serial->info.alias);
c1c534
         }
c1c534
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
c1c534
index b61cee74c7..77c9783929 100644
c1c534
--- a/tests/qemuxml2argvtest.c
c1c534
+++ b/tests/qemuxml2argvtest.c
c1c534
@@ -1922,10 +1922,13 @@ mymain(void)
c1c534
     DO_TEST_PARSE_ERROR("pseries-serial-invalid-machine", NONE);
c1c534
 
c1c534
     DO_TEST("mach-virt-serial-native",
c1c534
+            QEMU_CAPS_DEVICE_PL011,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST("mach-virt-serial+console-native",
c1c534
+            QEMU_CAPS_DEVICE_PL011,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST("mach-virt-serial-compat",
c1c534
+            QEMU_CAPS_DEVICE_PL011,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST("mach-virt-serial-pci",
c1c534
             QEMU_CAPS_NODEFCONFIG,
c1c534
@@ -1943,6 +1946,7 @@ mymain(void)
c1c534
             QEMU_CAPS_DEVICE_QEMU_XHCI,
c1c534
             QEMU_CAPS_DEVICE_USB_SERIAL);
c1c534
     DO_TEST("mach-virt-console-native",
c1c534
+            QEMU_CAPS_DEVICE_PL011,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST("mach-virt-console-virtio",
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
@@ -2492,11 +2496,13 @@ mymain(void)
c1c534
     DO_TEST("arm-virt-virtio",
c1c534
             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
c1c534
             QEMU_CAPS_DEVICE_VIRTIO_MMIO,
c1c534
+            QEMU_CAPS_DEVICE_PL011,
c1c534
             QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
c1c534
 
c1c534
     DO_TEST("aarch64-virt-virtio",
c1c534
             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
c1c534
             QEMU_CAPS_DEVICE_VIRTIO_MMIO,
c1c534
+            QEMU_CAPS_DEVICE_PL011,
c1c534
             QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
c1c534
 
c1c534
     /* Demonstrates the virtio-pci default... namely that there isn't any!
c1c534
@@ -2512,6 +2518,7 @@ mymain(void)
c1c534
             QEMU_CAPS_PCI_MULTIFUNCTION,
c1c534
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
c1c534
             QEMU_CAPS_DEVICE_IOH3420,
c1c534
+            QEMU_CAPS_DEVICE_PL011,
c1c534
             QEMU_CAPS_VIRTIO_SCSI);
c1c534
     DO_TEST("aarch64-virt-2.6-virtio-pci-default",
c1c534
             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
c1c534
@@ -2520,6 +2527,7 @@ mymain(void)
c1c534
             QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
c1c534
             QEMU_CAPS_PCI_MULTIFUNCTION,
c1c534
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
c1c534
+            QEMU_CAPS_DEVICE_PL011,
c1c534
             QEMU_CAPS_DEVICE_IOH3420);
c1c534
     /* Example of using virtio-pci with no explicit PCI controller
c1c534
        but with manual PCI addresses */
c1c534
@@ -2638,6 +2646,7 @@ mymain(void)
c1c534
             QEMU_CAPS_MACH_VIRT_GIC_VERSION);
c1c534
     DO_TEST("aarch64-kvm-32-on-64",
c1c534
             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
c1c534
+            QEMU_CAPS_DEVICE_PL011,
c1c534
             QEMU_CAPS_KVM, QEMU_CAPS_CPU_AARCH64_OFF);
c1c534
     DO_TEST_FAILURE("aarch64-kvm-32-on-64",
c1c534
             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
c1c534
-- 
c1c534
2.15.1
c1c534