diff mbox series

[v5,3/3] qmp: add new qmp display-reload

Message ID 20210311105424.1370-4-changzihao1@huawei.com (mailing list archive)
State New, archived
Headers show
Series vnc: support reload x509 certificates | expand

Commit Message

Zihao Chang March 11, 2021, 10:54 a.m. UTC
This patch provides a new qmp to reload display configuration
without restart VM, but only reloading the vnc tls certificates
is implemented.
Example:
{"execute": "display-reload", "arguments":{"vnc-tls-certs": true}}

Signed-off-by: Zihao Chang <changzihao1@huawei.com>
---
 monitor/qmp-cmds.c | 13 +++++++++++++
 qapi/ui.json       | 19 +++++++++++++++++++
 2 files changed, 32 insertions(+)

Comments

Daniel P. Berrangé March 11, 2021, 11:18 a.m. UTC | #1
On Thu, Mar 11, 2021 at 06:54:24PM +0800, Zihao Chang wrote:
> This patch provides a new qmp to reload display configuration
> without restart VM, but only reloading the vnc tls certificates
> is implemented.
> Example:
> {"execute": "display-reload", "arguments":{"vnc-tls-certs": true}}
> 
> Signed-off-by: Zihao Chang <changzihao1@huawei.com>
> ---
>  monitor/qmp-cmds.c | 13 +++++++++++++
>  qapi/ui.json       | 19 +++++++++++++++++++
>  2 files changed, 32 insertions(+)
> 
> diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
> index c7df8c0ee268..0f791f974f30 100644
> --- a/monitor/qmp-cmds.c
> +++ b/monitor/qmp-cmds.c
> @@ -334,3 +334,16 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp)
>  
>      return mem_info;
>  }
> +
> +void qmp_display_reload(bool has_vnc_tls_certs, bool vnc_tls_certs,
> +                        Error **errp)
> +{
> +    Error *local_err = NULL;
> +
> +    if (has_vnc_tls_certs && vnc_tls_certs) {
> +        if (!vnc_display_reload_certs(NULL, &local_err)) {
> +            error_propagate(errp, local_err);
> +            return;
> +        }
> +    }
> +}
> diff --git a/qapi/ui.json b/qapi/ui.json
> index d08d72b43923..97b38aa1666e 100644
> --- a/qapi/ui.json
> +++ b/qapi/ui.json
> @@ -1179,3 +1179,22 @@
>  ##
>  { 'command': 'query-display-options',
>    'returns': 'DisplayOptions' }
> +
> +##
> +# @display-reload:
> +#
> +# Reload display configuration
> +#
> +# Returns: Nothing on success
> +#
> +# Since: 6.0
> +#
> +# Example:
> +#
> +# -> { "execute": "display-reload",
> +#      "arguments": { "vnc-tls-certs": true } }
> +# <- { "return": {} }
> +#
> +##
> +{ 'command': 'display-reload',
> +  'data': { '*vnc-tls-certs': 'bool' } }

I think best practice would be to make this a  discriminated union
Something like this:

   { 'enum': 'DisplayReloadType',
     'data': ['vnc'] }

   { 'struct': 'DisplayReloadOptionsVNC',
     'data': { '*tls-certs': 'bool' } }

   { 'union': 'DisplayReloadOptions',
     'base': {'type': 'DisplayReloadType'},
     'discriminator': 'type',
     'data': { 'vnc': 'DisplayReloadOptionsVNC' }}

   { 'command': 'display-reload',
     'data': 'DisplayReloadOptions' }


Regards,
Daniel
diff mbox series

Patch

diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index c7df8c0ee268..0f791f974f30 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -334,3 +334,16 @@  MemoryInfo *qmp_query_memory_size_summary(Error **errp)
 
     return mem_info;
 }
+
+void qmp_display_reload(bool has_vnc_tls_certs, bool vnc_tls_certs,
+                        Error **errp)
+{
+    Error *local_err = NULL;
+
+    if (has_vnc_tls_certs && vnc_tls_certs) {
+        if (!vnc_display_reload_certs(NULL, &local_err)) {
+            error_propagate(errp, local_err);
+            return;
+        }
+    }
+}
diff --git a/qapi/ui.json b/qapi/ui.json
index d08d72b43923..97b38aa1666e 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1179,3 +1179,22 @@ 
 ##
 { 'command': 'query-display-options',
   'returns': 'DisplayOptions' }
+
+##
+# @display-reload:
+#
+# Reload display configuration
+#
+# Returns: Nothing on success
+#
+# Since: 6.0
+#
+# Example:
+#
+# -> { "execute": "display-reload",
+#      "arguments": { "vnc-tls-certs": true } }
+# <- { "return": {} }
+#
+##
+{ 'command': 'display-reload',
+  'data': { '*vnc-tls-certs': 'bool' } }