diff mbox series

[v2,2/3] qapi/ui: introduce change-vnc-listen

Message ID 20211222191731.467706-3-vsementsov@virtuozzo.com
State New
Headers show
Series qapi/ui: add change-vnc-listen | expand

Commit Message

Vladimir Sementsov-Ogievskiy Dec. 22, 2021, 7:17 p.m. UTC
Add command that can change addresses where VNC server listens for new
connections. Prior to 6.0 this functionality was available through
'change' qmp command which was deleted.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 docs/about/removed-features.rst |  3 ++-
 qapi/ui.json                    | 19 +++++++++++++++++++
 ui/vnc.c                        | 26 ++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletion(-)

Comments

Daniel P. Berrangé Jan. 4, 2022, 1:33 p.m. UTC | #1
On Wed, Dec 22, 2021 at 08:17:30PM +0100, Vladimir Sementsov-Ogievskiy wrote:
> Add command that can change addresses where VNC server listens for new
> connections. Prior to 6.0 this functionality was available through
> 'change' qmp command which was deleted.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  docs/about/removed-features.rst |  3 ++-
>  qapi/ui.json                    | 19 +++++++++++++++++++
>  ui/vnc.c                        | 26 ++++++++++++++++++++++++++
>  3 files changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst
> index d42c3341de..20e6901a82 100644
> --- a/docs/about/removed-features.rst
> +++ b/docs/about/removed-features.rst
> @@ -348,7 +348,8 @@ documentation of ``query-hotpluggable-cpus`` for additional details.
>  ``change`` (removed in 6.0)
>  '''''''''''''''''''''''''''
>  
> -Use ``blockdev-change-medium`` or ``change-vnc-password`` instead.
> +Use ``blockdev-change-medium`` or ``change-vnc-password`` or
> +``change-vnc-listen`` instead.
>  
>  ``query-events`` (removed in 6.0)
>  '''''''''''''''''''''''''''''''''
> diff --git a/qapi/ui.json b/qapi/ui.json
> index 2b4371da37..6a586edff1 100644
> --- a/qapi/ui.json
> +++ b/qapi/ui.json
> @@ -1334,3 +1334,22 @@
>  { 'command': 'display-reload',
>    'data': 'DisplayReloadOptions',
>    'boxed' : true }
> +
> +##
> +# @change-vnc-listen:
> +#
> +# Change set of addresses to listen for connections.
> +#
> +# @id: vnc display identifier
> +#
> +# @addresses: list of addresses for listen at
> +#
> +# @websockets: list of addresses to listen with websockets
> +#
> +# Since: 7.0
> +#
> +##
> +{ 'command': 'change-vnc-listen',
> +  'data': { 'id': 'str', 'addresses': ['SocketAddress'],
> +            '*websockets': ['SocketAddress'] },
> +  'if': 'CONFIG_VNC' }

I replied to your v1 before noticing this v2. So this is just to
point out that I suggested we could use 'display-reload' to update
the address rather than adding a new command.


Regards,
Daniel
diff mbox series

Patch

diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst
index d42c3341de..20e6901a82 100644
--- a/docs/about/removed-features.rst
+++ b/docs/about/removed-features.rst
@@ -348,7 +348,8 @@  documentation of ``query-hotpluggable-cpus`` for additional details.
 ``change`` (removed in 6.0)
 '''''''''''''''''''''''''''
 
-Use ``blockdev-change-medium`` or ``change-vnc-password`` instead.
+Use ``blockdev-change-medium`` or ``change-vnc-password`` or
+``change-vnc-listen`` instead.
 
 ``query-events`` (removed in 6.0)
 '''''''''''''''''''''''''''''''''
diff --git a/qapi/ui.json b/qapi/ui.json
index 2b4371da37..6a586edff1 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1334,3 +1334,22 @@ 
 { 'command': 'display-reload',
   'data': 'DisplayReloadOptions',
   'boxed' : true }
+
+##
+# @change-vnc-listen:
+#
+# Change set of addresses to listen for connections.
+#
+# @id: vnc display identifier
+#
+# @addresses: list of addresses for listen at
+#
+# @websockets: list of addresses to listen with websockets
+#
+# Since: 7.0
+#
+##
+{ 'command': 'change-vnc-listen',
+  'data': { 'id': 'str', 'addresses': ['SocketAddress'],
+            '*websockets': ['SocketAddress'] },
+  'if': 'CONFIG_VNC' }
diff --git a/ui/vnc.c b/ui/vnc.c
index e8430531c0..d7d0d255fc 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -4212,6 +4212,32 @@  fail:
     vnc_display_close(vd);
 }
 
+void qmp_change_vnc_listen(const char *id, SocketAddressList *addresses,
+                           bool has_websockets, SocketAddressList *websockets,
+                           Error **errp)
+{
+    VncDisplay *vd = vnc_display_find(id);
+
+    if (!vd) {
+        error_setg(errp, "VNC display '%s' not active", id);
+        return;
+    }
+
+    if (vd->listener) {
+        qio_net_listener_disconnect(vd->listener);
+        object_unref(OBJECT(vd->listener));
+    }
+    vd->listener = NULL;
+
+    if (vd->wslistener) {
+        qio_net_listener_disconnect(vd->wslistener);
+        object_unref(OBJECT(vd->wslistener));
+    }
+    vd->wslistener = NULL;
+
+    vnc_display_listen(vd, addresses, websockets, errp);
+}
+
 void vnc_display_add_client(const char *id, int csock, bool skipauth)
 {
     VncDisplay *vd = vnc_display_find(id);