aboutsummaryrefslogtreecommitdiff
path: root/monitor/hmp-cmds.c
diff options
context:
space:
mode:
authorStefan Reiter <s.reiter@proxmox.com>2022-02-25 09:49:48 +0100
committerDr. David Alan Gilbert <dgilbert@redhat.com>2022-03-02 18:12:40 +0000
commit7277db9103bc82a79cdd5db633560d2638fbfc33 (patch)
tree8719ddaa443bebcf0502e53f41fe4cf02a2b9b62 /monitor/hmp-cmds.c
parent26fcd766179e8a27c4c6c702201bdb0fe60eb091 (diff)
downloadqemu-7277db9103bc82a79cdd5db633560d2638fbfc33.zip
qemu-7277db9103bc82a79cdd5db633560d2638fbfc33.tar.gz
qemu-7277db9103bc82a79cdd5db633560d2638fbfc33.tar.bz2
qapi/monitor: refactor set/expire_password with enums
'protocol' and 'connected' are better suited as enums than as strings, make use of that. No functional change intended. Suggested-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Reiter <s.reiter@proxmox.com> [FE: update "Since: " from 6.2 to 7.0 put 'keep' first in enum to ease use as a default] Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> Message-Id: <20220225084949.35746-3-f.ebner@proxmox.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'monitor/hmp-cmds.c')
-rw-r--r--monitor/hmp-cmds.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 8c384dc..ff78741 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1398,8 +1398,24 @@ void hmp_set_password(Monitor *mon, const QDict *qdict)
const char *password = qdict_get_str(qdict, "password");
const char *connected = qdict_get_try_str(qdict, "connected");
Error *err = NULL;
+ DisplayProtocol proto;
+ SetPasswordAction conn;
- qmp_set_password(protocol, password, !!connected, connected, &err);
+ proto = qapi_enum_parse(&DisplayProtocol_lookup, protocol,
+ DISPLAY_PROTOCOL_VNC, &err);
+ if (err) {
+ goto out;
+ }
+
+ conn = qapi_enum_parse(&SetPasswordAction_lookup, connected,
+ SET_PASSWORD_ACTION_KEEP, &err);
+ if (err) {
+ goto out;
+ }
+
+ qmp_set_password(proto, password, !!connected, conn, &err);
+
+out:
hmp_handle_error(mon, err);
}
@@ -1408,8 +1424,17 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
const char *protocol = qdict_get_str(qdict, "protocol");
const char *whenstr = qdict_get_str(qdict, "time");
Error *err = NULL;
+ DisplayProtocol proto;
+
+ proto = qapi_enum_parse(&DisplayProtocol_lookup, protocol,
+ DISPLAY_PROTOCOL_VNC, &err);
+ if (err) {
+ goto out;
+ }
- qmp_expire_password(protocol, whenstr, &err);
+ qmp_expire_password(proto, whenstr, &err);
+
+out:
hmp_handle_error(mon, err);
}