]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Fix checking for reconnect conditions
authorPeter Krempa <pkrempa@redhat.com>
Mon, 2 Jan 2012 16:07:31 +0000 (17:07 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 2 Jan 2012 17:01:09 +0000 (18:01 +0100)
virshReportError() function frees the most recent error reported from
libvirt. Condition that checks if connection to the daemon was broken
during last command was then limited to check for SIGPIPE signal not
taking into account possible errors signalized without SIGPIPE.

This patch moves the check before the error is freed, to take into
account code that does not emit SIGPIPE while failing.

* tools/virsh.c: - move check for broken connection before error print.

tools/virsh.c

index e089f7b2f8c589b0348630959fbed473aa933c75..0bc05196b6ff44ef541ad936a37ffb54f5248070 100644 (file)
@@ -17041,18 +17041,20 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
         if (enable_timing)
             GETTIMEOFDAY(&after);
 
+        /* try to automatically catch disconnections */
+        if (!ret &&
+            ((last_error != NULL) &&
+             (((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
+               (last_error->domain == VIR_FROM_REMOTE)) ||
+              (last_error->code == VIR_ERR_RPC) ||
+              (last_error->code == VIR_ERR_NO_CONNECT) ||
+              (last_error->code == VIR_ERR_INVALID_CONN))))
+            disconnected++;
+
         if (!ret)
             virshReportError(ctl);
 
-        /* try to automatically catch disconnections */
-        if (!ret &&
-            ((disconnected != 0) ||
-             ((last_error != NULL) &&
-              (((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
-                (last_error->domain == VIR_FROM_REMOTE)) ||
-               (last_error->code == VIR_ERR_RPC) ||
-               (last_error->code == VIR_ERR_NO_CONNECT) ||
-               (last_error->code == VIR_ERR_INVALID_CONN)))))
+        if (!ret && disconnected != 0)
             vshReconnect(ctl);
 
         if (STREQ(cmd->def->name, "quit"))        /* hack ... */