Blame SOURCES/0031-virt-viewer-Support-newer-libvirt-xml-format.patch

140d58
From 2b271402aaeee7d7948493362bc6d152a7422856 Mon Sep 17 00:00:00 2001
140d58
From: Pavel Grunt <pgrunt@redhat.com>
140d58
Date: Fri, 7 Apr 2017 12:05:17 +0200
140d58
Subject: [PATCH virt-viewer 31/32] virt-viewer: Support newer libvirt xml
140d58
 format
140d58
To: virt-tools-list@redhat.com
140d58
140d58
Since libvirt 0.9.4 there is a new listen element which can be used
140d58
to specify address instead of using the attributes of graphics element.
140d58
140d58
Also add support for listen type socket - available for Qemu since
140d58
libvirt 2.0.0
140d58
140d58
Resolves: rhbz#1411765
140d58
140d58
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
140d58
(cherry picked from commit effa832ca5bd51b1f450f630e1fe3cd7deacb887)
140d58
---
140d58
 src/virt-viewer.c | 14 ++++++++++++--
140d58
 1 file changed, 12 insertions(+), 2 deletions(-)
140d58
140d58
diff --git a/src/virt-viewer.c b/src/virt-viewer.c
140d58
index 65c0546..fe10229 100644
140d58
--- a/src/virt-viewer.c
140d58
+++ b/src/virt-viewer.c
140d58
@@ -565,11 +565,21 @@ virt_viewer_extract_connect_info(VirtViewer *self,
140d58
     }
140d58
 
140d58
     if (gport || gtlsport) {
140d58
-        xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@listen)", type);
140d58
+        xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/listen/@address)", type);
140d58
         ghost = virt_viewer_extract_xpath_string(xmldesc, xpath);
140d58
+        if (ghost == NULL) { /* try old xml format - listen attribute in the graphics node */
140d58
+            g_free(xpath);
140d58
+            xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@listen)", type);
140d58
+            ghost = virt_viewer_extract_xpath_string(xmldesc, xpath);
140d58
+        }
140d58
     } else {
140d58
-        xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@socket)", type);
140d58
+        xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/listen/@socket)", type);
140d58
         unixsock = virt_viewer_extract_xpath_string(xmldesc, xpath);
140d58
+        if (unixsock == NULL) { /* try old xml format - socket attribute in the graphics node */
140d58
+            g_free(xpath);
140d58
+            xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@socket)", type);
140d58
+            unixsock = virt_viewer_extract_xpath_string(xmldesc, xpath);
140d58
+        }
140d58
     }
140d58
 
140d58
     if (ghost && gport) {
140d58
-- 
140d58
2.12.2
140d58