[libvirt] [PATCH] virsh: use the same connection URI for reconnect

Roman Bogorodskiy bogorodskiy at gmail.com
Thu Apr 14 07:23:04 UTC 2016


When for some reason virsh looses connection and then tries to
reconnection, it uses the default URI instead of the one that was used
for the previous connection it got disconnected from.

In order to make it reconnect using the same URI, copy URI of the
current (disconnected) connection to vshControl 'connname' attribute.
---
 tools/virsh.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/virsh.c b/tools/virsh.c
index 5a61189..07097aa 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -359,6 +359,14 @@ virshConnectionHandler(vshControl *ctl)
 {
     virshControlPtr priv = ctl->privData;
 
+    if (disconnected && priv->conn) {
+        if (!ctl->connname) {
+            char *uri = virConnectGetURI(priv->conn);
+            ctl->connname = vshStrdup(ctl, uri);
+            VIR_FREE(uri);
+        }
+    }
+
     if (!priv->conn || disconnected)
         virshReconnect(ctl);
 
-- 
2.7.4




More information about the libvir-list mailing list