From: Eric Blake <eblake@redhat.com>
To: Kevin Pouget <kpouget@redhat.com>, qemu-devel@nongnu.org
Cc: Marc-Andre Lureau <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [RFC] spice-core: allow setting properties from QMP
Date: Wed, 19 Jun 2019 10:19:11 -0500 [thread overview]
Message-ID: <e9fcdbfd-cde2-fc91-ce1d-6bfe06d39c4f@redhat.com> (raw)
In-Reply-To: <20190619123042.4822-1-kpouget@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 2477 bytes --]
On 6/19/19 7:30 AM, Kevin Pouget wrote:
> 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 ...
>
A new command may be okay, however,
> +##
> +# @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)' }
letting 'property' be an open-coded string feels wrong. If you are only
going to accept a specific (limited) set of property names, then
'property' should be typed as an enum:
{ 'enum': 'SpiceProperties', 'data': [ 'video-codecs' ] }
{ 'command': 'set-spice', 'data': { 'property': 'SpiceProperties',
'value': 'str' } }
> +
> ##
> # @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 "
invalid
> + "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
>
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-06-19 15:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-19 12:30 [Qemu-devel] [RFC] spice-core: allow setting properties from QMP Kevin Pouget
2019-06-19 12:39 ` no-reply
2019-06-19 15:19 ` Eric Blake [this message]
2019-06-20 11:54 ` Kevin Pouget
2019-06-21 7:16 ` Frediano Ziglio
2019-06-21 7:56 ` Kevin Pouget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e9fcdbfd-cde2-fc91-ce1d-6bfe06d39c4f@redhat.com \
--to=eblake@redhat.com \
--cc=kpouget@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).