Bug 1164052 - virt-viewer cannot reconnect libvirtd connection via ssh after libvirtd restart
Summary: virt-viewer cannot reconnect libvirtd connection via ssh after libvirtd restart
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: virt-viewer
Version: 7.1
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: rc
: 7.2
Assignee: Virt Viewer Maint
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 1243228 1246395
Blocks: 1289971
TreeView+ depends on / blocked
 
Reported: 2014-11-14 01:31 UTC by CongDong
Modified: 2015-12-09 12:47 UTC (History)
10 users (show)

Fixed In Version: virt-viewer-2.0-4.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1289971 (view as bug list)
Environment:
Last Closed: 2015-11-19 07:35:05 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2211 0 normal SHIPPED_LIVE virt-viewer, spice-gtk, and libgovirt bug fix and enhancement update 2015-11-19 08:27:40 UTC

Description CongDong 2014-11-14 01:31:15 UTC
Description of problem:
Use virt-viewer connect a guest on remote host via ssh with --wait option,
if libvirtd restart, virt-viewer cannot reconnect it and no more debug
message pop out.

Version-Release number of selected component (if applicable):
100%

How reproducible:
virt-viewer-0.6.0-11.el7.x86_64

Steps to Reproduce:
1. install a spice guest on host A and shut it down
2. use virt-viewer to connect the guest on host B with --wait
# G_MESSAGES_DEBUG=all virt-viewer -c qemu+ssh://$host_A_ip/system vm1 --wait
3. restart libvirtd on host A
# service libvirtd restart


Actual results:
Step 3, After libvirtd restart, there is no more debug message pop out

Expected results:
virt-viewer should report that the libvirtd connection is restart like this:
(virt-viewer:16227): virt-viewer-DEBUG **: Got connection event 1
(virt-viewer:16227): virt-viewer-DEBUG: reconnect_poll: 0
(virt-viewer:16227): virt-viewer-DEBUG: Connect timer fired
(virt-viewer:16227): virt-viewer-DEBUG: initial connect
(virt-viewer:16227): virt-viewer-DEBUG: connecting ...

Additional info:

Comment 2 Christophe Fergeau 2014-11-14 10:23:03 UTC
NB: this is working fine with a connection to a local libvirtd instance.

Comment 3 Fabiano Fidêncio 2014-11-19 03:35:05 UTC
Patch sent to the ML[0]. However, I do not see this bug as a regression what makes me want to avoid having it in for 7.1.

[0]: https://www.redhat.com/archives/virt-tools-list/2014-November/msg00095.html

Comment 4 Fabiano Fidêncio 2014-11-19 12:07:03 UTC
(In reply to Fabiano Fidêncio from comment #3)
> Patch sent to the ML[0]. However, I do not see this bug as a regression what
> makes me want to avoid having it in for 7.1.
> 
> [0]:
> https://www.redhat.com/archives/virt-tools-list/2014-November/msg00095.html

According to Daniel:
"(...) virConnectRegisterCloseCallback should be sufficient to detect
when libvirtd goes away. If it isn't working for some cases plesae
do report a bug so we can fix it. Apps shouldn't have to play games
to infer when libvirtd went away."

So, changing this bug from POST to NEW and reassigning it to libvirt.

Comment 8 Pavel Hrdina 2015-06-25 12:47:28 UTC
Actually this is not libvirt bug.  Moving it back to virt-viewer.  This is because of implementation details of SSH protocol.  You need to set also keepAlive on the libvirt connection in order to receive the CloseCallback event.

This patch fixes the issue:

diff --git a/src/virt-viewer.c b/src/virt-viewer.c
index 637b9e4..851c83d 100644
--- a/src/virt-viewer.c
+++ b/src/virt-viewer.c
@@ -960,6 +960,10 @@ virt_viewer_connect(VirtViewerApp *app, GError **err)
         g_debug("Unable to register close callback on libvirt connection");
     }
 
+    if (virConnectSetKeepAlive(priv->conn, 5, 3) < 0) {
+        g_debug("Unable to set keep alive");
+    }
+
     return 0;
 }


But you would like to probably introduce a new option to virt-viewer to let the user to choose, whether he would like to use the keepAlive functionality and to let him chose his own interval and number of retries.

Comment 9 Fabiano Fidêncio 2015-06-26 10:33:18 UTC
(In reply to Pavel Hrdina from comment #8)
> Actually this is not libvirt bug.  Moving it back to virt-viewer.  This is
> because of implementation details of SSH protocol.  You need to set also
> keepAlive on the libvirt connection in order to receive the CloseCallback
> event.
> 
> This patch fixes the issue:
> 
> diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> index 637b9e4..851c83d 100644
> --- a/src/virt-viewer.c
> +++ b/src/virt-viewer.c
> @@ -960,6 +960,10 @@ virt_viewer_connect(VirtViewerApp *app, GError **err)
>          g_debug("Unable to register close callback on libvirt connection");
>      }
>  
> +    if (virConnectSetKeepAlive(priv->conn, 5, 3) < 0) {
> +        g_debug("Unable to set keep alive");
> +    }
> +
>      return 0;
>  }
> 
> 
> But you would like to probably introduce a new option to virt-viewer to let
> the user to choose, whether he would like to use the keepAlive functionality
> and to let him chose his own interval and number of retries.

Pavel, I'm not sure if this is something we would like to exposeto the users.
If no-one complains I will go for your patch.
May I ask you to send the patch to virt-tools-list? (Then I won't forget to add you as author and so on ...)

Comment 10 Fabiano Fidêncio 2015-06-30 08:27:57 UTC
(In reply to Fabiano Fidêncio from comment #9)
> (In reply to Pavel Hrdina from comment #8)
> > Actually this is not libvirt bug.  Moving it back to virt-viewer.  This is
> > because of implementation details of SSH protocol.  You need to set also
> > keepAlive on the libvirt connection in order to receive the CloseCallback
> > event.
> > 
> > This patch fixes the issue:
> > 
> > diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> > index 637b9e4..851c83d 100644
> > --- a/src/virt-viewer.c
> > +++ b/src/virt-viewer.c
> > @@ -960,6 +960,10 @@ virt_viewer_connect(VirtViewerApp *app, GError **err)
> >          g_debug("Unable to register close callback on libvirt connection");
> >      }
> >  
> > +    if (virConnectSetKeepAlive(priv->conn, 5, 3) < 0) {
> > +        g_debug("Unable to set keep alive");
> > +    }
> > +
> >      return 0;
> >  }
> > 
> > 
> > But you would like to probably introduce a new option to virt-viewer to let
> > the user to choose, whether he would like to use the keepAlive functionality
> > and to let him chose his own interval and number of retries.
> 
> Pavel, I'm not sure if this is something we would like to exposeto the users.
> If no-one complains I will go for your patch.
> May I ask you to send the patch to virt-tools-list? (Then I won't
> forget to add you as author and so on ...)

Okay, I sent the patch as it is, with Pavel as author.

Comment 22 Fabiano Fidêncio 2015-07-17 09:28:54 UTC
Moving it back to virt-viewer.

One important info that has been missing about how to reproduce this bug is that the remote host *MUST* be a RHEL-7 or newer.
Older versions of libvirt (in the remote host) don't present the keepalive problem,

Comment 23 Xiaodai Wang 2015-07-20 06:16:25 UTC
(In reply to Fabiano Fidêncio from comment #22)
> Moving it back to virt-viewer.
> 
> One important info that has been missing about how to reproduce this bug is
> that the remote host *MUST* be a RHEL-7 or newer.
> Older versions of libvirt (in the remote host) don't present the keepalive
> problem,

Yes, I can reproduce it virt-viewer-0.6.0-11.el7.x86_64 with a RHLE-7 remote host. And the test it with latest virt-viewer, the debug message can display after libvirtd restart.
(virt-viewer:19685): virt-viewer-DEBUG: reconnect_poll: 0
(virt-viewer:19685): virt-viewer-DEBUG: Cleanup of handle 0x1661c10
(virt-viewer:19685): virt-viewer-DEBUG: Cleanup of timeout 0x1665f30
(virt-viewer:19685): virt-viewer-DEBUG: Connect timer fired
(virt-viewer:19685): virt-viewer-DEBUG: initial connect
(virt-viewer:19685): virt-viewer-DEBUG: connecting ...
(virt-viewer:19685): virt-viewer-DEBUG: Add handle 10 1 0x1698de0
(virt-viewer:19685): virt-viewer-DEBUG: initial connect

So for the original issue, it's fixed.

Comment 25 Xiaodai Wang 2015-07-23 05:43:25 UTC
Since this issue has been fixed based on #Comment 23, So move it to verified.

Comment 27 errata-xmlrpc 2015-11-19 07:35:05 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2211.html


Note You need to log in before you can comment on or make changes to this bug.