[virt-tools-list] [virt-viewer] Stop polling after reconnecting to libvirtd

Pavel Grunt pgrunt at redhat.com
Fri Oct 16 15:47:35 UTC 2015


Hi Christophe,

please, add the reference to the bug.

Ack.

Pavel

On Thu, 2015-10-15 at 17:40 +0200, Christophe Fergeau wrote:
> When the connection to libvirtd is lost, virt-viewer starts polling for
> libvirtd to come back. The polling mechanism is also used when
> connecting to very old libvirtd which don't support
> virConnectDomainEventDeregisterAny().
> 
> Currently, once we could reconnect to libvirtd, virt-viewer will keep
> polling, thus behaving as if the libvirtd connection does not support
> virConnectDomainEventDeregisterAny(). This commit makes sure we stop
> polling once the new libvirtd connection is established.
> ---
>  src/virt-viewer.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> index 851c83d..ca264c8 100644
> --- a/src/virt-viewer.c
> +++ b/src/virt-viewer.c
> @@ -151,6 +151,20 @@ virt_viewer_start_reconnect_poll(VirtViewer *self)
>  }
>  
>  static void
> +virt_viewer_stop_reconnect_poll(VirtViewer *self)
> +{
> +    VirtViewerPrivate *priv = self->priv;
> +
> +    g_debug("reconnect_poll: %d", priv->reconnect_poll);
> +
> +    if (priv->reconnect_poll == 0)
> +        return;
> +
> +    g_source_remove(priv->reconnect_poll);
> +    priv->reconnect_poll = 0;
> +}
> +
> +static void
>  virt_viewer_deactivated(VirtViewerApp *app, gboolean connect_error)
>  {
>      VirtViewer *self = VIRT_VIEWER(app);
> @@ -951,6 +965,10 @@ virt_viewer_connect(VirtViewerApp *app, GError **err)
>          !virt_viewer_app_is_active(app)) {
>          g_debug("No domain events, falling back to polling");
>          virt_viewer_start_reconnect_poll(self);
> +    } else {
> +        /* we may be polling if we lost the libvirt connection and are trying
> +         * to reconnect */
> +        virt_viewer_stop_reconnect_poll(self);
>      }
>  
>      if (virConnectRegisterCloseCallback(priv->conn,




More information about the virt-tools-list mailing list