On Wed, Jul 10, 2013 at 06:25:34PM +0200, Christophe Fergeau wrote: > When trying to connect to a VM which uses SPICE with only a tls port > set: > <graphics type='spice' tlsPort='-1' autoport='no' listen='0' keymap='en-us'> > <listen type='address' address='0'/> > </graphics> > the connection will fail with > "Cannot determine the graphic address for the guest spice" > > virt_viewer_extract_connect_info() indeed assumes that if no > non-TLS port is set, then this means we are trying to connect through > an already open socket, and otherwise the connection fails. > The presence of a TLS port is only checked when a non-TLS port is set. > > This commit reworks that logic to start by extracting both the non-TLS > and TLS ports (only when using SPICE for the latter), and by only trying > to parse the socket to use if none of these 2 ports is set > > This fixes rhbz#982840 > --- > src/virt-viewer.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/src/virt-viewer.c b/src/virt-viewer.c > index 951a42b..207c9ca 100644 > --- a/src/virt-viewer.c > +++ b/src/virt-viewer.c > @@ -335,24 +335,24 @@ virt_viewer_extract_connect_info(VirtViewer *self, > goto cleanup; > > xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@port)", type); > - if ((gport = virt_viewer_extract_xpath_string(xmldesc, xpath)) == NULL) { > - free(xpath); > + gport = virt_viewer_extract_xpath_string(xmldesc, xpath); > + g_free(xpath); > + if (g_str_equal(type, "spice")) { > + xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@tlsPort)", type); > + gtlsport = virt_viewer_extract_xpath_string(xmldesc, xpath); > + g_free(xpath); > + } > + > + if (gport || gtlsport) { > + xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@listen)", type); > + ghost = virt_viewer_extract_xpath_string(xmldesc, xpath); > + } else { > xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@socket)", type); > if ((unixsock = virt_viewer_extract_xpath_string(xmldesc, xpath)) == NULL) { > virt_viewer_app_simple_message_dialog(app, _("Cannot determine the graphic address for the guest %s"), > priv->domkey); > goto cleanup; > } > - } else { > - if (g_str_equal(type, "spice")) { > - free(xpath); > - xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@tlsPort)", type); > - gtlsport = virt_viewer_extract_xpath_string(xmldesc, xpath); > - } > - > - free(xpath); > - xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@listen)", type); > - ghost = virt_viewer_extract_xpath_string(xmldesc, xpath); > } > > if (ghost && gport) ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list