Many files include "monitor/hmp.h", but few of them really need
the completion declarations: move them to a distinct header.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
MAINTAINERS | 1 +
include/monitor/hmp-completion.h | 40 ++++++++++++++++++++++++++++++++
include/monitor/hmp.h | 21 -----------------
chardev/char-hmp-cmds.c | 1 +
migration/migration-hmp-cmds.c | 1 +
monitor/hmp-target.c | 1 +
net/net-hmp-cmds.c | 1 +
qom/qom-hmp-cmds.c | 1 +
system/qdev-monitor.c | 1 +
system/runstate-hmp-cmds.c | 1 +
trace/trace-hmp-cmds.c | 1 +
ui/ui-hmp-cmds.c | 1 +
12 files changed, 50 insertions(+), 21 deletions(-)
create mode 100644 include/monitor/hmp-completion.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 48976138be7..969c3601beb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3409,6 +3409,7 @@ F: monitor/hmp*
F: hmp.h
F: hmp-commands*.hx
F: include/monitor/hmp.h
+F: include/monitor/hmp-completion.h
F: tests/qtest/test-hmp.c
F: include/qemu/qemu-print.h
F: util/qemu-print.c
diff --git a/include/monitor/hmp-completion.h b/include/monitor/hmp-completion.h
new file mode 100644
index 00000000000..dab21867dc9
--- /dev/null
+++ b/include/monitor/hmp-completion.h
@@ -0,0 +1,40 @@
+/*
+ * Human Monitor Completion handlers
+ *
+ * Copyright IBM, Corp. 2011
+ *
+ * Authors:
+ * Anthony Liguori <aliguori@us.ibm.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HMP_COMPLETION_H
+#define HMP_COMPLETION_H
+
+#include "qemu/readline.h"
+
+void object_add_completion(ReadLineState *rs, int nb_args, const char *str);
+void object_del_completion(ReadLineState *rs, int nb_args, const char *str);
+void device_add_completion(ReadLineState *rs, int nb_args, const char *str);
+void device_del_completion(ReadLineState *rs, int nb_args, const char *str);
+void sendkey_completion(ReadLineState *rs, int nb_args, const char *str);
+void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str);
+void chardev_add_completion(ReadLineState *rs, int nb_args, const char *str);
+void set_link_completion(ReadLineState *rs, int nb_args, const char *str);
+void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str);
+void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str);
+void ringbuf_write_completion(ReadLineState *rs, int nb_args, const char *str);
+void info_trace_events_completion(ReadLineState *rs, int nb_args,
+ const char *str);
+void trace_event_completion(ReadLineState *rs, int nb_args, const char *str);
+void watchdog_action_completion(ReadLineState *rs, int nb_args,
+ const char *str);
+void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
+ const char *str);
+void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
+ const char *str);
+void delvm_completion(ReadLineState *rs, int nb_args, const char *str);
+void loadvm_completion(ReadLineState *rs, int nb_args, const char *str);
+
+#endif
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index 26571d35e84..f17a50a3fed 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -126,27 +126,6 @@ void hmp_vhost_queue_status(Monitor *mon, const QDict *qdict);
void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict);
void hmp_xen_event_inject(Monitor *mon, const QDict *qdict);
void hmp_xen_event_list(Monitor *mon, const QDict *qdict);
-void object_add_completion(ReadLineState *rs, int nb_args, const char *str);
-void object_del_completion(ReadLineState *rs, int nb_args, const char *str);
-void device_add_completion(ReadLineState *rs, int nb_args, const char *str);
-void device_del_completion(ReadLineState *rs, int nb_args, const char *str);
-void sendkey_completion(ReadLineState *rs, int nb_args, const char *str);
-void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str);
-void chardev_add_completion(ReadLineState *rs, int nb_args, const char *str);
-void set_link_completion(ReadLineState *rs, int nb_args, const char *str);
-void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str);
-void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str);
-void ringbuf_write_completion(ReadLineState *rs, int nb_args, const char *str);
-void info_trace_events_completion(ReadLineState *rs, int nb_args, const char *str);
-void trace_event_completion(ReadLineState *rs, int nb_args, const char *str);
-void watchdog_action_completion(ReadLineState *rs, int nb_args,
- const char *str);
-void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
- const char *str);
-void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
- const char *str);
-void delvm_completion(ReadLineState *rs, int nb_args, const char *str);
-void loadvm_completion(ReadLineState *rs, int nb_args, const char *str);
void hmp_rocker(Monitor *mon, const QDict *qdict);
void hmp_rocker_ports(Monitor *mon, const QDict *qdict);
void hmp_rocker_of_dpa_flows(Monitor *mon, const QDict *qdict);
diff --git a/chardev/char-hmp-cmds.c b/chardev/char-hmp-cmds.c
index 8e9e1c1c021..f377e00b699 100644
--- a/chardev/char-hmp-cmds.c
+++ b/chardev/char-hmp-cmds.c
@@ -16,6 +16,7 @@
#include "qemu/osdep.h"
#include "chardev/char.h"
#include "monitor/hmp.h"
+#include "monitor/hmp-completion.h"
#include "monitor/monitor.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-char.h"
diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 0a193b8f54a..d5712d11b8c 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -17,6 +17,7 @@
#include "block/qapi.h"
#include "migration/snapshot.h"
#include "monitor/hmp.h"
+#include "monitor/hmp-completion.h"
#include "monitor/monitor.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-migration.h"
diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c
index 2574c5d8b4b..d07e545ef7e 100644
--- a/monitor/hmp-target.c
+++ b/monitor/hmp-target.c
@@ -28,6 +28,7 @@
#include "net/slirp.h"
#include "system/device_tree.h"
#include "monitor/hmp.h"
+#include "monitor/hmp-completion.h"
#include "block/block-hmp-cmds.h"
#include "qapi/qapi-commands-control.h"
#include "qapi/qapi-commands-misc.h"
diff --git a/net/net-hmp-cmds.c b/net/net-hmp-cmds.c
index e7c55d27876..2b24c9e6049 100644
--- a/net/net-hmp-cmds.c
+++ b/net/net-hmp-cmds.c
@@ -16,6 +16,7 @@
#include "qemu/osdep.h"
#include "migration/misc.h"
#include "monitor/hmp.h"
+#include "monitor/hmp-completion.h"
#include "monitor/monitor.h"
#include "net/net.h"
#include "net/hub.h"
diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
index 32e40630c96..47110ca58c0 100644
--- a/qom/qom-hmp-cmds.c
+++ b/qom/qom-hmp-cmds.c
@@ -8,6 +8,7 @@
#include "qemu/osdep.h"
#include "hw/core/qdev.h"
#include "monitor/hmp.h"
+#include "monitor/hmp-completion.h"
#include "monitor/monitor.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-qom.h"
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index 1ac6d9a8575..2ed95e83602 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -20,6 +20,7 @@
#include "qemu/osdep.h"
#include "hw/core/sysbus.h"
#include "monitor/hmp.h"
+#include "monitor/hmp-completion.h"
#include "monitor/monitor.h"
#include "monitor/qdev.h"
#include "system/arch_init.h"
diff --git a/system/runstate-hmp-cmds.c b/system/runstate-hmp-cmds.c
index be1d6769926..02d1d42bf39 100644
--- a/system/runstate-hmp-cmds.c
+++ b/system/runstate-hmp-cmds.c
@@ -16,6 +16,7 @@
#include "qemu/osdep.h"
#include "exec/cpu-common.h"
#include "monitor/hmp.h"
+#include "monitor/hmp-completion.h"
#include "monitor/monitor.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-run-state.h"
diff --git a/trace/trace-hmp-cmds.c b/trace/trace-hmp-cmds.c
index 45f4335ff5d..390173095cf 100644
--- a/trace/trace-hmp-cmds.c
+++ b/trace/trace-hmp-cmds.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "monitor/hmp.h"
+#include "monitor/hmp-completion.h"
#include "monitor/monitor.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-trace.h"
diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c
index 6c93d452c9c..1e9bc77bd80 100644
--- a/ui/ui-hmp-cmds.c
+++ b/ui/ui-hmp-cmds.c
@@ -18,6 +18,7 @@
#include <spice/enums.h>
#endif
#include "monitor/hmp.h"
+#include "monitor/hmp-completion.h"
#include "monitor/monitor-internal.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-ui.h"
--
2.53.0
On 3/20/26 9:08 AM, Philippe Mathieu-Daudé wrote: > Many files include "monitor/hmp.h", but few of them really need > the completion declarations: move them to a distinct header. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > MAINTAINERS | 1 + > include/monitor/hmp-completion.h | 40 ++++++++++++++++++++++++++++++++ > include/monitor/hmp.h | 21 ----------------- > chardev/char-hmp-cmds.c | 1 + > migration/migration-hmp-cmds.c | 1 + > monitor/hmp-target.c | 1 + > net/net-hmp-cmds.c | 1 + > qom/qom-hmp-cmds.c | 1 + > system/qdev-monitor.c | 1 + > system/runstate-hmp-cmds.c | 1 + > trace/trace-hmp-cmds.c | 1 + > ui/ui-hmp-cmds.c | 1 + > 12 files changed, 50 insertions(+), 21 deletions(-) > create mode 100644 include/monitor/hmp-completion.h > Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
© 2016 - 2026 Red Hat, Inc.