summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2013-07-10 18:20:09 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2013-07-11 08:50:08 +0200
commit59ca6bd8a7eda9a0bf14d23f77d0a89f2bafbeaa (patch)
tree122acdfda36d88b454488d9c4122f6464e29110a /src
parentac4c71a3f00a5bd931bd41816606c391c11c5db1 (diff)
downloadvirt-viewer-59ca6bd8a7eda9a0bf14d23f77d0a89f2bafbeaa.tar.gz
virt-viewer-59ca6bd8a7eda9a0bf14d23f77d0a89f2bafbeaa.tar.xz
virt-viewer-59ca6bd8a7eda9a0bf14d23f77d0a89f2bafbeaa.zip
virt-viewer: Allow TLS-only SPICE connections
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
Diffstat (limited to 'src')
-rw-r--r--src/virt-viewer.c24
1 files 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)