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

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

 



On Thu, Apr 14, 2016 at 10:23:04AM +0300, Roman Bogorodskiy wrote:
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);

This would mean that next "connect" without parameters would connect to
the new uri.  Is that how you were trying that?  It's no how it should
behave IMHO.  I tried force-killing the daemon as well as letting the
client disconnect due to keepalive and in both cases virsh reconnected
to the last daemon it was connected to.  If you actually used 'connect'
after disconnection, you actually forced new connection to be made and
because no uri was supplied you got connected to the default uri.  With
your patch, I'm afraid the behaviour would change.  Also it would be
impossible to reconnect to the default uri unless you know it or printed
it out in the session.  Not that the last thing would be a great deal,
it's just a minor obstruction in usage I'd say.

+            VIR_FREE(uri);
+        }
+    }
+
    if (!priv->conn || disconnected)
        virshReconnect(ctl);

--
2.7.4

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

Attachment: signature.asc
Description: Digital signature

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