qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC] spice-core: allow setting properties from QMP


From: Kevin Pouget
Subject: [Qemu-devel] [RFC] spice-core: allow setting properties from QMP
Date: Wed, 19 Jun 2019 14:30:42 +0200

Hello,

we're investigating the possibility to set some spice properties at
runtime, through the QMP interface, but we're not sure what's the best
way to proceed.
I've prepared the patch below, that adds a new QMP
command, but is there another way like with a QOM object, that could
reuse an existing command? I searched but couldn't find an easy/not
hacky way to create such objects ...

thanks,

Kevin

---

This patch allows setting spice properties from the QMP interface.

At the moment, only the 'video-codecs' property is supported.

Signed-off-by: Kevin Pouget <address@hidden>
---
 qapi/ui.json    | 19 +++++++++++++++++++
 ui/spice-core.c | 13 +++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/qapi/ui.json b/qapi/ui.json
index 59e412139a..5483a9c003 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -265,6 +265,25 @@
 { 'command': 'query-spice', 'returns': 'SpiceInfo',
   'if': 'defined(CONFIG_SPICE)' }

+##
+# @set-spice:
+#
+# Set Spice properties.
+# @property: the SPICE property to modify
+# @value: the new value to affect to this property
+#
+# Since: ...
+#
+# Example:
+#
+# -> { "execute": "set-spice", "arguments": { "property": "video-codecs",
+#                                             "value": 
"spice:mjpeg;gst:mjpeg;" } }
+# <- { "returns": {} }
+##
+{ 'command': 'set-spice',
+  'data': {'property': 'str', 'value': 'str'},
+  'if': 'defined(CONFIG_SPICE)' }
+
 ##
 # @SPICE_CONNECTED:
 #
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 2ffc3335f0..5408b16684 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -503,6 +503,19 @@ static QemuOptsList qemu_spice_opts = {
     },
 };

+void qmp_set_spice(const char *property, const char *value, Error **errp) {
+    if (strcmp(property, "video-codecs") == 0) {
+        int invalid_codecs = spice_server_set_video_codecs(spice_server, 
value);
+
+        if (invalid_codecs) {
+            error_setg(errp, "Found %d invalic codecs while setting "
+                       "the property %s=%s\n", invalid_codecs, property, 
value);
+        }
+    } else {
+        error_setg(errp, "Setting an unknown spice property (%s=%s)\n", 
property, value);
+    }
+}
+
 SpiceInfo *qmp_query_spice(Error **errp)
 {
     QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
--
2.21.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]