On Fri, Jun 26, 2026 at 01:19:33AM +0400, Marc-André Lureau wrote:
> 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.
> 
> Signed-off-by: Marc-André Lureau <[email protected]>
> ---
>  qapi/control.json  | 4 +++-
>  qapi/misc.json     | 3 ++-
>  monitor/monitor.c  | 8 +++++++-
>  monitor/qmp-cmds.c | 2 ++
>  4 files changed, 14 insertions(+), 3 deletions(-)

this will need a bunch of conflict resolution with the QOM
work I'm afraid.

> 
> diff --git a/qapi/control.json b/qapi/control.json
> index 9a5302193d6..9898552814b 100644
> --- a/qapi/control.json
> +++ b/qapi/control.json
> @@ -186,7 +186,9 @@
>  #
>  # Since: 5.0
>  ##
> -{ 'enum': 'MonitorMode', 'data': [ 'readline', 'control' ] }
> +{ 'enum': 'MonitorMode', 'data': [
> +    { 'name': 'readline', 'if': 'CONFIG_HMP' },
> +    'control' ] }
>  
>  ##
>  # @MonitorOptions:
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 22b7afed9f6..a21ba61b96e 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -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:
> diff --git a/monitor/monitor.c b/monitor/monitor.c
> index f443f406b4c..50f1fe77c33 100644
> --- a/monitor/monitor.c
> +++ b/monitor/monitor.c
> @@ -733,13 +733,18 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, 
> Error **errp)
>      }
>  
>      if (!opts->has_mode) {
> -        opts->mode = allow_hmp ? MONITOR_MODE_READLINE : 
> MONITOR_MODE_CONTROL;
> +        opts->mode =
> +#ifdef CONFIG_HMP
> +            allow_hmp ? MONITOR_MODE_READLINE :
> +#endif
> +            MONITOR_MODE_CONTROL;
>      }
>  
>      switch (opts->mode) {
>      case MONITOR_MODE_CONTROL:
>          monitor_init_qmp(chr, opts->pretty, errp);
>          break;
> +#ifdef CONFIG_HMP
>      case MONITOR_MODE_READLINE:
>          if (!allow_hmp) {
>              error_setg(errp, "Only QMP is supported");
> @@ -751,6 +756,7 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, 
> Error **errp)
>          }
>          monitor_init_hmp(chr, true, errp);
>          break;
> +#endif /* CONFIG_HMP */
>      default:
>          g_assert_not_reached();
>      }
> diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
> index 0c409c27dc3..5e642a2b14d 100644
> --- a/monitor/qmp-cmds.c
> +++ b/monitor/qmp-cmds.c
> @@ -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)
>  {
> @@ -189,6 +190,7 @@ out:
>      monitor_data_destroy(&hmp.common);
>      return output;
>  }
> +#endif /* CONFIG_HMP */
>  
>  static void __attribute__((__constructor__)) monitor_init_qmp_commands(void)
>  {
> 
> -- 
> 2.54.0
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|


Reply via email to