]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/extra/0002-monitor-hmp-add-support-for-flag-argument-with-value.patch
17df26c1f91db152caa337404c65e84af57fb880
[pve-qemu.git] / debian / patches / extra / 0002-monitor-hmp-add-support-for-flag-argument-with-value.patch
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
5
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.
9
10 These parameters are always optional, the entry in the qdict will be
11 omitted if the flag is not given.
12
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>
16 ---
17 monitor/hmp.c | 17 ++++++++++++++++-
18 1 file changed, 16 insertions(+), 1 deletion(-)
19
20 diff --git a/monitor/hmp.c b/monitor/hmp.c
21 index d50c3124e1..a32dce7a35 100644
22 --- a/monitor/hmp.c
23 +++ b/monitor/hmp.c
24 @@ -980,6 +980,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
25 {
26 const char *tmp = p;
27 int skip_key = 0;
28 + int ret;
29 /* option */
30
31 c = *typestr++;
32 @@ -1002,8 +1003,22 @@ static QDict *monitor_parse_arguments(Monitor *mon,
33 }
34 if (skip_key) {
35 p = tmp;
36 + } else if (*typestr == 'S') {
37 + /* has option with string value */
38 + typestr++;
39 + tmp = p++;
40 + while (qemu_isspace(*p)) {
41 + p++;
42 + }
43 + ret = get_str(buf, sizeof(buf), &p);
44 + if (ret < 0) {
45 + monitor_printf(mon, "%s: value expected for -%c\n",
46 + cmd->name, *tmp);
47 + goto fail;
48 + }
49 + qdict_put_str(qdict, key, buf);
50 } else {
51 - /* has option */
52 + /* has boolean option */
53 p++;
54 qdict_put_bool(qdict, key, true);
55 }