qapi: make HMP-specific schema entries conditional on CONFIG_HMP

Make the 'readline' value of MonitorMode and the
'human-monitor-command' command conditional on CONFIG_HMP, so
they are only available when HMP support is compiled in.

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-40-9227de146347@redhat.com>
This commit is contained in:
Marc-André Lureau committed 2026-08-29 12:07:45 +04:00
1 parent b3b845f762
commit 2d6d5508bb
4 files changed
+17 -2

No files matched your search

+10
View File
@@ -740,13 +740,22 @@ int monitor_new(MonitorOptions *opts, bool allow_hmp, Error **errp)
ERRP_GUARD();
if (!opts->has_mode) {
#ifdef CONFIG_HMP
opts->mode = allow_hmp ? MONITOR_MODE_READLINE : MONITOR_MODE_CONTROL;
#else
if (allow_hmp) {
error_setg(errp, "HMP support is not built in this QEMU");
return -1;
}
opts->mode = MONITOR_MODE_CONTROL;
#endif
}
switch (opts->mode) {
case MONITOR_MODE_CONTROL:
monitor_new_qmp(opts->id, opts->chardev, opts->pretty, errp);
break;
#ifdef CONFIG_HMP
case MONITOR_MODE_READLINE:
if (!allow_hmp) {
error_setg(errp, "Only QMP is supported");
@@ -758,6 +767,7 @@ int monitor_new(MonitorOptions *opts, bool allow_hmp, Error **errp)
}
monitor_new_hmp(opts->id, opts->chardev, true, errp);
break;
#endif /* CONFIG_HMP */
default:
g_assert_not_reached();
}
+2
View File
@@ -162,6 +162,7 @@ void qmp_add_client(const char *protocol, const char *fdname,
}
}
#ifdef CONFIG_HMP
char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
int64_t cpu_index, Error **errp)
{
@@ -187,6 +188,7 @@ out:
object_unref(hmp);
return output;
}
#endif /* CONFIG_HMP */
static void __attribute__((__constructor__)) monitor_init_qmp_commands(void)
{
+3 -1
View File
@@ -186,7 +186,9 @@
#
# Since: 5.0
##
{ 'enum': 'MonitorMode', 'data': [ 'readline', 'control' ] }
{ 'enum': 'MonitorMode', 'data': [
{ 'name': 'readline', 'if': 'CONFIG_HMP' },
'control' ] }
##
# @MonitorOptions:
+2 -1
View File
@@ -247,7 +247,8 @@
{ 'command': 'human-monitor-command',
'data': {'command-line': 'str', '*cpu-index': 'int'},
'returns': 'str',
'features': [ 'savevm-monitor-nodes' ] }
'features': [ 'savevm-monitor-nodes' ],
'if': 'CONFIG_HMP' }
##
# @getfd: