On Thu, Apr 14, 2016 at 11:12:27AM +0300, Roman Bogorodskiy wrote:
Martin Kletzander wrote:
> 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);
The uri returned by virConnectGetURI needs to be freed, so there's no
need duplicating it.
>
> This would mean that next "connect" without parameters would connect to
> the new uri. Is that how you were trying that?
Basically, the issue I'm trying to solve is that:
1. I start libvirtd, virsh to it like:
sudo ./tools/virsh -d 1 -c
"bhyve:///system?socket=/var/run/libvirt/libvirt-sock"
2. I do some stuff and then I need to terminate libvirtd to change
something. I do that and I get:
virsh # error: Disconnected from bhyve:///system?socket=/var/run/libvirt/libvirt-sock due
to I/O error
3. I start the daemon again and in virsh I do something like "list".
That's what I get:
virsh # list
error: Failed to reconnect to the hypervisor
error: no valid connection
error: Failed to connect socket to '/usr/local/var/run/libvirt/libvirt-sock': No
such file or directory
virsh #
So it tries to use socket in /usr/local/var/run instead of just
/var/run and fails to connect. This is quite inconvenient.
It's weird that for me it does the expected. I don't see where would
the connname get freed as it should be set to what you passed in the
'-c' option. Anyway, I see we change the connname when you do 'connect
uri', so what you are doing in the patch is fine, sorry for the
confusion (apart from the leak mentioned above). I'll see where does
the conname get cleaned just so we're not covering another bug with this
code.
Roman Bogorodskiy
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list