From: Markus Armbruster <armbru@redhat.com>
To: Fabian Ebner <f.ebner@proxmox.com>
Cc: w.bumiller@proxmox.com, berrange@redhat.com,
qemu-devel@nongnu.org, dgilbert@redhat.com,
marcandre.lureau@gmail.com, kraxel@redhat.com,
pbonzini@redhat.com, marcandre.lureau@redhat.com,
eblake@redhat.com, t.lamprecht@proxmox.com
Subject: Re: [PATCH v8 1/3] monitor/hmp: add support for flag argument with value
Date: Wed, 09 Feb 2022 15:12:11 +0100 [thread overview]
Message-ID: <87tud8f7t0.fsf@pond.sub.org> (raw)
In-Reply-To: <20220204101220.343526-2-f.ebner@proxmox.com> (Fabian Ebner's message of "Fri, 4 Feb 2022 11:12:18 +0100")
Fabian Ebner <f.ebner@proxmox.com> writes:
> From: Stefan Reiter <s.reiter@proxmox.com>
>
> 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.
>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
> [FE: fixed typo pointed out by Eric Blake]
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
> 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 b20737e63c..fd4f5866c7 100644
> --- a/monitor/hmp.c
> +++ b/monitor/hmp.c
> @@ -981,6 +981,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
> {
> const char *tmp = p;
> int skip_key = 0;
> + int ret;
> /* option */
>
> c = *typestr++;
> @@ -1003,11 +1004,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 3da3f86c6a..a4cb307c8a 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 a 'V', it
> + * specifies an optional string param (e.g. '-fV' allows '-f foo')
> *
> */
For what it's worth, getopt() uses ':' after the option character for
"takes an argument".
Happy to make that tweak in my tree. But see my review of PATCH 3
first.
next prev parent reply other threads:[~2022-02-09 14:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 10:12 [PATCH v8 0/3] VNC-related HMP/QMP fixes Fabian Ebner
2022-02-04 10:12 ` [PATCH v8 1/3] monitor/hmp: add support for flag argument with value Fabian Ebner
2022-02-09 14:12 ` Markus Armbruster [this message]
2022-02-24 9:17 ` Fabian Ebner
2022-02-24 10:04 ` Markus Armbruster
2022-02-24 11:30 ` Dr. David Alan Gilbert
2022-02-04 10:12 ` [PATCH v8 2/3] qapi/monitor: refactor set/expire_password with enums Fabian Ebner
2022-02-09 13:43 ` Markus Armbruster
2022-02-04 10:12 ` [PATCH v8 3/3] qapi/monitor: allow VNC display id in set/expire_password Fabian Ebner
2022-02-09 14:07 ` Markus Armbruster
2022-02-17 7:42 ` Fabian Ebner
2022-02-17 8:04 ` Markus Armbruster
2022-02-23 13:45 ` Dr. David Alan Gilbert
2022-03-02 11:39 ` [PATCH v8 0/3] VNC-related HMP/QMP fixes Dr. David Alan Gilbert
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=87tud8f7t0.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=f.ebner@proxmox.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=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.