mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: Fix domdisplay when domain only uses TLS
It's possible to create a domain which will only use a TLS port and will not have a non-TLS port set by using: <graphics type='spice' autoport='yes' defaultMode='secure'/> In such a setup, the 'graphics' node for the running domain will be: <graphics type='spice' tlsPort='5900' autoport='yes' listen='127.0.0.1' defaultMode='secure'> However, cmdDomDisplay loops over all the 'graphics' node, and it ignores nodes which don't have a 'port' attribute. This means 'virsh domdisplay' will only return an empty string for domains as the one above. This commit looks for both 'port' and 'tlsPort' before deciding to ignore a graphics node. It also makes sure 'port' is not printed when it's not set. This makes 'virsh domdisplay' return 'spice://127.0.0.1?tls-port=5900' for domains using only a TLS port. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
parent
9e03f313b8
commit
9976c4b9a6
@ -9074,6 +9074,20 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
/* If there is no port number for this type, then jump to the next
|
/* If there is no port number for this type, then jump to the next
|
||||||
* scheme */
|
* scheme */
|
||||||
if (tmp)
|
if (tmp)
|
||||||
|
port = 0;
|
||||||
|
|
||||||
|
/* Create our XPATH lookup for TLS Port (automatically skipped
|
||||||
|
* for unsupported schemes */
|
||||||
|
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "tlsPort") < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
/* Attempt to get the TLS port number */
|
||||||
|
tmp = virXPathInt(xpath, ctxt, &tls_port);
|
||||||
|
VIR_FREE(xpath);
|
||||||
|
if (tmp)
|
||||||
|
tls_port = 0;
|
||||||
|
|
||||||
|
if (!port && !tls_port)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Create our XPATH lookup for the current display's address */
|
/* Create our XPATH lookup for the current display's address */
|
||||||
@ -9104,17 +9118,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
port -= 5900;
|
port -= 5900;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create our XPATH lookup for TLS Port (automatically skipped
|
|
||||||
* for unsupported schemes */
|
|
||||||
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "tlsPort") < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* Attempt to get the TLS port number */
|
|
||||||
tmp = virXPathInt(xpath, ctxt, &tls_port);
|
|
||||||
VIR_FREE(xpath);
|
|
||||||
if (tmp)
|
|
||||||
tls_port = 0;
|
|
||||||
|
|
||||||
/* Build up the full URI, starting with the scheme */
|
/* Build up the full URI, starting with the scheme */
|
||||||
virBufferAsprintf(&buf, "%s://", scheme[iter]);
|
virBufferAsprintf(&buf, "%s://", scheme[iter]);
|
||||||
|
|
||||||
@ -9129,6 +9132,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virBufferAsprintf(&buf, "%s", listen_addr);
|
virBufferAsprintf(&buf, "%s", listen_addr);
|
||||||
|
|
||||||
/* Add the port */
|
/* Add the port */
|
||||||
|
if (port)
|
||||||
virBufferAsprintf(&buf, ":%d", port);
|
virBufferAsprintf(&buf, ":%d", port);
|
||||||
|
|
||||||
/* TLS Port */
|
/* TLS Port */
|
||||||
|
Loading…
Reference in New Issue
Block a user