Re: [PATCH 1/2] Add VNC WebSocket support

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

 



On 29.04.2013 16:52, Martin Kletzander wrote:
> 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@xxxxxxxxxx>
> ---
>  docs/formatdomain.html.in     |  5 +++++
>  docs/schemas/domaincommon.rng |  5 +++++
>  src/conf/domain_conf.c        | 18 ++++++++++++++++++
>  src/conf/domain_conf.h        |  1 +
>  4 files changed, 29 insertions(+)
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index f325c3c..dfea434 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -3530,6 +3530,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 10596dc..59999a1 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -2071,6 +2071,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 a8b5dfd..026a737 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -7546,6 +7546,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) {
> @@ -7576,6 +7577,20 @@ 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"), port);
> +                VIR_FREE(websocket);
> +                goto error;
> +            }
> +            VIR_FREE(websocket);
> +        } else {
> +            def->data.vnc.websocket = 0;

This shouldn't be needed. Newly allocated memory is always set to zero.
But I see you just copy already existing pattern.

> +        }
> +
>          def->data.vnc.socket = virXMLPropString(node, "socket");
>          def->data.vnc.keymap = virXMLPropString(node, "keymap");
> 
> @@ -14980,6 +14995,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 3a0f23a..79deaf3 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -1401,6 +1401,7 @@ struct _virDomainGraphicsDef {
>      union {
>          struct {
>              int port;
> +            int websocket;
>              bool autoport;
>              char *keymap;
>              char *socket;
> 

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]