aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2023-01-09 20:03:17 +0100
committerMarkus Armbruster <armbru@redhat.com>2023-01-19 13:30:01 +0100
commitf916a1751e735d3202a2dfc051d324a206831b69 (patch)
tree5ee453275013aebe078cc3eda7573c3acb5a2d75
parentf8f2e9a859a1450756972266b0d6f4c081e6486c (diff)
downloadqemu-f916a1751e735d3202a2dfc051d324a206831b69.zip
qemu-f916a1751e735d3202a2dfc051d324a206831b69.tar.gz
qemu-f916a1751e735d3202a2dfc051d324a206831b69.tar.bz2
ui: Factor out hmp_change_vnc(), and move to ui/ui-hmp-cmds.c
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20230109190321.1056914-14-armbru@redhat.com>
-rw-r--r--include/monitor/hmp.h5
-rw-r--r--monitor/hmp-cmds.c30
-rw-r--r--monitor/qmp-cmds.c2
-rw-r--r--ui/ui-hmp-cmds.c35
4 files changed, 42 insertions, 30 deletions
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index b228a40..df89eac 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -73,6 +73,11 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict);
void hmp_set_password(Monitor *mon, const QDict *qdict);
void hmp_expire_password(Monitor *mon, const QDict *qdict);
void hmp_change(Monitor *mon, const QDict *qdict);
+#ifdef CONFIG_VNC
+void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
+ const char *arg, const char *read_only, bool force,
+ Error **errp);
+#endif
void hmp_migrate(Monitor *mon, const QDict *qdict);
void hmp_device_add(Monitor *mon, const QDict *qdict);
void hmp_device_del(Monitor *mon, const QDict *qdict);
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 4340e71..1dba973 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -25,7 +25,7 @@
#include "qemu/timer.h"
#include "qemu/sockets.h"
#include "qemu/help_option.h"
-#include "monitor/monitor-internal.h"
+#include "monitor/monitor.h"
#include "qapi/error.h"
#include "qapi/clone-visitor.h"
#include "qapi/opts-visitor.h"
@@ -41,7 +41,6 @@
#include "qapi/qapi-commands-run-state.h"
#include "qapi/qapi-commands-stats.h"
#include "qapi/qapi-commands-tpm.h"
-#include "qapi/qapi-commands-ui.h"
#include "qapi/qapi-commands-virtio.h"
#include "qapi/qapi-visit-virtio.h"
#include "qapi/qapi-visit-net.h"
@@ -1075,15 +1074,6 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict)
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);
-}
-#endif
-
void hmp_change(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_str(qdict, "device");
@@ -1096,23 +1086,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
#ifdef CONFIG_VNC
if (strcmp(device, "vnc") == 0) {
- if (read_only) {
- error_setg(&err, "Parameter 'read-only-mode' is invalid for VNC");
- goto end;
- }
- 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, &err);
- }
- } else {
- error_setg(&err, "Expected 'password' after 'vnc'");
- goto end;
- }
+ hmp_change_vnc(mon, device, target, arg, read_only, force, &err);
} else
#endif
{
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index b5b7367..14f0f78 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -168,7 +168,7 @@ void qmp_add_client(const char *protocol, const char *fdname,
bool has_skipauth, bool skipauth, bool has_tls, bool tls,
Error **errp)
{
- static struct {
+ static const struct {
const char *name;
bool (*add_client)(int fd, bool has_skipauth, bool skipauth,
bool has_tls, bool tls, Error **errp);
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 <spice/enums.h>
#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");