[PATCH 12/13] virsh: Introduce connection handler

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

 



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@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]