[PATCH] RFC: audio: deprecate HMP audio commands

marcandre.lureau--- via Devel posted 1 patch 1 week, 3 days ago
Failed in applying to current master (apply log)
There is a newer version of this series
docs/about/deprecated.rst     | 20 ++++++++++++++++++++
meson.build                   |  9 +++++++++
audio/meson.build             |  7 +++++--
hmp-commands-info.hx          |  2 ++
hmp-commands.hx               |  4 +++-
meson_options.txt             |  3 +++
scripts/meson-buildoptions.sh |  3 +++
7 files changed, 45 insertions(+), 3 deletions(-)
[PATCH] RFC: audio: deprecate HMP audio commands
Posted by marcandre.lureau--- via Devel 1 week, 3 days ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

The command is niche and better served by the host audio system.
There is no QMP equivalent, fortunately. You can capture the audio
stream via remote desktop protocols too (dbus, vnc, spice).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 docs/about/deprecated.rst     | 20 ++++++++++++++++++++
 meson.build                   |  9 +++++++++
 audio/meson.build             |  7 +++++--
 hmp-commands-info.hx          |  2 ++
 hmp-commands.hx               |  4 +++-
 meson_options.txt             |  3 +++
 scripts/meson-buildoptions.sh |  3 +++
 7 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 98361f5832..a357f207cf 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -169,6 +169,26 @@ Use ``job-finalize`` instead.
 
 This argument has always been ignored.
 
+Human Machine Protocol (HMP) commands
+-------------------------------------
+
+``wavcapture`` (since 10.2)
+''''''''''''''''''''''''''''
+
+The ``wavcapture`` command is deprecated and will be removed in a future release.
+
+Use ``-audiodev wav`` or your host audio system to capture audio.
+
+``stopcapture`` (since 10.2)
+''''''''''''''''''''''''''''
+
+The ``stopcapture`` command is deprecated and will be removed in a future release.
+
+``info`` argument ``capture`` (since 10.2)
+''''''''''''''''''''''''''''''''''''''''''
+
+The ``info capture`` command is deprecated and will be removed in a future release.
+
 Host Architectures
 ------------------
 
diff --git a/meson.build b/meson.build
index afaefa0172..0a2401e11e 100644
--- a/meson.build
+++ b/meson.build
@@ -2354,6 +2354,7 @@ endif
 config_host_data = configuration_data()
 
 config_host_data.set('CONFIG_HAVE_RUST', have_rust)
+config_host_data.set('CONFIG_AUDIO_HMP', get_option('audio_hmp'))
 audio_drivers_selected = []
 if have_system
   audio_drivers_available = {
@@ -5105,3 +5106,11 @@ if not actually_reloc and (host_os == 'windows' or get_option('relocatable'))
   message('QEMU will have to be installed under ' + get_option('prefix') + '.')
   message('Use --disable-relocatable to remove this warning.')
 endif
+
+if get_option('audio_hmp')
+  message()
+  warning('DEPRECATED HMP audio commands')
+  message()
+  message('If you want to keep supporting this command, please')
+  message('contact the developers at qemu-devel@nongnu.org.')
+endif
diff --git a/audio/meson.build b/audio/meson.build
index 59f0a431d5..ca2ef2a8f3 100644
--- a/audio/meson.build
+++ b/audio/meson.build
@@ -1,12 +1,15 @@
 system_ss.add([spice_headers, files('audio.c')])
 system_ss.add(files(
-  'audio-hmp-cmds.c',
+  'audio.c',
   'mixeng.c',
   'noaudio.c',
   'wavaudio.c',
-  'wavcapture.c',
 ))
 
+if get_option('audio_hmp')
+  system_ss.add(files('audio-hmp-cmds.c', 'wavcapture.c'))
+endif
+
 system_ss.add(when: coreaudio, if_true: files('coreaudio.m'))
 system_ss.add(when: dsound, if_true: files('dsoundaudio.c', 'audio_win_int.c'))
 
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 25b4aed51f..59f3446224 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -363,6 +363,7 @@ SRST
     Show host USB devices.
 ERST
 
+#ifdef CONFIG_AUDIO_HMP
     {
         .name       = "capture",
         .args_type  = "",
@@ -375,6 +376,7 @@ SRST
   ``info capture``
     Show capture information.
 ERST
+#endif
 
     {
         .name       = "snapshots",
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 15f6082596..414e2d2d1e 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -764,6 +764,7 @@ SRST
 
 ERST
 
+#ifdef CONFIG_AUDIO_HMP
     {
         .name       = "wavcapture",
         .args_type  = "path:F,audiodev:s,freq:i?,bits:i?,nchannels:i?",
@@ -798,6 +799,7 @@ SRST
     info capture
 
 ERST
+#endif
 
     {
         .name       = "memsave",
@@ -1090,7 +1092,7 @@ ERST
 
 SRST
 ``dump-guest-memory [-p]`` *filename* *begin* *length*
-  \ 
+  \
 ``dump-guest-memory [-z|-l|-s|-w]`` *filename*
   Dump guest memory to *protocol*. The file can be processed with crash or
   gdb. Without ``-z|-l|-s|-w``, the dump format is ELF.
diff --git a/meson_options.txt b/meson_options.txt
index 2836156257..d0fa75f1cf 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -39,6 +39,9 @@ option('coroutine_backend', type: 'combo',
 option('gdb', type: 'string', value: '',
        description: 'Path to GDB')
 
+option('audio_hmp', type: 'boolean', value: true,
+       description: 'enable HMP commands for audio', deprecated: true)
+
 # Everything else can be set via --enable/--disable-* option
 # on the configure script command line.  After adding an option
 # here make sure to run "make update-buildoptions".
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 3d0d132344..44ef7900f0 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -11,6 +11,7 @@ meson_options_help() {
   printf "%s\n" '                           set block driver read-write whitelist (by default'
   printf "%s\n" '                           affects only QEMU, not tools like qemu-img)'
   printf "%s\n" '  --datadir=VALUE          Data file directory [share]'
+  printf "%s\n" '  --disable-audio-hmp      enable HMP commands for audio'
   printf "%s\n" '  --disable-coroutine-pool coroutine freelist (better performance)'
   printf "%s\n" '  --disable-debug-info     Enable debug symbols and other information'
   printf "%s\n" '  --disable-hexagon-idef-parser'
@@ -244,6 +245,8 @@ _meson_option_parse() {
     --enable-attr) printf "%s" -Dattr=enabled ;;
     --disable-attr) printf "%s" -Dattr=disabled ;;
     --audio-drv-list=*) quote_sh "-Daudio_drv_list=$2" ;;
+    --enable-audio-hmp) printf "%s" -Daudio_hmp=true ;;
+    --disable-audio-hmp) printf "%s" -Daudio_hmp=false ;;
     --enable-auth-pam) printf "%s" -Dauth_pam=enabled ;;
     --disable-auth-pam) printf "%s" -Dauth_pam=disabled ;;
     --enable-gcov) printf "%s" -Db_coverage=true ;;
-- 
2.51.0

Re: [PATCH] RFC: audio: deprecate HMP audio commands
Posted by Daniel P. Berrangé 1 week, 3 days ago
On Wed, Oct 15, 2025 at 11:35:59AM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> The command is niche and better served by the host audio system.
> There is no QMP equivalent, fortunately. You can capture the audio
> stream via remote desktop protocols too (dbus, vnc, spice).
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  docs/about/deprecated.rst     | 20 ++++++++++++++++++++
>  meson.build                   |  9 +++++++++
>  audio/meson.build             |  7 +++++--
>  hmp-commands-info.hx          |  2 ++
>  hmp-commands.hx               |  4 +++-
>  meson_options.txt             |  3 +++
>  scripts/meson-buildoptions.sh |  3 +++
>  7 files changed, 45 insertions(+), 3 deletions(-)
> 
> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> index 98361f5832..a357f207cf 100644
> --- a/docs/about/deprecated.rst
> +++ b/docs/about/deprecated.rst
> @@ -169,6 +169,26 @@ Use ``job-finalize`` instead.
>  
>  This argument has always been ignored.
>  
> +Human Machine Protocol (HMP) commands
> +-------------------------------------
> +
> +``wavcapture`` (since 10.2)
> +''''''''''''''''''''''''''''
> +
> +The ``wavcapture`` command is deprecated and will be removed in a future release.
> +
> +Use ``-audiodev wav`` or your host audio system to capture audio.
> +
> +``stopcapture`` (since 10.2)
> +''''''''''''''''''''''''''''
> +
> +The ``stopcapture`` command is deprecated and will be removed in a future release.
> +
> +``info`` argument ``capture`` (since 10.2)
> +''''''''''''''''''''''''''''''''''''''''''
> +
> +The ``info capture`` command is deprecated and will be removed in a future release.
> +
>  Host Architectures
>  ------------------
>  
> diff --git a/meson.build b/meson.build
> index afaefa0172..0a2401e11e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2354,6 +2354,7 @@ endif
>  config_host_data = configuration_data()
>  
>  config_host_data.set('CONFIG_HAVE_RUST', have_rust)
> +config_host_data.set('CONFIG_AUDIO_HMP', get_option('audio_hmp'))
>  audio_drivers_selected = []
>  if have_system
>    audio_drivers_available = {
> @@ -5105,3 +5106,11 @@ if not actually_reloc and (host_os == 'windows' or get_option('relocatable'))
>    message('QEMU will have to be installed under ' + get_option('prefix') + '.')
>    message('Use --disable-relocatable to remove this warning.')
>  endif
> +
> +if get_option('audio_hmp')
> +  message()
> +  warning('DEPRECATED HMP audio commands')
> +  message()
> +  message('If you want to keep supporting this command, please')
> +  message('contact the developers at qemu-devel@nongnu.org.')
> +endif
> diff --git a/audio/meson.build b/audio/meson.build
> index 59f0a431d5..ca2ef2a8f3 100644
> --- a/audio/meson.build
> +++ b/audio/meson.build
> @@ -1,12 +1,15 @@
>  system_ss.add([spice_headers, files('audio.c')])
>  system_ss.add(files(
> -  'audio-hmp-cmds.c',
> +  'audio.c',
>    'mixeng.c',
>    'noaudio.c',
>    'wavaudio.c',
> -  'wavcapture.c',
>  ))
>  
> +if get_option('audio_hmp')
> +  system_ss.add(files('audio-hmp-cmds.c', 'wavcapture.c'))
> +endif
> +
>  system_ss.add(when: coreaudio, if_true: files('coreaudio.m'))
>  system_ss.add(when: dsound, if_true: files('dsoundaudio.c', 'audio_win_int.c'))
>  
> diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
> index 25b4aed51f..59f3446224 100644
> --- a/hmp-commands-info.hx
> +++ b/hmp-commands-info.hx
> @@ -363,6 +363,7 @@ SRST
>      Show host USB devices.
>  ERST
>  
> +#ifdef CONFIG_AUDIO_HMP
>      {
>          .name       = "capture",
>          .args_type  = "",
> @@ -375,6 +376,7 @@ SRST
>    ``info capture``
>      Show capture information.
>  ERST
> +#endif
>  
>      {
>          .name       = "snapshots",
> diff --git a/hmp-commands.hx b/hmp-commands.hx
> index 15f6082596..414e2d2d1e 100644
> --- a/hmp-commands.hx
> +++ b/hmp-commands.hx
> @@ -764,6 +764,7 @@ SRST
>  
>  ERST
>  
> +#ifdef CONFIG_AUDIO_HMP
>      {
>          .name       = "wavcapture",
>          .args_type  = "path:F,audiodev:s,freq:i?,bits:i?,nchannels:i?",
> @@ -798,6 +799,7 @@ SRST
>      info capture
>  
>  ERST
> +#endif
>  
>      {
>          .name       = "memsave",
> @@ -1090,7 +1092,7 @@ ERST
>  
>  SRST
>  ``dump-guest-memory [-p]`` *filename* *begin* *length*
> -  \ 
> +  \
>  ``dump-guest-memory [-z|-l|-s|-w]`` *filename*
>    Dump guest memory to *protocol*. The file can be processed with crash or
>    gdb. Without ``-z|-l|-s|-w``, the dump format is ELF.
> diff --git a/meson_options.txt b/meson_options.txt
> index 2836156257..d0fa75f1cf 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -39,6 +39,9 @@ option('coroutine_backend', type: 'combo',
>  option('gdb', type: 'string', value: '',
>         description: 'Path to GDB')
>  
> +option('audio_hmp', type: 'boolean', value: true,
> +       description: 'enable HMP commands for audio', deprecated: true)
> +
>  # Everything else can be set via --enable/--disable-* option
>  # on the configure script command line.  After adding an option
>  # here make sure to run "make update-buildoptions".
> diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> index 3d0d132344..44ef7900f0 100644
> --- a/scripts/meson-buildoptions.sh
> +++ b/scripts/meson-buildoptions.sh
> @@ -11,6 +11,7 @@ meson_options_help() {
>    printf "%s\n" '                           set block driver read-write whitelist (by default'
>    printf "%s\n" '                           affects only QEMU, not tools like qemu-img)'
>    printf "%s\n" '  --datadir=VALUE          Data file directory [share]'
> +  printf "%s\n" '  --disable-audio-hmp      enable HMP commands for audio'
>    printf "%s\n" '  --disable-coroutine-pool coroutine freelist (better performance)'
>    printf "%s\n" '  --disable-debug-info     Enable debug symbols and other information'
>    printf "%s\n" '  --disable-hexagon-idef-parser'
> @@ -244,6 +245,8 @@ _meson_option_parse() {
>      --enable-attr) printf "%s" -Dattr=enabled ;;
>      --disable-attr) printf "%s" -Dattr=disabled ;;
>      --audio-drv-list=*) quote_sh "-Daudio_drv_list=$2" ;;
> +    --enable-audio-hmp) printf "%s" -Daudio_hmp=true ;;
> +    --disable-audio-hmp) printf "%s" -Daudio_hmp=false ;;
>      --enable-auth-pam) printf "%s" -Dauth_pam=enabled ;;
>      --disable-auth-pam) printf "%s" -Dauth_pam=disabled ;;
>      --enable-gcov) printf "%s" -Db_coverage=true ;;

Adding build time options to disable functionality is not the way we handle
deprecation in QEMU.

This should update deprecated.rst and then change the impl of the HMP
commands so that they print a warning (once only) when invoked.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|