mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-07 01:13:49 +00:00
tools: virsh: Adding unix socket support to 'domdisplay' command.
This commit adds the unix socket URL support to 'domdisplay' command. Before, even if an user was using unix socket to define a spice graphics, the command 'domdisplay' showed that the settings were not supported. Now, the command shows the proper URL: spice+unix://foo/bar.sock. Settings: <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> <listen type='address' address='127.0.0.1'/> </graphics> <graphics type='spice'> <listen type='socket' socket='/tmp/spice.sock'/> </graphics> Before: virsh # domdisplay --all Windows7 vnc://127.0.0.1:0 After: virsh # domdisplay --all Windows7 vnc://127.0.0.1:0 spice+unix:///tmp/spice.sock Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1336720 Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
This commit is contained in:
parent
bca4ec7560
commit
215b3ab4ef
@ -10948,6 +10948,8 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
char *xpath = NULL;
|
char *xpath = NULL;
|
||||||
char *listen_addr = NULL;
|
char *listen_addr = NULL;
|
||||||
int port, tls_port = 0;
|
int port, tls_port = 0;
|
||||||
|
char *type_conn = NULL;
|
||||||
|
char *socket = NULL;
|
||||||
char *passwd = NULL;
|
char *passwd = NULL;
|
||||||
char *output = NULL;
|
char *output = NULL;
|
||||||
const char *scheme[] = { "vnc", "spice", "rdp", NULL };
|
const char *scheme[] = { "vnc", "spice", "rdp", NULL };
|
||||||
@ -11008,9 +11010,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (tmp)
|
if (tmp)
|
||||||
tls_port = 0;
|
tls_port = 0;
|
||||||
|
|
||||||
if (!port && !tls_port)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Create our XPATH lookup for the current display's address */
|
/* Create our XPATH lookup for the current display's address */
|
||||||
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@listen") < 0)
|
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@listen") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -11021,6 +11020,29 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
listen_addr = virXPathString(xpath, ctxt);
|
listen_addr = virXPathString(xpath, ctxt);
|
||||||
VIR_FREE(xpath);
|
VIR_FREE(xpath);
|
||||||
|
|
||||||
|
/* Create our XPATH lookup for the current spice type. */
|
||||||
|
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "listen/@type") < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
/* Attempt to get the type of spice connection */
|
||||||
|
VIR_FREE(type_conn);
|
||||||
|
type_conn = virXPathString(xpath, ctxt);
|
||||||
|
VIR_FREE(xpath);
|
||||||
|
|
||||||
|
if (STREQ_NULLABLE(type_conn, "socket")) {
|
||||||
|
if (!socket) {
|
||||||
|
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "listen/@socket") < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
socket = virXPathString(xpath, ctxt);
|
||||||
|
|
||||||
|
VIR_FREE(xpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!port && !tls_port && !socket)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!listen_addr) {
|
if (!listen_addr) {
|
||||||
/* The subelement address - <listen address='xyz'/> -
|
/* The subelement address - <listen address='xyz'/> -
|
||||||
* *should* have been automatically backfilled into its
|
* *should* have been automatically backfilled into its
|
||||||
@ -11035,11 +11057,9 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
listen_addr = virXPathString(xpath, ctxt);
|
listen_addr = virXPathString(xpath, ctxt);
|
||||||
VIR_FREE(xpath);
|
VIR_FREE(xpath);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
/* If listen_addr is 0.0.0.0 or [::] we should try to parse URI and set
|
/* If listen_addr is 0.0.0.0 or [::] we should try to parse URI and set
|
||||||
* listen_addr based on current URI. */
|
* listen_addr based on current URI. */
|
||||||
if (listen_addr) {
|
|
||||||
if (virSocketAddrParse(&addr, listen_addr, AF_UNSPEC) > 0 &&
|
if (virSocketAddrParse(&addr, listen_addr, AF_UNSPEC) > 0 &&
|
||||||
virSocketAddrIsWildcard(&addr)) {
|
virSocketAddrIsWildcard(&addr)) {
|
||||||
|
|
||||||
@ -11078,6 +11098,9 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
VIR_FREE(xpath);
|
VIR_FREE(xpath);
|
||||||
|
|
||||||
/* Build up the full URI, starting with the scheme */
|
/* Build up the full URI, starting with the scheme */
|
||||||
|
if (socket)
|
||||||
|
virBufferAsprintf(&buf, "%s+unix://", scheme[iter]);
|
||||||
|
else
|
||||||
virBufferAsprintf(&buf, "%s://", scheme[iter]);
|
virBufferAsprintf(&buf, "%s://", scheme[iter]);
|
||||||
|
|
||||||
/* There is no user, so just append password if there's any */
|
/* There is no user, so just append password if there's any */
|
||||||
@ -11085,13 +11108,18 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virBufferAsprintf(&buf, ":%s@", passwd);
|
virBufferAsprintf(&buf, ":%s@", passwd);
|
||||||
|
|
||||||
/* Then host name or IP */
|
/* Then host name or IP */
|
||||||
if (!listen_addr)
|
if (!listen_addr && !socket)
|
||||||
virBufferAddLit(&buf, "localhost");
|
virBufferAddLit(&buf, "localhost");
|
||||||
else if (strchr(listen_addr, ':'))
|
else if (!socket && strchr(listen_addr, ':'))
|
||||||
virBufferAsprintf(&buf, "[%s]", listen_addr);
|
virBufferAsprintf(&buf, "[%s]", listen_addr);
|
||||||
|
else if (socket)
|
||||||
|
virBufferAsprintf(&buf, "%s", socket);
|
||||||
else
|
else
|
||||||
virBufferAsprintf(&buf, "%s", listen_addr);
|
virBufferAsprintf(&buf, "%s", listen_addr);
|
||||||
|
|
||||||
|
/* Free socket to prepare the pointer for the next iteration */
|
||||||
|
VIR_FREE(socket);
|
||||||
|
|
||||||
/* Add the port */
|
/* Add the port */
|
||||||
if (port) {
|
if (port) {
|
||||||
if (STREQ(scheme[iter], "vnc")) {
|
if (STREQ(scheme[iter], "vnc")) {
|
||||||
@ -11148,6 +11176,8 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(xpath);
|
VIR_FREE(xpath);
|
||||||
|
VIR_FREE(type_conn);
|
||||||
|
VIR_FREE(socket);
|
||||||
VIR_FREE(passwd);
|
VIR_FREE(passwd);
|
||||||
VIR_FREE(listen_addr);
|
VIR_FREE(listen_addr);
|
||||||
VIR_FREE(output);
|
VIR_FREE(output);
|
||||||
|
Loading…
Reference in New Issue
Block a user