[virt-tools-list] [PATCH] virt-viewer: ensure we close when seeing domain stop event

Fabiano Fidêncio fabiano at fidencio.org
Tue Jul 12 10:44:40 UTC 2016


On Tue, Jul 12, 2016 at 12:29 PM, Daniel P. Berrange
<berrange at redhat.com> wrote:
> Normally virt-viewer relies on the VNC/SPICE widget seeing
> an EOF on its underlying connection to detect when the
> session is closed.
>
> When tunnelling to a remote guest over SSH though, this
> EOF can be delayed for a very long time, leaving a dead
> session open.
>
> This can be seen with
>
>    virt-viewer -c qemu+ssh://remotehost/system guestname
>
> when on the remote shell run
>
>    virsh destroy guestname
>
> and notice that virt-viewer does not see the shutdown
> immediately.
>
> When we get a domain stopped event we know the session
> should be dead, so forceably close it, if not already
> closed.
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  src/virt-viewer.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> index 173b0d3..4dfe8df 100644
> --- a/src/virt-viewer.c
> +++ b/src/virt-viewer.c
> @@ -664,6 +664,7 @@ virt_viewer_domain_event(virConnectPtr conn G_GNUC_UNUSED,
>  {
>      VirtViewer *self = opaque;
>      VirtViewerApp *app = VIRT_VIEWER_APP(self);
> +    VirtViewerSession *sess;
>      GError *error = NULL;
>
>      g_debug("Got domain event %d %d", event, detail);
> @@ -673,7 +674,9 @@ virt_viewer_domain_event(virConnectPtr conn G_GNUC_UNUSED,
>
>      switch (event) {
>      case VIR_DOMAIN_EVENT_STOPPED:
> -        //virt_viewer_deactivate(self);
> +        sess = virt_viewer_app_get_session(app);
> +        if (sess != NULL)
> +            virt_viewer_session_close(sess);
>          break;
>
>      case VIR_DOMAIN_EVENT_STARTED:
> --
> 2.7.4
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list

Please, use session instead of sess.
ACK with the change.

Acked-by: Fabiano Fidêncio <fidencio at redhat.com>

-- 
Fabiano Fidêncio




More information about the virt-tools-list mailing list