From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Stefan Reiter <s.reiter@proxmox.com>
Cc: "Wolfgang Bumiller" <w.bumiller@proxmox.com>,
"Markus Armbruster" <armbru@redhat.com>,
qemu-devel@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@gmail.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Thomas Lamprecht" <t.lamprecht@proxmox.com>
Subject: Re: [PATCH v7 1/4] monitor/hmp: add support for flag argument with value
Date: Tue, 26 Oct 2021 11:07:31 +0100 [thread overview]
Message-ID: <YXfTY2MGliDYXb7E@work-vm> (raw)
In-Reply-To: <20211021100135.4146766-2-s.reiter@proxmox.com>
* Stefan Reiter (s.reiter@proxmox.com) wrote:
> Adds support for the "-xV" parameter type, where "-x" denotes a flag
> name and the "V" suffix indicates that this flag is supposed to take an
> arbitrary string parameter.
>
> These parameters are always optional, the entry in the qdict will be
> omitted if the flag is not given.
>
> Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>
> v6:
> It wasn't possible to pass the 'connected' parameter to set_password, since the
> code to handle optional parameters couldn't live with a different param (not
> starting with '-') coming up instead - fix that by advancing over the 'value
> flag' modifier in case `*p != '-'`.
>
> Also change the modifier to 'V' instead of 'S' so it can be distinguished from
> an actual trailing 'S' type param.
>
> Discovered in testing. I dropped Eric's R-b due to the code change.
>
> monitor/hmp.c | 19 ++++++++++++++++++-
> monitor/monitor-internal.h | 3 ++-
> 2 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/monitor/hmp.c b/monitor/hmp.c
> index d50c3124e1..899e0c990f 100644
> --- a/monitor/hmp.c
> +++ b/monitor/hmp.c
> @@ -980,6 +980,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
> {
> const char *tmp = p;
> int skip_key = 0;
> + int ret;
> /* option */
>
> c = *typestr++;
> @@ -1002,11 +1003,27 @@ static QDict *monitor_parse_arguments(Monitor *mon,
> }
> if (skip_key) {
> p = tmp;
> + } else if (*typestr == 'V') {
> + /* has option with string value */
> + typestr++;
> + tmp = p++;
> + while (qemu_isspace(*p)) {
> + p++;
> + }
> + ret = get_str(buf, sizeof(buf), &p);
> + if (ret < 0) {
> + monitor_printf(mon, "%s: value expected for -%c\n",
> + cmd->name, *tmp);
> + goto fail;
> + }
> + qdict_put_str(qdict, key, buf);
> } else {
> - /* has option */
> + /* has boolean option */
> p++;
> qdict_put_bool(qdict, key, true);
> }
> + } else if (*typestr == 'V') {
> + typestr++;
> }
> }
> break;
> diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
> index 9c3a09cb01..9e708b329d 100644
> --- a/monitor/monitor-internal.h
> +++ b/monitor/monitor-internal.h
> @@ -63,7 +63,8 @@
> * '.' other form of optional type (for 'i' and 'l')
> * 'b' boolean
> * user mode accepts "on" or "off"
> - * '-' optional parameter (eg. '-f')
> + * '-' optional parameter (eg. '-f'); if followed by an 'V', it
> + * specifies an optional string param (e.g. '-fV' allows '-f foo')
> *
> */
>
> --
> 2.30.2
>
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2021-10-26 10:08 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 10:01 [PATCH v7 0/4] VNC-related HMP/QMP fixes Stefan Reiter
2021-10-21 10:01 ` [PATCH v7 1/4] monitor/hmp: add support for flag argument with value Stefan Reiter
2021-10-26 10:07 ` Dr. David Alan Gilbert [this message]
2021-10-29 19:51 ` Eric Blake
2021-10-21 10:01 ` [PATCH v7 2/4] qapi/monitor: refactor set/expire_password with enums Stefan Reiter
2022-01-20 13:32 ` Fabian Ebner
2022-01-20 15:28 ` Markus Armbruster
2021-10-21 10:01 ` [PATCH v7 3/4] qapi/monitor: allow VNC display id in set/expire_password Stefan Reiter
2021-10-21 10:38 ` Markus Armbruster
2021-10-26 10:12 ` Dr. David Alan Gilbert
2021-10-21 10:01 ` [PATCH v7 4/4] qapi/monitor: only allow 'keep' SetPasswordAction for VNC and deprecate Stefan Reiter
2022-01-31 16:07 ` Daniel P. Berrangé
2021-10-21 10:39 ` [PATCH v7 0/4] VNC-related HMP/QMP fixes Markus Armbruster
2021-10-26 10:18 ` Dr. David Alan Gilbert
2021-10-26 11:32 ` Markus Armbruster
2021-10-27 7:27 ` Gerd Hoffmann
2021-10-27 8:44 ` Dr. David Alan Gilbert
2021-10-28 5:25 ` Markus Armbruster
2021-10-28 19:37 ` Markus Armbruster
2022-01-11 14:18 ` Fabian Ebner
2022-01-13 15:52 ` Markus Armbruster
2022-01-21 13:20 ` Fabian Ebner
2022-01-21 15:54 ` Markus Armbruster
2022-01-24 13:50 ` Markus Armbruster
2022-01-24 13:50 ` Markus Armbruster
2022-01-25 15:06 ` Daniel P. Berrangé
2022-01-31 9:45 ` Fabian Ebner
2022-01-31 16:11 ` Daniel P. Berrangé
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=YXfTY2MGliDYXb7E@work-vm \
--to=dgilbert@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=s.reiter@proxmox.com \
--cc=t.lamprecht@proxmox.com \
--cc=w.bumiller@proxmox.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.