[virt-tools-list] [PATCH 1/2] Do not show a display when virt-viewer --direct fails

Fabiano Fidêncio fidencio at redhat.com
Wed Mar 25 14:54:08 UTC 2015


When --direct fails the expected behavior is to report an error and
close the dialog, instead of the current behavior, that shows a dialog
and waits for the guest to connect.

Related to: https://bugzilla.redhat.com/show_bug.cgi?id=1085216
---
 src/virt-viewer.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/virt-viewer.c b/src/virt-viewer.c
index e83898b..68dc148 100644
--- a/src/virt-viewer.c
+++ b/src/virt-viewer.c
@@ -474,8 +474,19 @@ virt_viewer_extract_connect_info(VirtViewer *self,
     if (!virt_viewer_is_reachable(ghost, transport, host, direct)) {
         g_debug("graphics listen '%s' is not reachable from this machine",
                 ghost ? ghost : "");
-        virt_viewer_app_simple_message_dialog(app, _("Guest '%s' is not reachable"),
-                                              priv->domkey);
+        if (!direct) {
+            /*
+             * The distinction made between virt-viewer launched with
+             * '--direct' consists in:
+             * 1) virt_viewer_is_reachable() fails: Reporting an error
+             * to the user and closing the application.
+             * 2) virt_viewer_is_reachable() doesn't fail: Informing
+             * the user through a simple dialog and letting virt-viewer
+             * wait for the guest is the expected behavior.
+             */
+            virt_viewer_app_simple_message_dialog(app, _("Guest '%s' is not reachable"),
+                                                  priv->domkey);
+        }
         goto cleanup;
     }
 
@@ -757,8 +768,17 @@ virt_viewer_initial_connect(VirtViewerApp *app, GError **error)
         goto wait;
     }
 
-    if (!virt_viewer_update_display(self, dom))
+    if (!virt_viewer_update_display(self, dom)) {
+        if (virt_viewer_app_get_direct(app)) {
+            gchar *msg = g_strdup_printf(_("Guest '%s' is not reachable"), priv->domkey);
+            g_set_error_literal(&err, VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_FAILED, msg);
+            g_free(msg);
+            g_debug("%s", err->message);
+            goto cleanup;
+        }
+
         goto wait;
+    }
 
     ret = VIRT_VIEWER_APP_CLASS(virt_viewer_parent_class)->initial_connect(app, &err);
     if (ret || err)
-- 
2.3.3




More information about the virt-tools-list mailing list