[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/2] qemu: Don't blindly assume VNC is supported



Currently its assumed that qemu always supports VNC, however it is
definitely possible to compile qemu without VNC support so we should at
the very least check for it and handle that correctly.
---
 src/qemu/qemu_capabilities.c |    5 ++++
 src/qemu/qemu_capabilities.h |    1 +
 src/qemu/qemu_command.c      |    6 +++++
 tests/qemuhelptest.c         |   48 ++++++++++++++++++++++++++++--------------
 tests/qemuxml2argvtest.c     |   10 ++++----
 5 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 7c391b3..9c7cbca 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -187,6 +187,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
               "reboot-timeout", /* 110 */
               "dump-guest-core",
               "seamless-migration",
+              "vnc",
     );
 
 struct _qemuCaps {
@@ -937,6 +938,8 @@ qemuCapsComputeCmdFlags(const char *help,
     }
     if (strstr(help, "-spice"))
         qemuCapsSet(caps, QEMU_CAPS_SPICE);
+    if (strstr(help, "-vnc"))
+        qemuCapsSet(caps, QEMU_CAPS_VNC);
     if (strstr(help, "seamless-migration="))
         qemuCapsSet(caps, QEMU_CAPS_SEAMLESS_MIGRATION);
     if (strstr(help, "boot=on"))
@@ -1881,6 +1884,8 @@ qemuCapsProbeQMPCommands(qemuCapsPtr caps,
             qemuCapsSet(caps, QEMU_CAPS_SPICE);
         else if (STREQ(name, "query-kvm"))
             qemuCapsSet(caps, QEMU_CAPS_KVM);
+        else if (STREQ(name, "query-vnc"))
+            qemuCapsSet(caps, QEMU_CAPS_VNC);
         VIR_FREE(name);
     }
     VIR_FREE(commands);
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 5d343c1..1dd6f0c 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -150,6 +150,7 @@ enum qemuCapsFlags {
     QEMU_CAPS_REBOOT_TIMEOUT     = 110, /* -boot reboot-timeout */
     QEMU_CAPS_DUMP_GUEST_CORE    = 111, /* dump-guest-core-parameter */
     QEMU_CAPS_SEAMLESS_MIGRATION = 112, /* seamless-migration for SPICE */
+    QEMU_CAPS_VNC                = 113, /* Is -vnc avail */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9096b3c..40c6417 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5847,6 +5847,12 @@ qemuBuildCommandLine(virConnectPtr conn,
         def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
         virBuffer opt = VIR_BUFFER_INITIALIZER;
 
+        if (!qemuCapsGet(caps, QEMU_CAPS_VNC)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("vnc graphics are not supported with this QEMU"));
+            goto error;
+        }
+
         if (def->graphics[0]->data.vnc.socket ||
             driver->vncAutoUnixSocket) {
 
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index df30ac1..b49c86d 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -147,7 +147,8 @@ mymain(void)
             QEMU_CAPS_NO_REBOOT,
             QEMU_CAPS_DRIVE,
             QEMU_CAPS_NAME,
-            QEMU_CAPS_NO_ACPI);
+            QEMU_CAPS_NO_ACPI,
+            QEMU_CAPS_VNC);
     DO_TEST("kvm-74", 9001, 1, 74,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -161,7 +162,8 @@ mymain(void)
             QEMU_CAPS_MEM_PATH,
             QEMU_CAPS_TDF,
             QEMU_CAPS_NO_SHUTDOWN,
-            QEMU_CAPS_NO_ACPI);
+            QEMU_CAPS_NO_ACPI,
+            QEMU_CAPS_VNC);
     DO_TEST("kvm-83-rhel56", 9001, 1, 83,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -189,7 +191,8 @@ mymain(void)
             QEMU_CAPS_SMBIOS_TYPE,
             QEMU_CAPS_SPICE,
             QEMU_CAPS_NO_SHUTDOWN,
-            QEMU_CAPS_NO_ACPI);
+            QEMU_CAPS_NO_ACPI,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-0.10.5", 10005, 0, 0,
             QEMU_CAPS_KQEMU,
             QEMU_CAPS_VNC_COLON,
@@ -210,7 +213,8 @@ mymain(void)
             QEMU_CAPS_NO_HPET,
             QEMU_CAPS_VGA_NONE,
             QEMU_CAPS_NO_SHUTDOWN,
-            QEMU_CAPS_NO_ACPI);
+            QEMU_CAPS_NO_ACPI,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-kvm-0.10.5", 10005, 1, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -237,7 +241,8 @@ mymain(void)
             QEMU_CAPS_NESTING,
             QEMU_CAPS_VGA_NONE,
             QEMU_CAPS_NO_SHUTDOWN,
-            QEMU_CAPS_NO_ACPI);
+            QEMU_CAPS_NO_ACPI,
+            QEMU_CAPS_VNC);
     DO_TEST("kvm-86", 10050, 1, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -264,7 +269,8 @@ mymain(void)
             QEMU_CAPS_SMBIOS_TYPE,
             QEMU_CAPS_VGA_NONE,
             QEMU_CAPS_NO_SHUTDOWN,
-            QEMU_CAPS_NO_ACPI);
+            QEMU_CAPS_NO_ACPI,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-kvm-0.11.0-rc2", 10092, 1, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -296,7 +302,8 @@ mymain(void)
             QEMU_CAPS_SMBIOS_TYPE,
             QEMU_CAPS_VGA_NONE,
             QEMU_CAPS_NO_SHUTDOWN,
-            QEMU_CAPS_NO_ACPI);
+            QEMU_CAPS_NO_ACPI,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-0.12.1", 12001, 0, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -331,7 +338,8 @@ mymain(void)
             QEMU_CAPS_PCI_ROMBAR,
             QEMU_CAPS_NO_ACPI,
             QEMU_CAPS_VIRTIO_BLK_SG_IO,
-            QEMU_CAPS_CPU_HOST);
+            QEMU_CAPS_CPU_HOST,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-kvm-0.12.1.2-rhel60", 12001, 1, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -382,7 +390,8 @@ mymain(void)
             QEMU_CAPS_PCI_ROMBAR,
             QEMU_CAPS_NO_ACPI,
             QEMU_CAPS_VIRTIO_BLK_SG_IO,
-            QEMU_CAPS_CPU_HOST);
+            QEMU_CAPS_CPU_HOST,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-kvm-0.12.3", 12003, 1, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -424,7 +433,8 @@ mymain(void)
             QEMU_CAPS_PCI_ROMBAR,
             QEMU_CAPS_NO_ACPI,
             QEMU_CAPS_VIRTIO_BLK_SG_IO,
-            QEMU_CAPS_CPU_HOST);
+            QEMU_CAPS_CPU_HOST,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-kvm-0.13.0", 13000, 1, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -484,7 +494,8 @@ mymain(void)
             QEMU_CAPS_NO_ACPI,
             QEMU_CAPS_VIRTIO_BLK_SG_IO,
             QEMU_CAPS_CPU_HOST,
-            QEMU_CAPS_SCSI_LSI);
+            QEMU_CAPS_SCSI_LSI,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-kvm-0.12.1.2-rhel61", 12001, 1, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -542,7 +553,8 @@ mymain(void)
             QEMU_CAPS_VIRTIO_BLK_SCSI,
             QEMU_CAPS_VIRTIO_BLK_SG_IO,
             QEMU_CAPS_CPU_HOST,
-            QEMU_CAPS_BLOCKIO);
+            QEMU_CAPS_BLOCKIO,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-kvm-0.12.1.2-rhel62-beta", 12001, 1, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -610,7 +622,8 @@ mymain(void)
             QEMU_CAPS_DRIVE_COPY_ON_READ,
             QEMU_CAPS_CPU_HOST,
             QEMU_CAPS_SCSI_CD,
-            QEMU_CAPS_BLOCKIO);
+            QEMU_CAPS_BLOCKIO,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-1.0", 1000000, 0, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -683,7 +696,8 @@ mymain(void)
             QEMU_CAPS_SCSI_CD,
             QEMU_CAPS_IDE_CD,
             QEMU_CAPS_SCSI_LSI,
-            QEMU_CAPS_BLOCKIO);
+            QEMU_CAPS_BLOCKIO,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-1.1.0", 1001000, 0, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -764,7 +778,8 @@ mymain(void)
             QEMU_CAPS_NETDEV_BRIDGE,
             QEMU_CAPS_SCSI_LSI,
             QEMU_CAPS_VIRTIO_SCSI_PCI,
-            QEMU_CAPS_BLOCKIO);
+            QEMU_CAPS_BLOCKIO,
+            QEMU_CAPS_VNC);
     DO_TEST("qemu-1.2.0", 1002000, 0, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -848,7 +863,8 @@ mymain(void)
             QEMU_CAPS_BLOCKIO,
             QEMU_CAPS_SCSI_DISK_WWN,
             QEMU_CAPS_SECCOMP_SANDBOX,
-            QEMU_CAPS_DUMP_GUEST_CORE);
+            QEMU_CAPS_DUMP_GUEST_CORE,
+            QEMU_CAPS_VNC);
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7403a8f..20b0b35 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -536,16 +536,16 @@ mymain(void)
             QEMU_CAPS_SCSI_BLOCK, QEMU_CAPS_VIRTIO_BLK_SG_IO,
             QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI_PCI);
 
-    DO_TEST("graphics-vnc", NONE);
-    DO_TEST("graphics-vnc-socket", NONE);
+    DO_TEST("graphics-vnc", QEMU_CAPS_VNC);
+    DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC);
 
     driver.vncSASL = 1;
     driver.vncSASLdir = strdup("/root/.sasl2");
-    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VGA);
+    DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_VGA);
     driver.vncTLS = 1;
     driver.vncTLSx509verify = 1;
     driver.vncTLSx509certdir = strdup("/etc/pki/tls/qemu");
-    DO_TEST("graphics-vnc-tls", NONE);
+    DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC);
     driver.vncSASL = driver.vncTLSx509verify = driver.vncTLS = 0;
     VIR_FREE(driver.vncSASLdir);
     VIR_FREE(driver.vncTLSx509certdir);
@@ -585,7 +585,7 @@ mymain(void)
 
     DO_TEST("input-usbmouse", NONE);
     DO_TEST("input-usbtablet", NONE);
-    DO_TEST("input-xen", QEMU_CAPS_DOMID, QEMU_CAPS_KVM);
+    DO_TEST("input-xen", QEMU_CAPS_DOMID, QEMU_CAPS_KVM, QEMU_CAPS_VNC);
     DO_TEST("misc-acpi", NONE);
     DO_TEST("misc-disable-s3", QEMU_CAPS_DISABLE_S3);
     DO_TEST("misc-disable-suspends", QEMU_CAPS_DISABLE_S3, QEMU_CAPS_DISABLE_S4);
-- 
1.7.8.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]