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);
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.
Roman Bogorodskiy