render / rpms / libvirt

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