[virt-tools-list] [PATCH] virt-viewer: Avoid waiting if --attach is needed

Snir Sheriber ssheribe at redhat.com
Thu Jan 12 15:58:02 UTC 2017


Avoid waiting for domain to start if only direct libvirt connection
can be established (i.e remote connection is disabled) and --attach
was not set

Resolves: rhbz#1386630
---
 src/virt-viewer.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/virt-viewer.c b/src/virt-viewer.c
index 3a3b64d..7a03100 100644
--- a/src/virt-viewer.c
+++ b/src/virt-viewer.c
@@ -846,6 +846,21 @@ virt_viewer_initial_connect(VirtViewerApp *app, GError **error)
     }
 
     if (info.state == VIR_DOMAIN_SHUTOFF) {
+        /* If attach is disabled check whether remote connection can be established */
+        if(!virt_viewer_app_get_attach(app)) {
+            char *type,*xmldesc;
+
+            xmldesc = virDomainGetXMLDesc(dom, 0);
+            type = virt_viewer_extract_xpath_string(xmldesc, "string(/domain/devices/graphics/listen/@type)");
+            if(g_strcmp0(type,"none") == 0) {
+                    g_set_error_literal(&err, VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_FAILED,
+                                        _("Display can only be attached through libvirt with --attach"));
+                    free(xmldesc);
+                    goto cleanup;
+            }
+            free(xmldesc);
+        }
+
         virt_viewer_app_show_status(app, _("Waiting for guest domain to start"));
         goto wait;
     }
-- 
2.9.3




More information about the virt-tools-list mailing list