1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Stefan Reiter <s.reiter@proxmox.com>
3 Date: Wed, 1 Sep 2021 16:51:04 +0200
4 Subject: [PATCH] monitor/hmp: add support for flag argument with value
6 Adds support for the "-xS" parameter type, where "-x" denotes a flag
7 name and the "S" suffix indicates that this flag is supposed to take an
8 arbitrary string parameter.
10 These parameters are always optional, the entry in the qdict will be
11 omitted if the flag is not given.
13 Reviewed-by: Eric Blake <eblake@redhat.com>
14 Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
15 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
17 monitor/hmp.c | 17 ++++++++++++++++-
18 1 file changed, 16 insertions(+), 1 deletion(-)
20 diff --git a/monitor/hmp.c b/monitor/hmp.c
21 index d50c3124e1..a32dce7a35 100644
24 @@ -980,6 +980,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
32 @@ -1002,8 +1003,22 @@ static QDict *monitor_parse_arguments(Monitor *mon,
36 + } else if (*typestr == 'S') {
37 + /* has option with string value */
40 + while (qemu_isspace(*p)) {
43 + ret = get_str(buf, sizeof(buf), &p);
45 + monitor_printf(mon, "%s: value expected for -%c\n",
49 + qdict_put_str(qdict, key, buf);
52 + /* has boolean option */
54 qdict_put_bool(qdict, key, true);