From f916a1751e735d3202a2dfc051d324a206831b69 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 9 Jan 2023 20:03:17 +0100 Subject: ui: Factor out hmp_change_vnc(), and move to ui/ui-hmp-cmds.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230109190321.1056914-14-armbru@redhat.com> --- ui/ui-hmp-cmds.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c index 4af92f8..8ae9674 100644 --- a/ui/ui-hmp-cmds.c +++ b/ui/ui-hmp-cmds.c @@ -18,7 +18,8 @@ #include #endif #include "monitor/hmp.h" -#include "monitor/monitor.h" +#include "monitor/monitor-internal.h" +#include "qapi/error.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qdict.h" #include "qemu/cutils.h" @@ -311,6 +312,38 @@ out: hmp_handle_error(mon, err); } +#ifdef CONFIG_VNC +static void hmp_change_read_arg(void *opaque, const char *password, + void *readline_opaque) +{ + qmp_change_vnc_password(password, NULL); + monitor_read_command(opaque, 1); +} + +void hmp_change_vnc(Monitor *mon, const char *device, const char *target, + const char *arg, const char *read_only, bool force, + Error **errp) +{ + if (read_only) { + error_setg(errp, "Parameter 'read-only-mode' is invalid for VNC"); + return; + } + if (strcmp(target, "passwd") == 0 || + strcmp(target, "password") == 0) { + if (!arg) { + MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common); + monitor_read_password(hmp_mon, hmp_change_read_arg, NULL); + return; + } else { + qmp_change_vnc_password(arg, errp); + } + } else { + error_setg(errp, "Expected 'password' after 'vnc'"); + return; + } +} +#endif + void hmp_sendkey(Monitor *mon, const QDict *qdict) { const char *keys = qdict_get_str(qdict, "keys"); -- cgit v1.1