c1c534
From a8befcda79640ae13c9787cb3be54ca2ee861077 Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <a8befcda79640ae13c9787cb3be54ca2ee861077@dist-git>
c1c534
From: Andrea Bolognani <abologna@redhat.com>
c1c534
Date: Wed, 29 Nov 2017 16:22:51 +0100
c1c534
Subject: [PATCH] qemu: Add QEMU_CAPS_DEVICE_SPAPR_VTY
c1c534
c1c534
Up until now we assumed the spapr-vty device would always be
c1c534
present, which is not very nice. Check for its availability before
c1c534
using it instead.
c1c534
c1c534
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
c1c534
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
c1c534
(cherry picked from commit 87eabeb17d637b753dbb1e63e417e25bbd0f7d61)
c1c534
c1c534
 Conflicts:
c1c534
	src/qemu/qemu_capabilities.c
c1c534
	src/qemu/qemu_capabilities.h
c1c534
	tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
c1c534
	tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
c1c534
c1c534
	Insert the new capability in the right place, in both
c1c534
	declarations and caps.
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1449265
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1511421
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1512929
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1512934
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/qemu/qemu_capabilities.c                     |  3 ++-
c1c534
 src/qemu/qemu_capabilities.h                     |  2 +-
c1c534
 src/qemu/qemu_command.c                          |  6 ++++++
c1c534
 tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml |  1 +
c1c534
 tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml  |  1 +
c1c534
 tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml  |  1 +
c1c534
 tests/qemuxml2argvtest.c                         | 12 ++++++++++++
c1c534
 7 files changed, 24 insertions(+), 2 deletions(-)
c1c534
c1c534
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
c1c534
index 2f41e076cb..0defa9a3e4 100644
c1c534
--- a/src/qemu/qemu_capabilities.c
c1c534
+++ b/src/qemu/qemu_capabilities.c
c1c534
@@ -445,7 +445,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
c1c534
               "virtio-blk.num-queues",
c1c534
               "machine.pseries.resize-hpt",
c1c534
 
c1c534
-
c1c534
+              "spapr-vty",
c1c534
 
c1c534
               /* 275 */
c1c534
 
c1c534
@@ -1679,6 +1679,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
c1c534
     { "pcie-root-port", QEMU_CAPS_DEVICE_PCIE_ROOT_PORT },
c1c534
     { "qemu-xhci", QEMU_CAPS_DEVICE_QEMU_XHCI },
c1c534
     { "spapr-pci-host-bridge", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE },
c1c534
+    { "spapr-vty", QEMU_CAPS_DEVICE_SPAPR_VTY },
c1c534
 };
c1c534
 
c1c534
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = {
c1c534
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
c1c534
index 60818daa1c..65b969a0ea 100644
c1c534
--- a/src/qemu/qemu_capabilities.h
c1c534
+++ b/src/qemu/qemu_capabilities.h
c1c534
@@ -431,7 +431,7 @@ typedef enum {
c1c534
     QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES, /* virtio-blk-*.num-queues */
c1c534
     QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT, /* -machine pseries,resize-hpt */
c1c534
 
c1c534
-
c1c534
+    QEMU_CAPS_DEVICE_SPAPR_VTY, /* -device spapr-vty */
c1c534
 
c1c534
     /* 275 */
c1c534
 
c1c534
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
c1c534
index fc7f54e81e..65b6a59d3f 100644
c1c534
--- a/src/qemu/qemu_command.c
c1c534
+++ b/src/qemu/qemu_command.c
c1c534
@@ -10308,6 +10308,12 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
c1c534
     if (qemuDomainIsPSeries(def)) {
c1c534
         if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
c1c534
             serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) {
c1c534
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_VTY)) {
c1c534
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
c1c534
+                               _("spapr-vty not supported in this QEMU binary"));
c1c534
+                goto error;
c1c534
+            }
c1c534
+
c1c534
             virBufferAsprintf(&cmd, "spapr-vty,chardev=char%s",
c1c534
                               serial->info.alias);
c1c534
         }
c1c534
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
c1c534
index c01777a5a3..c95025b41f 100644
c1c534
--- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
c1c534
+++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
c1c534
@@ -178,6 +178,7 @@
c1c534
   <flag name='vxhs'/>
c1c534
   <flag name='virtio-blk.num-queues'/>
c1c534
   <flag name='machine.pseries.resize-hpt'/>
c1c534
+  <flag name='spapr-vty'/>
c1c534
   <flag name='disk-share-rw'/>
c1c534
   <version>2010000</version>
c1c534
   <kvmVersion>0</kvmVersion>
c1c534
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
c1c534
index f1c9fc98a4..5ff8598fc8 100644
c1c534
--- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
c1c534
+++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml
c1c534
@@ -167,6 +167,7 @@
c1c534
   <flag name='vnc-multi-servers'/>
c1c534
   <flag name='chardev-reconnect'/>
c1c534
   <flag name='virtio-gpu.max_outputs'/>
c1c534
+  <flag name='spapr-vty'/>
c1c534
   <version>2006000</version>
c1c534
   <kvmVersion>0</kvmVersion>
c1c534
   <package></package>
c1c534
diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
c1c534
index e912211f40..3b70b1a407 100644
c1c534
--- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
c1c534
+++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml
c1c534
@@ -173,6 +173,7 @@
c1c534
   <flag name='chardev-reconnect'/>
c1c534
   <flag name='virtio-gpu.max_outputs'/>
c1c534
   <flag name='virtio-blk.num-queues'/>
c1c534
+  <flag name='spapr-vty'/>
c1c534
   <flag name='disk-share-rw'/>
c1c534
   <version>2009000</version>
c1c534
   <kvmVersion>0</kvmVersion>
c1c534
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
c1c534
index 4e981c9fab..70c72e4e64 100644
c1c534
--- a/tests/qemuxml2argvtest.c
c1c534
+++ b/tests/qemuxml2argvtest.c
c1c534
@@ -1756,50 +1756,62 @@ mymain(void)
c1c534
     DO_TEST_PARSE_ERROR("seclabel-device-duplicates", NONE);
c1c534
 
c1c534
     DO_TEST("pseries-basic",
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST("pseries-vio",
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST("pseries-usb-default",
c1c534
             QEMU_CAPS_NODEFCONFIG,
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_PIIX3_USB_UHCI,
c1c534
             QEMU_CAPS_PCI_OHCI,
c1c534
             QEMU_CAPS_PCI_MULTIFUNCTION);
c1c534
     DO_TEST("pseries-usb-multi",
c1c534
             QEMU_CAPS_NODEFCONFIG,
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_PIIX3_USB_UHCI,
c1c534
             QEMU_CAPS_PCI_OHCI,
c1c534
             QEMU_CAPS_PCI_MULTIFUNCTION);
c1c534
     DO_TEST("pseries-vio-user-assigned",
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST_PARSE_ERROR("pseries-vio-address-clash",
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST("pseries-nvram", QEMU_CAPS_DEVICE_NVRAM);
c1c534
     DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
c1c534
             QEMU_CAPS_DEVICE_USB_KBD,
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST("pseries-cpu-exact",
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST_PARSE_ERROR("pseries-no-parallel",
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
 
c1c534
     qemuTestSetHostArch(driver.caps, VIR_ARCH_PPC64);
c1c534
     DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST_FAILURE("pseries-cpu-compat-power9", QEMU_CAPS_KVM);
c1c534
 
c1c534
     qemuTestSetHostCPU(driver.caps, cpuPower9);
c1c534
     DO_TEST("pseries-cpu-compat-power9",
c1c534
             QEMU_CAPS_KVM,
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     qemuTestSetHostCPU(driver.caps, NULL);
c1c534
 
c1c534
     qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
c1c534
 
c1c534
     DO_TEST("pseries-panic-missing",
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST("pseries-panic-no-address",
c1c534
+            QEMU_CAPS_DEVICE_SPAPR_VTY,
c1c534
             QEMU_CAPS_NODEFCONFIG);
c1c534
     DO_TEST_FAILURE("pseries-panic-address",
c1c534
                     QEMU_CAPS_NODEFCONFIG);
c1c534
-- 
c1c534
2.15.1
c1c534