Before any virsh command can be executed, client connection to daemon
needs to be checked, i.e. first we try to reconnect if needed and then
check the connection usability which is connection type specific. This
handler is registered as client hook.
---
 tools/virsh.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/virsh.c b/tools/virsh.c
index 017a669..fcbd553 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -915,9 +915,17 @@ virshConnectionUsability(vshControl *ctl, virConnectPtr 
conn)
     return true;
 }
 
+static void *
+virshConnectionHandler(vshControl *ctl)
 {
+    virshControlPtr priv = ctl->privData;
 
+    if (!priv->conn || disconnected)
+        virshReconnect(ctl);
 
+    if (virshConnectionUsability(ctl, priv->conn))
+        return priv->conn;
+    return NULL;
 }
 
 /* ---------------
-- 
1.9.3

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

Reply via email to