[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v3 1/2] 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.

Signed-off-by: Martin Kletzander <mkletzan redhat com>
---
 docs/formatdomain.html.in     |  5 +++++
 docs/schemas/domaincommon.rng |  5 +++++
 src/conf/domain_conf.c        | 16 ++++++++++++++++
 src/conf/domain_conf.h        |  1 +
 4 files changed, 27 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 9ade507..e5b69f8 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3589,6 +3589,11 @@ qemu-kvm -net nic,model=? /dev/null
             Rather than using listen/port, QEMU supports a
             <code>socket</code> attribute for listening on a unix
             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). <span class="since">Since
+            1.0.6</span>
           </dd>
           <dt><code>"spice"</code></dt>
           <dd>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 8004428..472bcd6 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2103,6 +2103,11 @@
                 </attribute>
               </optional>
               <optional>
+                <attribute name="websocket">
+                  <ref name="PortNumber"/>
+                </attribute>
+              </optional>
+              <optional>
                 <attribute name="listen">
                   <ref name="addrIPorName"/>
                 </attribute>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 862b997..7279827 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7667,6 +7667,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,

     if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
         char *port = virXMLPropString(node, "port");
+        char *websocket = virXMLPropString(node, "websocket");
         char *autoport;

         if (port) {
@@ -7697,6 +7698,18 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
             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.keymap = virXMLPropString(node, "keymap");

@@ -15173,6 +15186,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
             virBufferAsprintf(buf, " autoport='%s'",
                               def->data.vnc.autoport ? "yes" : "no");

+            if (def->data.vnc.websocket)
+                virBufferAsprintf(buf, " websocket='%d'", def->data.vnc.websocket);
+
             if (listenAddr)
                 virBufferAsprintf(buf, " listen='%s'", listenAddr);
         }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a9d3410..0d61579 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1411,6 +1411,7 @@ struct _virDomainGraphicsDef {
     union {
         struct {
             int port;
+            int websocket;
             bool autoport;
             char *keymap;
             char *socket;
-- 
1.8.2.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]