提交 215b3ab4 编写于 作者: J Julio Faracco 提交者: Michal Privoznik

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=1336720Signed-off-by: NJulio Faracco <jcfaracco@gmail.com>
上级 bca4ec75
......@@ -10948,6 +10948,8 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
char *xpath = NULL;
char *listen_addr = NULL;
int port, tls_port = 0;
char *type_conn = NULL;
char *socket = NULL;
char *passwd = NULL;
char *output = NULL;
const char *scheme[] = { "vnc", "spice", "rdp", NULL };
......@@ -11008,9 +11010,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
if (tmp)
tls_port = 0;
if (!port && !tls_port)
continue;
/* Create our XPATH lookup for the current display's address */
if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@listen") < 0)
goto cleanup;
......@@ -11021,6 +11020,29 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
listen_addr = virXPathString(xpath, ctxt);
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) {
/* The subelement address - <listen address='xyz'/> -
* *should* have been automatically backfilled into its
......@@ -11035,11 +11057,9 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
listen_addr = virXPathString(xpath, ctxt);
VIR_FREE(xpath);
}
} else {
/* If listen_addr is 0.0.0.0 or [::] we should try to parse URI and set
* listen_addr based on current URI. */
if (listen_addr) {
if (virSocketAddrParse(&addr, listen_addr, AF_UNSPEC) > 0 &&
virSocketAddrIsWildcard(&addr)) {
......@@ -11078,6 +11098,9 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
VIR_FREE(xpath);
/* Build up the full URI, starting with the scheme */
if (socket)
virBufferAsprintf(&buf, "%s+unix://", scheme[iter]);
else
virBufferAsprintf(&buf, "%s://", scheme[iter]);
/* 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);
/* Then host name or IP */
if (!listen_addr)
if (!listen_addr && !socket)
virBufferAddLit(&buf, "localhost");
else if (strchr(listen_addr, ':'))
else if (!socket && strchr(listen_addr, ':'))
virBufferAsprintf(&buf, "[%s]", listen_addr);
else if (socket)
virBufferAsprintf(&buf, "%s", socket);
else
virBufferAsprintf(&buf, "%s", listen_addr);
/* Free socket to prepare the pointer for the next iteration */
VIR_FREE(socket);
/* Add the port */
if (port) {
if (STREQ(scheme[iter], "vnc")) {
......@@ -11148,6 +11176,8 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
cleanup:
VIR_FREE(xpath);
VIR_FREE(type_conn);
VIR_FREE(socket);
VIR_FREE(passwd);
VIR_FREE(listen_addr);
VIR_FREE(output);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册