[virt-tools-list] [PATCH] virt-viewer: Avoid waiting if --attach is needed

Daniel P. Berrange berrange at redhat.com
Thu Jan 12 16:01:25 UTC 2017


On Thu, Jan 12, 2017 at 05:58:02PM +0200, Snir Sheriber wrote:
> Avoid waiting for domain to start if only direct libvirt connection
> can be established (i.e remote connection is disabled) and --attach
> was not set
> 
> Resolves: rhbz#1386630
> ---
>  src/virt-viewer.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> index 3a3b64d..7a03100 100644
> --- a/src/virt-viewer.c
> +++ b/src/virt-viewer.c
> @@ -846,6 +846,21 @@ virt_viewer_initial_connect(VirtViewerApp *app, GError **error)
>      }
>  
>      if (info.state == VIR_DOMAIN_SHUTOFF) {
> +        /* If attach is disabled check whether remote connection can be established */
> +        if(!virt_viewer_app_get_attach(app)) {
> +            char *type,*xmldesc;
> +
> +            xmldesc = virDomainGetXMLDesc(dom, 0);
> +            type = virt_viewer_extract_xpath_string(xmldesc, "string(/domain/devices/graphics/listen/@type)");
> +            if(g_strcmp0(type,"none") == 0) {
> +                    g_set_error_literal(&err, VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_FAILED,
> +                                        _("Display can only be attached through libvirt with --attach"));
> +                    free(xmldesc);
> +                    goto cleanup;
> +            }
> +            free(xmldesc);
> +        }
> +
>          virt_viewer_app_show_status(app, _("Waiting for guest domain to start"));
>          goto wait;
>      }

This is wrong. The guest XML may change at the time it starts, so doing
this premature check on the inactive XML may lead us to incorrectly
report an error


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|




More information about the virt-tools-list mailing list