monitor: isolate HMP declarations in hmp.h
Also rename password & commands with hmp in the name, while at it. Other functions need larger changes which we will take care of next. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-30-9227de146347@redhat.com>
Marc-André Lureau committed
Aug 28, 2026 at 16:04 UTC
cd70266709383af01a24bdbadc5c42de9ef5d76a
27 files changed
+48
-30
accel/accel-system.c
+1
@@ -28,6 +28,7 @@
28
#include "qom/compat-properties.h"
29
#include "qapi/qapi-commands-accelerator.h"
30
#include "monitor/monitor.h"
31
+#include "monitor/hmp.h"
32
#include "hw/core/boards.h"
33
#include "hw/core/cpu.h"
34
#include "accel/accel-ops.h"
accel/tcg/monitor.c
+1
@@ -11,6 +11,7 @@
11
#include "qapi/type-helpers.h"
12
#include "qapi/qapi-commands-machine.h"
13
#include "monitor/monitor.h"
14
+#include "monitor/hmp.h"
15
#include "system/tcg.h"
16
#include "tcg/tcg.h"
17
#include "internal-common.h"
chardev/char.c
+1
-1
@@ -24,7 +24,7 @@
24
25
#include "qemu/osdep.h"
26
#include "qemu/cutils.h"
27
-#include "monitor/monitor.h"
27
+#include "monitor/hmp.h"
28
#include "monitor/qmp-helpers.h"
29
#include "qemu/config-file.h"
30
#include "qemu/error-report.h"
disas/disas-mon.c
+1
@@ -10,6 +10,7 @@
10
#include "system/memory.h"
11
#include "hw/core/cpu.h"
12
#include "monitor/monitor.h"
13
+#include "monitor/hmp.h"
14
15
/*
16
* Get LENGTH bytes from info's buffer, at target address memaddr.
gdbstub/system.c
+1
-1
@@ -29,7 +29,7 @@
29
#include "hw/core/boards.h"
30
#include "chardev/char.h"
31
#include "chardev/char-fe.h"
32
-#include "monitor/monitor.h"
32
+#include "monitor/hmp.h"
33
#include "trace.h"
34
#include "internals.h"
35
hw/char/virtio-serial-bus.c
+1
@@ -25,6 +25,7 @@
25
#include "qemu/module.h"
26
#include "migration/qemu-file-types.h"
27
#include "monitor/monitor.h"
28
+#include "monitor/hmp.h"
29
#include "qemu/error-report.h"
30
#include "qemu/queue.h"
31
#include "hw/core/qdev-properties.h"
hw/core/machine-hmp-cmds.c
-1
@@ -15,7 +15,6 @@
15
16
#include "qemu/osdep.h"
17
#include "monitor/hmp.h"
18
-#include "monitor/monitor.h"
18
#include "qapi/error.h"
19
#include "qapi/qapi-builtin-visit.h"
20
#include "qapi/qapi-commands-accelerator.h"
hw/core/sysbus.c
+1
@@ -21,6 +21,7 @@
21
#include "qapi/error.h"
22
#include "hw/core/sysbus.h"
23
#include "monitor/monitor.h"
24
+#include "monitor/hmp.h"
25
#include "system/address-spaces.h"
26
27
static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent);
hw/hexagon/hexagon_tlb.c
+1
@@ -12,6 +12,7 @@
12
#include "hw/core/resettable.h"
13
#include "migration/vmstate.h"
14
#include "monitor/monitor.h"
15
+#include "monitor/hmp.h"
16
#include "qapi/error.h"
17
#include "exec/page-protection.h"
18
#include "exec/target_page.h"
hw/misc/auxbus.c
+1
@@ -33,6 +33,7 @@
33
#include "hw/misc/auxbus.h"
34
#include "hw/i2c/i2c.h"
35
#include "monitor/monitor.h"
36
+#include "monitor/hmp.h"
37
#include "qapi/error.h"
38
39
#ifndef DEBUG_AUX
hw/usb/bus.c
+1
@@ -9,6 +9,7 @@
9
#include "system/system.h"
10
#include "migration/vmstate.h"
11
#include "monitor/monitor.h"
12
+#include "monitor/hmp.h"
13
#include "trace.h"
14
#include "qemu/cutils.h"
15
hw/usb/host-libusb.c
+1
@@ -48,6 +48,7 @@
48
#include "qapi/error.h"
49
#include "migration/vmstate.h"
50
#include "monitor/monitor.h"
51
+#include "monitor/hmp.h"
52
#include "qemu/error-report.h"
53
#include "qemu/main-loop.h"
54
#include "qemu/module.h"
hw/xen/xen-bus.c
+1
@@ -17,6 +17,7 @@
17
#include "hw/xen/xen-bus.h"
18
#include "hw/xen/xen-bus-helper.h"
19
#include "monitor/monitor.h"
20
+#include "monitor/hmp.h"
21
#include "qapi/error.h"
22
#include "qobject/qdict.h"
23
#include "system/system.h"
include/monitor/hmp.h
+21
@@ -18,6 +18,9 @@
18
#include "qapi/qapi-types-common.h"
19
#include "monitor/monitor.h"
20
21
+#define TYPE_MONITOR_HMP "monitor-hmp"
22
+OBJECT_DECLARE_TYPE(MonitorHMP, MonitorHMPClass, MONITOR_HMP);
23
+
24
#define HMP_STUB(cmd) \
25
void hmp_##cmd(Monitor *mon, const QDict *qdict) \
26
{ \
@@ -30,6 +33,24 @@ struct MonitorDef {
33
int64_t (*get_value)(Monitor *mon, const MonitorDef *md, int offset);
34
};
35
36
+void monitor_new_hmp(const char *id, const char *chardev_id,
37
+ bool use_readline, Error **errp);
38
+
39
+int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
40
+ G_GNUC_PRINTF(2, 0);
41
+int monitor_printf(Monitor *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
42
+void monitor_printc(Monitor *mon, int ch);
43
+
44
+void monitor_hmp_read_command(MonitorHMP *hmp, int show_prompt);
45
+int monitor_hmp_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
46
+ void *opaque);
47
+
48
+void monitor_register_hmp(const char *name, bool info,
49
+ void (*cmd)(Monitor *mon, const QDict *qdict));
50
+void monitor_register_hmp_info_hrt(const char *name,
51
+ HumanReadableText *(*handler)(Error **errp));
52
+
53
+
54
CPUArchState *mon_get_cpu_env(Monitor *mon);
55
CPUState *mon_get_cpu(Monitor *mon);
56
include/monitor/monitor.h
-18
@@ -10,9 +10,6 @@
10
#define TYPE_MONITOR "monitor"
11
OBJECT_DECLARE_TYPE(Monitor, MonitorClass, MONITOR);
12
13
-#define TYPE_MONITOR_HMP "monitor-hmp"
14
-OBJECT_DECLARE_TYPE(MonitorHMP, MonitorHMPClass, MONITOR_HMP);
15
-
13
#define TYPE_MONITOR_QMP "monitor-qmp"
14
OBJECT_DECLARE_TYPE(MonitorQMP, MonitorQMPClass, MONITOR_QMP);
15
@@ -30,8 +27,6 @@ void monitor_init_globals_core(void);
27
char *monitor_compat_id(void);
28
void monitor_new_qmp(const char *id, const char *chardev_id,
29
bool pretty, Error **errp);
33
-void monitor_new_hmp(const char *id, const char *chardev_id,
34
- bool use_readline, Error **errp);
30
int monitor_new(MonitorOptions *opts, bool allow_hmp, Error **errp);
31
int monitor_new_opts(QemuOpts *opts, Error **errp);
32
void monitor_cleanup(void);
@@ -43,28 +38,15 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp);
38
int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp);
39
40
int monitor_puts(Monitor *mon, const char *str);
46
-int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
47
- G_GNUC_PRINTF(2, 0);
48
-int monitor_printf(Monitor *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
49
-void monitor_printc(Monitor *mon, int ch);
41
void monitor_flush(Monitor *mon);
42
int monitor_get_cpu_index(Monitor *mon);
43
44
int monitor_puts_locked(Monitor *mon, const char *str);
45
void monitor_flush_locked(Monitor *mon);
46
56
-void monitor_read_command(MonitorHMP *hmp, int show_prompt);
57
-int monitor_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
58
- void *opaque);
59
-
47
AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
48
const char *opaque, Error **errp);
49
int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags, Error **errp);
50
void monitor_fdset_dup_fd_remove(int dup_fd);
51
65
-void monitor_register_hmp(const char *name, bool info,
66
- void (*cmd)(Monitor *mon, const QDict *qdict));
67
-void monitor_register_hmp_info_hrt(const char *name,
68
- HumanReadableText *(*handler)(Error **errp));
69
-
52
#endif /* MONITOR_H */
monitor/hmp.c
+4
-4
@@ -136,7 +136,7 @@ static void monitor_command_cb(void *opaque, const char *cmdline,
136
monitor_resume(&hmp->parent_obj);
137
}
138
139
-void monitor_read_command(MonitorHMP *hmp, int show_prompt)
139
+void monitor_hmp_read_command(MonitorHMP *hmp, int show_prompt)
140
{
141
if (!hmp->rs) {
142
return;
@@ -148,8 +148,8 @@ void monitor_read_command(MonitorHMP *hmp, int show_prompt)
148
}
149
}
150
151
-int monitor_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
152
- void *opaque)
151
+int monitor_hmp_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
152
+ void *opaque)
153
{
154
if (hmp->rs) {
155
readline_start(hmp->rs, "Password: ", 1, readline_func, opaque);
@@ -1647,7 +1647,7 @@ static void monitor_hmp_complete(UserCreatable *uc, Error **errp)
1647
monitor_readline_flush,
1648
hmp,
1649
monitor_find_completion);
1650
- monitor_read_command(hmp, 0);
1650
+ monitor_hmp_read_command(hmp, 0);
1651
}
1652
1653
qemu_chr_fe_set_handlers(&hmp->parent_obj.chr,
monitor/monitor-internal.h
+1
@@ -27,6 +27,7 @@
27
28
#include "chardev/char-fe.h"
29
#include "monitor/monitor.h"
30
+#include "monitor/hmp.h"
31
#include "qapi/qapi-emit-events.h"
32
#include "qapi/qapi-types-control.h"
33
#include "qapi/qapi-types-qom.h"
net/slirp.c
+1
@@ -36,6 +36,7 @@
36
#include "clients.h"
37
#include "hub.h"
38
#include "monitor/monitor.h"
39
+#include "monitor/hmp.h"
40
#include "qemu/error-report.h"
41
#include "qemu/sockets.h"
42
#include <libslirp.h>
stubs/monitor-core.c
+1
@@ -1,5 +1,6 @@
1
#include "qemu/osdep.h"
2
#include "monitor/monitor.h"
3
+#include "monitor/hmp.h"
4
#include "qapi/qapi-emit-events.h"
5
6
Monitor *monitor_cur(void)
stubs/monitor-internal.c
+1
-1
@@ -1,6 +1,6 @@
1
#include "qemu/osdep.h"
2
#include "qapi/error.h"
3
-#include "monitor/monitor.h"
3
+#include "monitor/hmp.h"
4
5
int monitor_get_fd(Monitor *mon, const char *name, Error **errp)
6
{
target/rx/disas.c
+1
@@ -19,6 +19,7 @@
19
#include "qemu/osdep.h"
20
#include "disas/dis-asm.h"
21
#include "qemu/bitops.h"
22
+#include "monitor/hmp.h"
23
#include "cpu.h"
24
25
typedef struct DisasContext {
tests/unit/test-util-sockets.c
+1
@@ -24,6 +24,7 @@
24
#include "qapi/error.h"
25
#include "socket-helpers.h"
26
#include "monitor/monitor.h"
27
+#include "monitor/hmp.h"
28
29
static void test_fd_is_socket_bad(void)
30
{
tools/qemu-vnc/stubs.c
+1
@@ -9,6 +9,7 @@
9
#include "system/runstate.h"
10
#include "hw/core/qdev.h"
11
#include "monitor/monitor.h"
12
+#include "monitor/hmp.h"
13
#include "migration/vmstate.h"
14
15
bool runstate_is_running(void)
trace/trace-hmp-cmds.c
-1
@@ -25,7 +25,6 @@
25
#include "qemu/osdep.h"
26
#include "monitor/hmp.h"
27
#include "monitor/hmp-completion.h"
28
-#include "monitor/monitor.h"
28
#include "qapi/error.h"
29
#include "qapi/qapi-commands-trace.h"
30
#include "qobject/qdict.h"
ui/ui-hmp-cmds.c
+2
-2
@@ -327,7 +327,7 @@ static void hmp_change_read_arg(void *opaque, const char *password,
327
void *readline_opaque)
328
{
329
qmp_change_vnc_password(password, NULL);
330
- monitor_read_command(opaque, 1);
330
+ monitor_hmp_read_command(opaque, 1);
331
}
332
333
void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
@@ -344,7 +344,7 @@ void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
344
}
345
if (!arg) {
346
MonitorHMP *hmp = MONITOR_HMP(mon);
347
- monitor_read_password(hmp, hmp_change_read_arg, NULL);
347
+ monitor_hmp_read_password(hmp, hmp_change_read_arg, NULL);
348
} else {
349
qmp_change_vnc_password(arg, errp);
350
}
util/error-report.c
+1
-1
@@ -11,7 +11,7 @@
11
*/
12
13
#include "qemu/osdep.h"
14
-#include "monitor/monitor.h"
14
+#include "monitor/hmp.h"
15
#include "qemu/error-report.h"
16
17
/*
util/qemu-print.c
+1
@@ -12,6 +12,7 @@
12
13
#include "qemu/osdep.h"
14
#include "monitor/monitor.h"
15
+#include "monitor/hmp.h"
16
#include "qemu/qemu-print.h"
17
18
/*