Add VNC WebSocket support

Adding support for new attribute 'websocket' in the '<graphics>'
element, the attribute value is the port to listen on with '-1'
meaning auto-allocation, '0' meaning no websockets.
This commit is contained in:
Martin Kletzander 2013-04-29 14:34:01 +02:00
parent 5606c7a867
commit f1ad8d2079
4 changed files with 28 additions and 0 deletions

View File

@ -3595,6 +3595,12 @@ qemu-kvm -net nic,model=? /dev/null
Rather than using listen/port, QEMU supports a Rather than using listen/port, QEMU supports a
<code>socket</code> attribute for listening on a unix <code>socket</code> attribute for listening on a unix
domain socket path.<span class="since">Since 0.8.8</span> domain socket path.<span class="since">Since 0.8.8</span>
For VNC WebSocket functionality, <code>websocket</code>
attribute may be used to specify port to listen on (with
-1 meaning auto-allocation and <code>autoport</code>
having no effect due to security reasons).
<span class="since">Since 1.0.6</span>
</dd> </dd>
<dt><code>"spice"</code></dt> <dt><code>"spice"</code></dt>
<dd> <dd>

View File

@ -2109,6 +2109,11 @@
</choice> </choice>
</attribute> </attribute>
</optional> </optional>
<optional>
<attribute name="websocket">
<ref name="PortNumber"/>
</attribute>
</optional>
<optional> <optional>
<attribute name="listen"> <attribute name="listen">
<ref name="addrIPorName"/> <ref name="addrIPorName"/>

View File

@ -7667,6 +7667,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
char *port = virXMLPropString(node, "port"); char *port = virXMLPropString(node, "port");
char *websocket = virXMLPropString(node, "websocket");
char *autoport; char *autoport;
if (port) { if (port) {
@ -7697,6 +7698,18 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
VIR_FREE(autoport); VIR_FREE(autoport);
} }
if (websocket) {
if (virStrToLong_i(websocket,
NULL, 10,
&def->data.vnc.websocket) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse vnc WebSocket port %s"), websocket);
VIR_FREE(websocket);
goto error;
}
VIR_FREE(websocket);
}
def->data.vnc.socket = virXMLPropString(node, "socket"); def->data.vnc.socket = virXMLPropString(node, "socket");
def->data.vnc.keymap = virXMLPropString(node, "keymap"); def->data.vnc.keymap = virXMLPropString(node, "keymap");
@ -15176,6 +15189,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, " autoport='%s'", virBufferAsprintf(buf, " autoport='%s'",
def->data.vnc.autoport ? "yes" : "no"); def->data.vnc.autoport ? "yes" : "no");
if (def->data.vnc.websocket)
virBufferAsprintf(buf, " websocket='%d'", def->data.vnc.websocket);
if (listenAddr) if (listenAddr)
virBufferAsprintf(buf, " listen='%s'", listenAddr); virBufferAsprintf(buf, " listen='%s'", listenAddr);
} }

View File

@ -1411,6 +1411,7 @@ struct _virDomainGraphicsDef {
union { union {
struct { struct {
int port; int port;
int websocket;
bool autoport; bool autoport;
char *keymap; char *keymap;
char *socket; char *socket;