[PATCH 2/2] virsh: Really disconnect on keepalive timeout

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

 



Commit 676cb4f4e762b8682a06c6dab1f690fbcd939550 added client keepalive
support for virsh.  But because whenever the connection is closed, virsh
tries to reconnect, unless the disconnection happened with the reason
VIR_CONNECT_CLOSE_REASON_CLIENT.  Because of that, virsh kept trying to
reconnect even when the connection was closed due to keepalive.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1073506

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 tools/virsh.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index bcfa561..98d8d18 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -327,9 +327,14 @@ static int disconnected; /* we may have been disconnected */
 static void
 vshCatchDisconnect(virConnectPtr conn ATTRIBUTE_UNUSED,
                    int reason,
-                   void *opaque ATTRIBUTE_UNUSED)
+                   void *opaque)
 {
-    if (reason != VIR_CONNECT_CLOSE_REASON_CLIENT)
+    vshControl *ctl = opaque;
+
+    vshDebug(ctl, VSH_ERR_INFO, "Received disconnect with reason '%d'", reason);
+
+    if (reason != VIR_CONNECT_CLOSE_REASON_CLIENT &&
+        reason != VIR_CONNECT_CLOSE_REASON_KEEPALIVE)
         disconnected++;
 }

@@ -407,7 +412,7 @@ vshReconnect(vshControl *ctl)
             vshError(ctl, "%s", _("failed to connect to the hypervisor"));
     } else {
         if (virConnectRegisterCloseCallback(ctl->conn, vshCatchDisconnect,
-                                            NULL, NULL) < 0)
+                                            ctl, NULL) < 0)
             vshError(ctl, "%s", _("Unable to register disconnect callback"));
         if (connected)
             vshError(ctl, "%s", _("Reconnected to the hypervisor"));
@@ -484,7 +489,7 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
     }

     if (virConnectRegisterCloseCallback(ctl->conn, vshCatchDisconnect,
-                                        NULL, NULL) < 0)
+                                        ctl, NULL) < 0)
         vshError(ctl, "%s", _("Unable to register disconnect callback"));

     return true;
-- 
2.1.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]