]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add VNC WebSocket support
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 29 Apr 2013 12:34:01 +0000 (14:34 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 15 May 2013 07:38:56 +0000 (09:38 +0200)
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.

docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h

index df772b5322f9863b8f0b61744552ee5fee19e302..8852d7d586b1df3b7a4052f8c865338d1f8f2971 100644 (file)
@@ -3595,6 +3595,12 @@ 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 and <code>autoport</code>
+            having no effect due to security reasons).
+            <span class="since">Since 1.0.6</span>
           </dd>
           <dt><code>"spice"</code></dt>
           <dd>
index b40cb9008dec449504668deda3231834a90cd821..414fd727dbe6a7d0638072e3a15c6d725b67d3b6 100644 (file)
                   </choice>
                 </attribute>
               </optional>
+              <optional>
+                <attribute name="websocket">
+                  <ref name="PortNumber"/>
+                </attribute>
+              </optional>
               <optional>
                 <attribute name="listen">
                   <ref name="addrIPorName"/>
index 2ab1bf8266d066de777dbfd4516c7c0a692c4d28..91f3b3168f487dd4ee7566f205338a86e1aee54d 100644 (file)
@@ -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");
 
@@ -15176,6 +15189,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);
         }
index 11511114a3a0ff5be5b9495a96fbf9f37d73d35f..8d4b8683932d07a3126126829f6f05856ad5b0f0 100644 (file)
@@ -1411,6 +1411,7 @@ struct _virDomainGraphicsDef {
     union {
         struct {
             int port;
+            int websocket;
             bool autoport;
             char *keymap;
             char *socket;