All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] add build option to disable audio subsystem
@ 2026-02-17  5:27 Sergei Heifetz
  2026-02-17  5:27 ` [PATCH 1/8] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
                   ` (8 more replies)
  0 siblings, 9 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-17  5:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

This patch series adds a compile-time option to disable building
audio-related sources (mostly, files under `audio/` and `hw/audio/`).
It adds `--disable-audio` and `--enable-audio` options to the
`configure` script. Audio remains enabled by default, and the changes are
harmless in that case.

When audio is disabled, it may not be possible to build a number of
devices and machines. This is expected, and can be addressed on a
case-by-case basis if needed.

This feature may be useful in production environments which only use a
specific subset of QEMU’s functionality and, in particular, do not need
the audio subsystem. In such environments it is generally beneficial to
avoid building unused code, for both security and maintenance reasons.

Sergei Heifetz (8):
  audio: add `audio` build option for meson and Kconfig
  ui/vnc: disable audio feature when configured with --disable-audio
  tests/qtest: remove -audio none when configured with --disable-audio
  hw/audio/pcspk: change PCSPK behaviour with --disable-audio
  Kconfig: add AUDIO dependency to audio-related devices
  system/vl: remove audio and audiodev options when audio is disabled
  audio: do not build audio-related sources with --disable-audio
  meson.build: ignore audio drivers when configured with --disable-audio

 Kconfig.host                |  3 ++
 audio/audio-hmp-cmds-stub.c | 28 +++++++++++++
 audio/audio-stub.c          | 35 ++++++++++++++++
 audio/meson.build           |  5 +++
 configure                   |  4 ++
 hw/audio/Kconfig            | 21 ++++++----
 hw/audio/pcspk.c            | 14 +++++++
 hw/usb/Kconfig              |  2 +-
 meson.build                 | 83 +++++++++++++++++++++----------------
 meson_options.txt           |  3 ++
 qapi/audio.json             |  3 +-
 replay/meson.build          |  9 +++-
 replay/replay-audio-stub.c  | 16 +++++++
 replay/stubs-system.c       |  6 ---
 system/vl.c                 |  6 +++
 tests/qtest/libqtest.c      |  2 +
 ui/vnc.c                    | 31 ++++++++++++--
 17 files changed, 215 insertions(+), 56 deletions(-)
 create mode 100644 audio/audio-hmp-cmds-stub.c
 create mode 100644 audio/audio-stub.c
 create mode 100644 replay/replay-audio-stub.c

-- 
2.34.1



^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17  5:27 [PATCH 0/8] add build option to disable audio subsystem Sergei Heifetz
@ 2026-02-17  5:27 ` Sergei Heifetz
  2026-02-17  8:40   ` Thomas Huth
                     ` (2 more replies)
  2026-02-17  5:27 ` [PATCH 2/8] ui/vnc: disable audio feature when configured with --disable-audio Sergei Heifetz
                   ` (7 subsequent siblings)
  8 siblings, 3 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-17  5:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

This patch adds the `audio` option to meson_options.txt. It is
propagated into Kconfig as AUDIO. It is enabled by default.
The corresponding `--disable-audio` and `--enable-audio` options
for `configure` are also added.

For now, this option does nothing. In subsequent patches, it will
gradually disable audio in different places. The final goal is to stop
building sources from `audio/` and `hw/audio/` and other audio-related
files (except for some stubs). Note that this intent is different from
`-audio none`, which mutes audio but still compiles the audio subsystem.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 Kconfig.host      | 3 +++
 configure         | 4 ++++
 meson.build       | 3 +++
 meson_options.txt | 3 +++
 4 files changed, 13 insertions(+)

diff --git a/Kconfig.host b/Kconfig.host
index 933425c74b..ec129aa4fc 100644
--- a/Kconfig.host
+++ b/Kconfig.host
@@ -29,6 +29,9 @@ config IVSHMEM
 config TPM
     bool
 
+config AUDIO
+    bool
+
 config FDT
     bool
 
diff --git a/configure b/configure
index 4b61fd3bbf..ff391c79a1 100755
--- a/configure
+++ b/configure
@@ -762,6 +762,10 @@ for opt do
   ;;
   --wasm64-32bit-address-limit)
   ;;
+  --enable-audio) meson_option_add -Daudio=true
+  ;;
+  --disable-audio) meson_option_add -Daudio=false
+  ;;
   # everything else has the same name in configure and meson
   --*) meson_option_parse "$opt" "$optarg"
   ;;
diff --git a/meson.build b/meson.build
index 8c6c0a9a32..69aa7cd189 100644
--- a/meson.build
+++ b/meson.build
@@ -68,6 +68,8 @@ foreach target : target_dirs
 endforeach
 have_user = have_linux_user or have_bsd_user
 
+audio_enabled = get_option('audio')
+
 ############
 # Programs #
 ############
@@ -3244,6 +3246,7 @@ disassemblers = {
 have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
 host_kconfig = \
   (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \
+  (audio_enabled ? ['CONFIG_AUDIO=y'] : []) + \
   (have_tpm ? ['CONFIG_TPM=y'] : []) + \
   (pixman.found() ? ['CONFIG_PIXMAN=y'] : []) + \
   (spice.found() ? ['CONFIG_SPICE=y'] : []) + \
diff --git a/meson_options.txt b/meson_options.txt
index 2836156257..172ed10ead 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -71,6 +71,9 @@ option('malloc_trim', type : 'feature', value : 'auto',
 option('malloc', type : 'combo', choices : ['system', 'tcmalloc', 'jemalloc'],
        value: 'system', description: 'choose memory allocator to use')
 
+option('audio', type: 'boolean', value: true,
+       description: 'Audio support')
+
 option('kvm', type: 'feature', value: 'auto',
        description: 'KVM acceleration support')
 option('mshv', type: 'feature', value: 'auto',
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 2/8] ui/vnc: disable audio feature when configured with --disable-audio
  2026-02-17  5:27 [PATCH 0/8] add build option to disable audio subsystem Sergei Heifetz
  2026-02-17  5:27 ` [PATCH 1/8] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
@ 2026-02-17  5:27 ` Sergei Heifetz
  2026-02-17  5:27 ` [PATCH 3/8] tests/qtest: remove -audio none " Sergei Heifetz
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-17  5:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

Disable the audio feature in VNC when QEMU is configured with
`--disable-audio`. Do not compile the corresponding audio-related
code.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 ui/vnc.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index a61a4f937d..8212d3ce81 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1072,6 +1072,7 @@ static void vnc_update_throttle_offset(VncState *vs)
     size_t offset =
         vs->client_width * vs->client_height * vs->client_pf.bytes_per_pixel;
 
+#ifdef CONFIG_AUDIO
     if (vs->audio_cap) {
         int bps;
         switch (vs->as.fmt) {
@@ -1091,6 +1092,7 @@ static void vnc_update_throttle_offset(VncState *vs)
         }
         offset += vs->as.freq * bps * vs->as.nchannels;
     }
+#endif
 
     /* Put a floor of 1MB on offset, so that if we have a large pending
      * buffer and the display is resized to a small size & back again
@@ -1214,6 +1216,7 @@ static int vnc_update_client(VncState *vs, int has_dirty)
     return n;
 }
 
+#ifdef CONFIG_AUDIO
 /* audio */
 static void audio_capture_notify(void *opaque, audcnotification_e cmd)
 {
@@ -1293,6 +1296,7 @@ static void audio_del(VncState *vs)
         vs->audio_cap = NULL;
     }
 }
+#endif
 
 static void vnc_disconnect_start(VncState *vs)
 {
@@ -1332,7 +1336,9 @@ void vnc_disconnect_finish(VncState *vs)
 #ifdef CONFIG_VNC_SASL
     vnc_sasl_client_cleanup(vs);
 #endif /* CONFIG_VNC_SASL */
+#ifdef CONFIG_AUDIO
     audio_del(vs);
+#endif
     qkbd_state_lift_all_keys(vs->vd->kbd);
 
     if (vs->mouse_mode_notifier.notify != NULL) {
@@ -2097,6 +2103,7 @@ static void send_ext_key_event_ack(VncState *vs)
     vnc_flush(vs);
 }
 
+#ifdef CONFIG_AUDIO
 static void send_ext_audio_ack(VncState *vs)
 {
     vnc_lock_output(vs);
@@ -2110,6 +2117,7 @@ static void send_ext_audio_ack(VncState *vs)
     vnc_unlock_output(vs);
     vnc_flush(vs);
 }
+#endif
 
 static void send_xvp_message(VncState *vs, int code)
 {
@@ -2197,10 +2205,15 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)
             send_ext_key_event_ack(vs);
             break;
         case VNC_ENCODING_AUDIO:
+#ifdef CONFIG_AUDIO
             if (vs->vd->audio_be) {
                 vnc_set_feature(vs, VNC_FEATURE_AUDIO);
                 send_ext_audio_ack(vs);
             }
+#else
+            VNC_DEBUG("Audio encoding received with audio subsystem "
+                      "disabled\n");
+#endif
             break;
         case VNC_ENCODING_WMVi:
             vnc_set_feature(vs, VNC_FEATURE_WMVI);
@@ -2394,7 +2407,9 @@ static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
 {
     int i;
     uint16_t limit;
-    uint32_t freq;
+    #ifdef CONFIG_AUDIO
+        uint32_t freq;
+    #endif
     VncDisplay *vd = vs->vd;
 
     if (data[0] > 3) {
@@ -2571,7 +2586,9 @@ static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
                 vnc_client_error(vs);
                 break;
             }
-
+#ifndef CONFIG_AUDIO
+            abort();
+#else
             if (len == 2)
                 return 4;
 
@@ -2626,7 +2643,7 @@ static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
                 break;
             }
             break;
-
+#endif
         default:
             VNC_DEBUG("Msg: %d\n", read_u16(data, 0));
             vnc_client_error(vs);
@@ -3369,10 +3386,12 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc,
     vs->last_x = -1;
     vs->last_y = -1;
 
+#ifdef CONFIG_AUDIO
     vs->as.freq = 44100;
     vs->as.nchannels = 2;
     vs->as.fmt = AUDIO_FORMAT_S16;
     vs->as.endianness = 0;
+#endif
 
     qemu_mutex_init(&vs->output_mutex);
     vs->bh = qemu_bh_new(vnc_jobs_bh, vs);
@@ -3645,9 +3664,11 @@ static QemuOptsList qemu_vnc_opts = {
         },{
             .name = "non-adaptive",
             .type = QEMU_OPT_BOOL,
+#ifdef CONFIG_AUDIO
         },{
             .name = "audiodev",
             .type = QEMU_OPT_STRING,
+#endif
         },{
             .name = "power-control",
             .type = QEMU_OPT_BOOL,
@@ -4080,7 +4101,9 @@ void vnc_display_open(const char *id, Error **errp)
     const char *saslauthz;
     int lock_key_sync = 1;
     int key_delay_ms;
+#ifdef CONFIG_AUDIO
     const char *audiodev;
+#endif
     const char *passwordSecret;
 
     if (!vd) {
@@ -4238,6 +4261,7 @@ void vnc_display_open(const char *id, Error **errp)
     }
     vd->ledstate = 0;
 
+#ifdef CONFIG_AUDIO
     audiodev = qemu_opt_get(opts, "audiodev");
     if (audiodev) {
         vd->audio_be = audio_be_by_name(audiodev, errp);
@@ -4247,6 +4271,7 @@ void vnc_display_open(const char *id, Error **errp)
     } else {
         vd->audio_be = audio_get_default_audio_be(NULL);
     }
+#endif
 
     device_id = qemu_opt_get(opts, "display");
     if (device_id) {
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 3/8] tests/qtest: remove -audio none when configured with --disable-audio
  2026-02-17  5:27 [PATCH 0/8] add build option to disable audio subsystem Sergei Heifetz
  2026-02-17  5:27 ` [PATCH 1/8] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
  2026-02-17  5:27 ` [PATCH 2/8] ui/vnc: disable audio feature when configured with --disable-audio Sergei Heifetz
@ 2026-02-17  5:27 ` Sergei Heifetz
  2026-02-17  9:19   ` Thomas Huth
  2026-02-17  5:27 ` [PATCH 4/8] hw/audio/pcspk: change PCSPK behaviour " Sergei Heifetz
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-17  5:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

It does not matter much whether `-audio none` is passed. In the future,
support for `-audio none` with `--disable-audio` will be dropped, so we
should remove it beforehand.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 tests/qtest/libqtest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 794d870085..adb968f40e 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -464,7 +464,9 @@ gchar *qtest_qemu_args(const char *extra_args)
                       "-chardev socket,path=%s,id=char0 "
                       "-mon chardev=char0,mode=control "
                       "-display none "
+#ifdef CONFIG_AUDIO
                       "-audio none "
+#endif
                       "%s"
                       "%s"
                       " -accel qtest",
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 4/8] hw/audio/pcspk: change PCSPK behaviour with --disable-audio
  2026-02-17  5:27 [PATCH 0/8] add build option to disable audio subsystem Sergei Heifetz
                   ` (2 preceding siblings ...)
  2026-02-17  5:27 ` [PATCH 3/8] tests/qtest: remove -audio none " Sergei Heifetz
@ 2026-02-17  5:27 ` Sergei Heifetz
  2026-02-17  9:14   ` Thomas Huth
  2026-02-17  9:56   ` Paolo Bonzini
  2026-02-17  5:27 ` [PATCH 5/8] Kconfig: add AUDIO dependency to audio-related devices Sergei Heifetz
                   ` (4 subsequent siblings)
  8 siblings, 2 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-17  5:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

PCSPK (PC Speaker) is an embedded audio device. We don't want it to use audio
when QEMU is configured with `--disable-audio`. This is achieved with minimal,
non-invasive changes to the code.

In essence, the changes ensure that PCSPK does not use the corresponding
audio backend, while functioning the same way in non-audio aspects.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 hw/audio/pcspk.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index 916c56fa4c..03fe816024 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -36,10 +36,12 @@
 #include "qom/object.h"
 #include "trace.h"
 
+#ifdef CONFIG_AUDIO
 #define PCSPK_BUF_LEN 1792
 #define PCSPK_SAMPLE_RATE 32000
 #define PCSPK_MAX_FREQ (PCSPK_SAMPLE_RATE >> 1)
 #define PCSPK_MIN_COUNT DIV_ROUND_UP(PIT_FREQ, PCSPK_MAX_FREQ)
+#endif
 
 OBJECT_DECLARE_SIMPLE_TYPE(PCSpkState, PC_SPEAKER)
 
@@ -48,18 +50,25 @@ struct PCSpkState {
 
     MemoryRegion ioport;
     uint32_t iobase;
+#ifdef CONFIG_AUDIO
     uint8_t sample_buf[PCSPK_BUF_LEN];
+#endif
     AudioBackend *audio_be;
+#ifdef CONFIG_AUDIO
     SWVoiceOut *voice;
+#endif
     PITCommonState *pit;
+#ifdef CONFIG_AUDIO
     unsigned int pit_count;
     unsigned int samples;
     unsigned int play_pos;
+#endif
     uint8_t data_on;
     uint8_t dummy_refresh_clock;
     bool migrate;
 };
 
+#ifdef CONFIG_AUDIO
 static const char *s_spk = "pcspk";
 
 static inline void generate_samples(PCSpkState *s)
@@ -131,6 +140,7 @@ static int pcspk_audio_init(PCSpkState *s)
 
     return 0;
 }
+#endif
 
 static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
                               unsigned size)
@@ -161,11 +171,13 @@ static void pcspk_io_write(void *opaque, hwaddr addr, uint64_t val,
 
     s->data_on = (val >> 1) & 1;
     pit_set_gate(s->pit, 2, gate);
+#ifdef CONFIG_AUDIO
     if (s->voice) {
         if (gate) /* restart */
             s->play_pos = 0;
         AUD_set_active_out(s->voice, gate & s->data_on);
     }
+#endif
 }
 
 static const MemoryRegionOps pcspk_io_ops = {
@@ -196,10 +208,12 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)
 
     isa_register_ioport(isadev, &s->ioport, s->iobase);
 
+#ifdef CONFIG_AUDIO
     if (s->audio_be && AUD_backend_check(&s->audio_be, errp)) {
         pcspk_audio_init(s);
         return;
     }
+#endif
 }
 
 static bool migrate_needed(void *opaque)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 5/8] Kconfig: add AUDIO dependency to audio-related devices
  2026-02-17  5:27 [PATCH 0/8] add build option to disable audio subsystem Sergei Heifetz
                   ` (3 preceding siblings ...)
  2026-02-17  5:27 ` [PATCH 4/8] hw/audio/pcspk: change PCSPK behaviour " Sergei Heifetz
@ 2026-02-17  5:27 ` Sergei Heifetz
  2026-02-17  9:15   ` Thomas Huth
  2026-02-17  5:27 ` [PATCH 6/8] system/vl: remove audio and audiodev options when audio is disabled Sergei Heifetz
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-17  5:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

The idea of the `--disable-audio` option is to stop building audio-related
source files. Although this is not yet implemented, we can already make
the existing AUDIO Kconfig option a dependency for a number of devices so
that the build does not break when we remove `audio/` and other sources.

Note that some machines have embedded audio devices and therefore cannot
be used with `--disable-audio` at all. `-audio none` should be used for
such machines if audio needs to be muted.

The only device that is purposefully not included in this patch is PCSPK
(PC speaker), because its code has already been modified to work with
`--disable-audio`.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 hw/audio/Kconfig | 21 ++++++++++++---------
 hw/usb/Kconfig   |  2 +-
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
index daf060e1be..0479818e3f 100644
--- a/hw/audio/Kconfig
+++ b/hw/audio/Kconfig
@@ -1,37 +1,37 @@
 config SB16
     bool
     default y
-    depends on ISA_BUS
+    depends on ISA_BUS && AUDIO
 
 config ES1370
     bool
     default y if PCI_DEVICES
-    depends on PCI
+    depends on PCI && AUDIO
 
 config AC97
     bool
     default y if PCI_DEVICES
-    depends on PCI
+    depends on PCI && AUDIO
 
 config ADLIB
     bool
     default y
-    depends on ISA_BUS
+    depends on ISA_BUS && AUDIO
 
 config GUS
     bool
     default y
-    depends on ISA_BUS
+    depends on ISA_BUS && AUDIO
 
 config CS4231A
     bool
     default y
-    depends on ISA_BUS
+    depends on ISA_BUS && AUDIO
 
 config HDA
     bool
     default y if PCI_DEVICES
-    depends on PCI
+    depends on PCI && AUDIO
 
 config PCSPK
     bool
@@ -40,18 +40,21 @@ config PCSPK
 
 config WM8750
     bool
-    depends on I2C
+    depends on I2C && AUDIO
 
 config PL041
     bool
+    depends on AUDIO
 
 config CS4231
     bool
+    depends on AUDIO
 
 config ASC
     bool
+    depends on AUDIO
 
 config VIRTIO_SND
     bool
     default y
-    depends on VIRTIO
+    depends on VIRTIO && AUDIO
diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig
index de95686720..e370585892 100644
--- a/hw/usb/Kconfig
+++ b/hw/usb/Kconfig
@@ -98,7 +98,7 @@ config USB_STORAGE_UAS
 config USB_AUDIO
     bool
     default y
-    depends on USB
+    depends on USB && AUDIO
 
 config USB_SERIAL
     bool
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 6/8] system/vl: remove audio and audiodev options when audio is disabled
  2026-02-17  5:27 [PATCH 0/8] add build option to disable audio subsystem Sergei Heifetz
                   ` (4 preceding siblings ...)
  2026-02-17  5:27 ` [PATCH 5/8] Kconfig: add AUDIO dependency to audio-related devices Sergei Heifetz
@ 2026-02-17  5:27 ` Sergei Heifetz
  2026-02-17  5:27 ` [PATCH 7/8] audio: do not build audio-related sources with --disable-audio Sergei Heifetz
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-17  5:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

Remove the audio and audiodev runtime options when QEMU is configured
with `--disable-audio`.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 system/vl.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/system/vl.c b/system/vl.c
index aa9a155041..b4f0c3b2f3 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2248,7 +2248,9 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
 static bool is_qemuopts_group(const char *group)
 {
     if (g_str_equal(group, "object") ||
+#ifdef CONFIG_AUDIO
         g_str_equal(group, "audiodev") ||
+#endif
         g_str_equal(group, "machine") ||
         g_str_equal(group, "smp-opts") ||
         g_str_equal(group, "boot-opts")) {
@@ -2265,6 +2267,7 @@ static void qemu_record_config_group(const char *group, QDict *dict,
         object_option_add_visitor(v);
         visit_free(v);
 
+#ifdef CONFIG_AUDIO
     } else if (g_str_equal(group, "audiodev")) {
         Audiodev *dev = NULL;
         Visitor *v = qobject_input_visitor_new_keyval(QOBJECT(dict));
@@ -2272,6 +2275,7 @@ static void qemu_record_config_group(const char *group, QDict *dict,
             audio_add_audiodev(dev);
         }
         visit_free(v);
+#endif
 
     } else if (g_str_equal(group, "machine")) {
         /*
@@ -3059,6 +3063,7 @@ void qemu_init(int argc, char **argv)
                 }
                 break;
 #endif
+#ifdef CONFIG_AUDIO
             case QEMU_OPTION_audiodev:
                 default_audio = 0;
                 audio_parse_option(optarg);
@@ -3099,6 +3104,7 @@ void qemu_init(int argc, char **argv)
                 }
                 break;
             }
+#endif
             case QEMU_OPTION_h:
                 help(0);
                 break;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 7/8] audio: do not build audio-related sources with --disable-audio
  2026-02-17  5:27 [PATCH 0/8] add build option to disable audio subsystem Sergei Heifetz
                   ` (5 preceding siblings ...)
  2026-02-17  5:27 ` [PATCH 6/8] system/vl: remove audio and audiodev options when audio is disabled Sergei Heifetz
@ 2026-02-17  5:27 ` Sergei Heifetz
  2026-02-17  9:49   ` Paolo Bonzini
  2026-02-17  5:27 ` [PATCH 8/8] meson.build: ignore audio drivers when configured " Sergei Heifetz
  2026-02-17  9:58 ` [PATCH 0/8] add build option to disable audio subsystem Marc-André Lureau
  8 siblings, 1 reply; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-17  5:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

When QEMU is configured with `--disable-audio`, do not build any
audio-related sources.

- audio/meson.build and replay/meson.build:
  Exclude audio-related sources when audio is disabled.

- audio/audio-stub.c:
  Provide a minimal set of straightforward stubs.

- replay/replay-audio-stub.c:
  Move the existing stubs from replay/stubs-system.c into a separate
  file.

- qapi/audio.json:
  Remove the QMP `query-audiodevs` command.

- audio/audio-hmp-cmds-stub.c:
  Provide meaningful messages for audio-related HMP commands:
  stopcapture, wavcapture, info capture.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 audio/audio-hmp-cmds-stub.c | 28 ++++++++++++++++++++++++++++
 audio/audio-stub.c          | 35 +++++++++++++++++++++++++++++++++++
 audio/meson.build           |  5 +++++
 qapi/audio.json             |  3 ++-
 replay/meson.build          |  9 ++++++++-
 replay/replay-audio-stub.c  | 16 ++++++++++++++++
 replay/stubs-system.c       |  6 ------
 7 files changed, 94 insertions(+), 8 deletions(-)
 create mode 100644 audio/audio-hmp-cmds-stub.c
 create mode 100644 audio/audio-stub.c
 create mode 100644 replay/replay-audio-stub.c

diff --git a/audio/audio-hmp-cmds-stub.c b/audio/audio-hmp-cmds-stub.c
new file mode 100644
index 0000000000..2f94f1c8dd
--- /dev/null
+++ b/audio/audio-hmp-cmds-stub.c
@@ -0,0 +1,28 @@
+/*
+ * Stub for audio-hmp-cmds.c
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "audio_int.h"
+#include "monitor/hmp.h"
+#include "monitor/monitor.h"
+#include "qapi/error.h"
+#include "qobject/qdict.h"
+#include "qemu/error-report.h"
+
+void hmp_info_capture(Monitor *mon, const QDict *qdict)
+{
+    monitor_puts(mon, "audio subsystem is disabled at compile time");
+}
+
+void hmp_stopcapture(Monitor *mon, const QDict *qdict)
+{
+    monitor_puts(mon, "audio subsystem is disabled at compile time");
+}
+
+void hmp_wavcapture(Monitor *mon, const QDict *qdict)
+{
+    monitor_puts(mon, "audio subsystem is disabled at compile time");
+}
diff --git a/audio/audio-stub.c b/audio/audio-stub.c
new file mode 100644
index 0000000000..0c9e2446e0
--- /dev/null
+++ b/audio/audio-stub.c
@@ -0,0 +1,35 @@
+/*
+ * Stub for audio.c
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/qapi-commands-audio.h"
+#include "qemu/audio.h"
+#include "qapi/error.h"
+
+void audio_cleanup(void) {}
+
+AudioBackend *audio_be_by_name(const char *name, Error **errp)
+{
+  error_setg(
+      errp,
+      "trying to find audiodev '%s' by name with audio component disabled",
+      name);
+  return NULL;
+}
+
+const char *audio_be_get_id(AudioBackend *be) { return ""; }
+
+bool audio_be_set_dbus_server(AudioBackend *be,
+                              GDBusObjectManagerServer *server, bool p2p,
+                              Error **errp)
+{
+  error_setg(errp, "trying to set dbus server with audio component disabled");
+  return false;
+}
+
+void audio_init_audiodevs(void) {}
+
+void audio_create_default_audiodevs(void) {}
diff --git a/audio/meson.build b/audio/meson.build
index b2dca2c640..ea1f88fb6f 100644
--- a/audio/meson.build
+++ b/audio/meson.build
@@ -1,3 +1,8 @@
+if not audio_enabled
+  system_ss.add(files('audio-stub.c', 'audio-hmp-cmds-stub.c'))
+  subdir_done()
+endif
+
 system_ss.add(files(
   'audio.c',
   'mixeng.c',
diff --git a/qapi/audio.json b/qapi/audio.json
index 2df87b9710..28fda7c8ac 100644
--- a/qapi/audio.json
+++ b/qapi/audio.json
@@ -540,4 +540,5 @@
 # Since: 8.0
 ##
 { 'command': 'query-audiodevs',
-  'returns': ['Audiodev'] }
+  'returns': ['Audiodev'],
+  'if': 'CONFIG_AUDIO' }
diff --git a/replay/meson.build b/replay/meson.build
index 4b4175e8dd..7f8b5dca61 100644
--- a/replay/meson.build
+++ b/replay/meson.build
@@ -7,7 +7,14 @@ system_ss.add(when: 'CONFIG_TCG', if_true: files(
   'replay-char.c',
   'replay-snapshot.c',
   'replay-net.c',
-  'replay-audio.c',
   'replay-random.c',
   'replay-debugging.c',
 ), if_false: files('stubs-system.c'))
+
+if audio_enabled
+  system_ss.add(when: 'CONFIG_TCG',
+  if_true: files('replay-audio.c'),
+  if_false: files('replay-audio-stub.c'))
+else
+  system_ss.add(files('replay-audio-stub.c'))
+endif
diff --git a/replay/replay-audio-stub.c b/replay/replay-audio-stub.c
new file mode 100644
index 0000000000..303e5075f4
--- /dev/null
+++ b/replay/replay-audio-stub.c
@@ -0,0 +1,16 @@
+/*
+ * Stub for replay-audio.c
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "system/replay.h"
+
+void replay_audio_in(size_t *recorded, st_sample *samples,
+                     size_t *wpos, size_t size)
+{
+}
+void replay_audio_out(size_t *played)
+{
+}
diff --git a/replay/stubs-system.c b/replay/stubs-system.c
index 7f85764936..454415ae8e 100644
--- a/replay/stubs-system.c
+++ b/replay/stubs-system.c
@@ -15,12 +15,6 @@ void replay_input_sync_event(void)
 void replay_add_blocker(const char *feature)
 {
 }
-void replay_audio_in(size_t *recorded, st_sample *samples, size_t *wpos, size_t size)
-{
-}
-void replay_audio_out(size_t *played)
-{
-}
 void replay_breakpoint(void)
 {
 }
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 8/8] meson.build: ignore audio drivers when configured with --disable-audio
  2026-02-17  5:27 [PATCH 0/8] add build option to disable audio subsystem Sergei Heifetz
                   ` (6 preceding siblings ...)
  2026-02-17  5:27 ` [PATCH 7/8] audio: do not build audio-related sources with --disable-audio Sergei Heifetz
@ 2026-02-17  5:27 ` Sergei Heifetz
  2026-02-17  9:58 ` [PATCH 0/8] add build option to disable audio subsystem Marc-André Lureau
  8 siblings, 0 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-17  5:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

When QEMU is configured with `--disable-audio`, we do not need to add the
audio drivers list to config_host_data. We also do not need to print this
list.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 meson.build | 80 ++++++++++++++++++++++++++++++-----------------------
 1 file changed, 45 insertions(+), 35 deletions(-)

diff --git a/meson.build b/meson.build
index 69aa7cd189..a1224c9695 100644
--- a/meson.build
+++ b/meson.build
@@ -2266,46 +2266,55 @@ endif
 config_host_data = configuration_data()
 
 config_host_data.set('CONFIG_HAVE_RUST', have_rust)
-audio_drivers_selected = []
-if have_system
-  audio_drivers_available = {
-    'alsa': alsa.found(),
-    'coreaudio': coreaudio.found(),
-    'dsound': dsound.found(),
-    'jack': jack.found(),
-    'oss': oss.found(),
-    'pa': pulse.found(),
-    'pipewire': pipewire.found(),
-    'sdl': sdl.found(),
-    'sndio': sndio.found(),
-  }
-  foreach k, v: audio_drivers_available
-    config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
-  endforeach
+config_host_data.set('CONFIG_AUDIO', audio_enabled)
+if audio_enabled
+  audio_drivers_selected = []
+  if have_system
+    audio_drivers_available = {
+      'alsa': alsa.found(),
+      'coreaudio': coreaudio.found(),
+      'dsound': dsound.found(),
+      'jack': jack.found(),
+      'oss': oss.found(),
+      'pa': pulse.found(),
+      'pipewire': pipewire.found(),
+      'sdl': sdl.found(),
+      'sndio': sndio.found(),
+    }
+    foreach k, v: audio_drivers_available
+      config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
+    endforeach
 
-  # Default to native drivers first, OSS second, SDL third
-  audio_drivers_priority = \
-    [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
-    (host_os == 'linux' ? [] : [ 'sdl' ])
-  audio_drivers_default = []
-  foreach k: audio_drivers_priority
-    if audio_drivers_available[k]
-      audio_drivers_default += k
-    endif
-  endforeach
+    # Default to native drivers first, OSS second, SDL third
+    audio_drivers_priority = \
+      [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
+      (host_os == 'linux' ? [] : [ 'sdl' ])
+    audio_drivers_default = []
+    foreach k: audio_drivers_priority
+      if audio_drivers_available[k]
+        audio_drivers_default += k
+      endif
+    endforeach
 
+    foreach k: get_option('audio_drv_list')
+      if k == 'default'
+        audio_drivers_selected += audio_drivers_default
+      elif not audio_drivers_available[k]
+        error('Audio driver "@0@" not available.'.format(k))
+      else
+        audio_drivers_selected += k
+      endif
+    endforeach
+  endif
+  config_host_data.set('CONFIG_AUDIO_DRIVERS',
+                      '"' + '", "'.join(audio_drivers_selected) + '", ')
+else
   foreach k: get_option('audio_drv_list')
-    if k == 'default'
-      audio_drivers_selected += audio_drivers_default
-    elif not audio_drivers_available[k]
-      error('Audio driver "@0@" not available.'.format(k))
-    else
-      audio_drivers_selected += k
+    if k != 'default'
+      error('Audio drivers are not supported because audio is disabled.')
     endif
   endforeach
 endif
-config_host_data.set('CONFIG_AUDIO_DRIVERS',
-                     '"' + '", "'.join(audio_drivers_selected) + '", ')
 
 have_host_block_device = (host_os != 'darwin' or
     cc.has_header('IOKit/storage/IOMedia.h'))
@@ -4660,7 +4669,8 @@ if enable_modules
   summary_info += {'alternative module path': get_option('module_upgrades')}
 endif
 summary_info += {'fuzzing support':   get_option('fuzzing')}
-if have_system
+summary_info += {'Audio':             get_option('audio')}
+if have_system and audio_enabled
   summary_info += {'Audio drivers':     ' '.join(audio_drivers_selected)}
 endif
 summary_info += {'Trace backends':    ','.join(get_option('trace_backends'))}
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17  5:27 ` [PATCH 1/8] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
@ 2026-02-17  8:40   ` Thomas Huth
  2026-02-18  7:30     ` Sergei Heifetz
  2026-02-17  9:31   ` Peter Maydell
  2026-02-17  9:44   ` Paolo Bonzini
  2 siblings, 1 reply; 32+ messages in thread
From: Thomas Huth @ 2026-02-17  8:40 UTC (permalink / raw)
  To: Sergei Heifetz, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Gerd Hoffmann,
	Laurent Vivier

  Hi!

On 17/02/2026 06.27, Sergei Heifetz wrote:
> This patch adds the `audio` option to meson_options.txt. It is
> propagated into Kconfig as AUDIO. It is enabled by default.
> The corresponding `--disable-audio` and `--enable-audio` options
> for `configure` are also added.
> 
> For now, this option does nothing. In subsequent patches, it will
> gradually disable audio in different places. The final goal is to stop
> building sources from `audio/` and `hw/audio/` and other audio-related
> files (except for some stubs). Note that this intent is different from
> `-audio none`, which mutes audio but still compiles the audio subsystem.
> 
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> ---
...
> diff --git a/configure b/configure
> index 4b61fd3bbf..ff391c79a1 100755
> --- a/configure
> +++ b/configure
> @@ -762,6 +762,10 @@ for opt do
>     ;;
>     --wasm64-32bit-address-limit)
>     ;;
> +  --enable-audio) meson_option_add -Daudio=true
> +  ;;
> +  --disable-audio) meson_option_add -Daudio=false
> +  ;;

Changing "configure" should not be necessary. Please run "make 
scripts/meson-buildoptions.sh" instead and add the generated change to that 
file to your patch instead.

  Thanks,
   Thomas



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 4/8] hw/audio/pcspk: change PCSPK behaviour with --disable-audio
  2026-02-17  5:27 ` [PATCH 4/8] hw/audio/pcspk: change PCSPK behaviour " Sergei Heifetz
@ 2026-02-17  9:14   ` Thomas Huth
  2026-02-18  7:36     ` Sergei Heifetz
  2026-02-17  9:56   ` Paolo Bonzini
  1 sibling, 1 reply; 32+ messages in thread
From: Thomas Huth @ 2026-02-17  9:14 UTC (permalink / raw)
  To: Sergei Heifetz, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Gerd Hoffmann,
	Laurent Vivier

On 17/02/2026 06.27, Sergei Heifetz wrote:
> PCSPK (PC Speaker) is an embedded audio device. We don't want it to use audio
> when QEMU is configured with `--disable-audio`. This is achieved with minimal,
> non-invasive changes to the code.
> 
> In essence, the changes ensure that PCSPK does not use the corresponding
> audio backend, while functioning the same way in non-audio aspects.
> 
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> ---
>   hw/audio/pcspk.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
> index 916c56fa4c..03fe816024 100644
> --- a/hw/audio/pcspk.c
> +++ b/hw/audio/pcspk.c
> @@ -36,10 +36,12 @@
>   #include "qom/object.h"
>   #include "trace.h"
>   
> +#ifdef CONFIG_AUDIO
>   #define PCSPK_BUF_LEN 1792
>   #define PCSPK_SAMPLE_RATE 32000
>   #define PCSPK_MAX_FREQ (PCSPK_SAMPLE_RATE >> 1)
>   #define PCSPK_MIN_COUNT DIV_ROUND_UP(PIT_FREQ, PCSPK_MAX_FREQ)
> +#endif
>   
>   OBJECT_DECLARE_SIMPLE_TYPE(PCSpkState, PC_SPEAKER)
>   
> @@ -48,18 +50,25 @@ struct PCSpkState {
>   
>       MemoryRegion ioport;
>       uint32_t iobase;
> +#ifdef CONFIG_AUDIO
>       uint8_t sample_buf[PCSPK_BUF_LEN];
> +#endif
>       AudioBackend *audio_be;
> +#ifdef CONFIG_AUDIO
>       SWVoiceOut *voice;
> +#endif
>       PITCommonState *pit;
> +#ifdef CONFIG_AUDIO
>       unsigned int pit_count;
>       unsigned int samples;
>       unsigned int play_pos;
> +#endif

Could you maybe group the fields that should get disabled together in one 
#ifdef here? ... AFAIK the order of the fields should not matter, so it 
should be ok to move them together.

  Thomas



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 5/8] Kconfig: add AUDIO dependency to audio-related devices
  2026-02-17  5:27 ` [PATCH 5/8] Kconfig: add AUDIO dependency to audio-related devices Sergei Heifetz
@ 2026-02-17  9:15   ` Thomas Huth
  0 siblings, 0 replies; 32+ messages in thread
From: Thomas Huth @ 2026-02-17  9:15 UTC (permalink / raw)
  To: Sergei Heifetz, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Gerd Hoffmann,
	Laurent Vivier

On 17/02/2026 06.27, Sergei Heifetz wrote:
> The idea of the `--disable-audio` option is to stop building audio-related
> source files. Although this is not yet implemented, we can already make
> the existing AUDIO Kconfig option a dependency for a number of devices so
> that the build does not break when we remove `audio/` and other sources.
> 
> Note that some machines have embedded audio devices and therefore cannot
> be used with `--disable-audio` at all. `-audio none` should be used for
> such machines if audio needs to be muted.
> 
> The only device that is purposefully not included in this patch is PCSPK
> (PC speaker), because its code has already been modified to work with
> `--disable-audio`.
> 
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> ---
>   hw/audio/Kconfig | 21 ++++++++++++---------
>   hw/usb/Kconfig   |  2 +-
>   2 files changed, 13 insertions(+), 10 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 3/8] tests/qtest: remove -audio none when configured with --disable-audio
  2026-02-17  5:27 ` [PATCH 3/8] tests/qtest: remove -audio none " Sergei Heifetz
@ 2026-02-17  9:19   ` Thomas Huth
  0 siblings, 0 replies; 32+ messages in thread
From: Thomas Huth @ 2026-02-17  9:19 UTC (permalink / raw)
  To: Sergei Heifetz, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Gerd Hoffmann,
	Laurent Vivier

On 17/02/2026 06.27, Sergei Heifetz wrote:
> It does not matter much whether `-audio none` is passed. In the future,
> support for `-audio none` with `--disable-audio` will be dropped, so we
> should remove it beforehand.
> 
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> ---
>   tests/qtest/libqtest.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index 794d870085..adb968f40e 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -464,7 +464,9 @@ gchar *qtest_qemu_args(const char *extra_args)
>                         "-chardev socket,path=%s,id=char0 "
>                         "-mon chardev=char0,mode=control "
>                         "-display none "
> +#ifdef CONFIG_AUDIO
>                         "-audio none "
> +#endif
>                         "%s"
>                         "%s"
>                         " -accel qtest",

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17  5:27 ` [PATCH 1/8] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
  2026-02-17  8:40   ` Thomas Huth
@ 2026-02-17  9:31   ` Peter Maydell
  2026-02-17  9:42     ` Paolo Bonzini
  2026-02-17 10:05     ` Daniel P. Berrangé
  2026-02-17  9:44   ` Paolo Bonzini
  2 siblings, 2 replies; 32+ messages in thread
From: Peter Maydell @ 2026-02-17  9:31 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Philippe Mathieu-Daudé, Alex Bennée,
	Eric Blake, Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

On Tue, 17 Feb 2026 at 05:29, Sergei Heifetz <heifetz@yandex-team.com> wrote:
>
> This patch adds the `audio` option to meson_options.txt. It is
> propagated into Kconfig as AUDIO. It is enabled by default.
> The corresponding `--disable-audio` and `--enable-audio` options
> for `configure` are also added.
>
> For now, this option does nothing. In subsequent patches, it will
> gradually disable audio in different places. The final goal is to stop
> building sources from `audio/` and `hw/audio/` and other audio-related
> files (except for some stubs). Note that this intent is different from
> `-audio none`, which mutes audio but still compiles the audio subsystem.

Not building audio/ code makes sense, but do we really want to
stop building hw/audio code ? That's the guest facing audio
devices, and if for instance a machine type has an embedded
sound device that would require us to stop compiling that
machine. I think it would be very confusing for users if
--disable-audio meant "we will silently not build half the
Arm boards that have a pl041 in them".

Maybe it would be better if "--disable-audio" meant "don't build
the audio backends, and everything behaves as if the user
passed -audio none" ?

thanks
-- PMM


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17  9:31   ` Peter Maydell
@ 2026-02-17  9:42     ` Paolo Bonzini
  2026-02-17 10:06       ` Peter Maydell
  2026-02-17 10:05     ` Daniel P. Berrangé
  1 sibling, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2026-02-17  9:42 UTC (permalink / raw)
  To: Peter Maydell, Sergei Heifetz
  Cc: qemu-devel, Philippe Mathieu-Daudé, Alex Bennée,
	Eric Blake, Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Thomas Huth, Gerd Hoffmann,
	Laurent Vivier

On 2/17/26 10:31, Peter Maydell wrote:
> On Tue, 17 Feb 2026 at 05:29, Sergei Heifetz <heifetz@yandex-team.com> wrote:
>>
>> This patch adds the `audio` option to meson_options.txt. It is
>> propagated into Kconfig as AUDIO. It is enabled by default.
>> The corresponding `--disable-audio` and `--enable-audio` options
>> for `configure` are also added.
>>
>> For now, this option does nothing. In subsequent patches, it will
>> gradually disable audio in different places. The final goal is to stop
>> building sources from `audio/` and `hw/audio/` and other audio-related
>> files (except for some stubs). Note that this intent is different from
>> `-audio none`, which mutes audio but still compiles the audio subsystem.
> 
> Not building audio/ code makes sense, but do we really want to
> stop building hw/audio code ? That's the guest facing audio
> devices, and if for instance a machine type has an embedded
> sound device that would require us to stop compiling that
> machine. I think it would be very confusing for users if
> --disable-audio meant "we will silently not build half the
> Arm boards that have a pl041 in them".
> 
> Maybe it would be better if "--disable-audio" meant "don't build
> the audio backends, and everything behaves as if the user
> passed -audio none" ?

The problem is that "-audio none" uses a silent backend but still keeps 
all the audio/ code around.  If you prefer to keep the Arm boards 
around, the solution would be to disable the audio code in the 
individual pl041 devices with "#ifdef CONFIG_AUDIO", so that the 
"depends on AUDIO" for pl041 can be removed too.

I agree that this extra ifdef-ery is not great, and it's the only thing 
that makes me pause on this series.

Paolo



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17  5:27 ` [PATCH 1/8] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
  2026-02-17  8:40   ` Thomas Huth
  2026-02-17  9:31   ` Peter Maydell
@ 2026-02-17  9:44   ` Paolo Bonzini
  2026-02-18  7:26     ` Sergei Heifetz
  2 siblings, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2026-02-17  9:44 UTC (permalink / raw)
  To: Sergei Heifetz, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Thomas Huth, Gerd Hoffmann,
	Laurent Vivier

On 2/17/26 06:27, Sergei Heifetz wrote:
> This patch adds the `audio` option to meson_options.txt. It is
> propagated into Kconfig as AUDIO. It is enabled by default.
> The corresponding `--disable-audio` and `--enable-audio` options
> for `configure` are also added.
> 
> For now, this option does nothing. In subsequent patches, it will
> gradually disable audio in different places. The final goal is to stop
> building sources from `audio/` and `hw/audio/` and other audio-related
> files (except for some stubs). Note that this intent is different from
> `-audio none`, which mutes audio but still compiles the audio subsystem.
> 
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> ---
>   Kconfig.host      | 3 +++
>   configure         | 4 ++++
>   meson.build       | 3 +++
>   meson_options.txt | 3 +++
>   4 files changed, 13 insertions(+)
> 
> diff --git a/Kconfig.host b/Kconfig.host
> index 933425c74b..ec129aa4fc 100644
> --- a/Kconfig.host
> +++ b/Kconfig.host
> @@ -29,6 +29,9 @@ config IVSHMEM
>   config TPM
>       bool
>   
> +config AUDIO
> +    bool
> +
>   config FDT
>       bool
>   
> diff --git a/configure b/configure
> index 4b61fd3bbf..ff391c79a1 100755
> --- a/configure
> +++ b/configure
> @@ -762,6 +762,10 @@ for opt do
>     ;;
>     --wasm64-32bit-address-limit)
>     ;;
> +  --enable-audio) meson_option_add -Daudio=true
> +  ;;
> +  --disable-audio) meson_option_add -Daudio=false
> +  ;;
>     # everything else has the same name in configure and meson
>     --*) meson_option_parse "$opt" "$optarg"
>     ;;
> diff --git a/meson.build b/meson.build
> index 8c6c0a9a32..69aa7cd189 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -68,6 +68,8 @@ foreach target : target_dirs
>   endforeach
>   have_user = have_linux_user or have_bsd_user
>   
> +audio_enabled = get_option('audio')

You can use

audio_enabled = get_option('audio').disable_auto_if(not have_system)

and then replace all the "if have_system and audio_enabled" with just 
"if audio_enabled".

That said, I'd rename the variable to "have_audio" for consistency with 
other names in meson.build.

Paolo

> +
>   ############
>   # Programs #
>   ############
> @@ -3244,6 +3246,7 @@ disassemblers = {
>   have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
>   host_kconfig = \
>     (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \
> +  (audio_enabled ? ['CONFIG_AUDIO=y'] : []) + \
>     (have_tpm ? ['CONFIG_TPM=y'] : []) + \
>     (pixman.found() ? ['CONFIG_PIXMAN=y'] : []) + \
>     (spice.found() ? ['CONFIG_SPICE=y'] : []) + \
> diff --git a/meson_options.txt b/meson_options.txt
> index 2836156257..172ed10ead 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -71,6 +71,9 @@ option('malloc_trim', type : 'feature', value : 'auto',
>   option('malloc', type : 'combo', choices : ['system', 'tcmalloc', 'jemalloc'],
>          value: 'system', description: 'choose memory allocator to use')
>   
> +option('audio', type: 'boolean', value: true,
> +       description: 'Audio support')
> +
>   option('kvm', type: 'feature', value: 'auto',
>          description: 'KVM acceleration support')
>   option('mshv', type: 'feature', value: 'auto',



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 7/8] audio: do not build audio-related sources with --disable-audio
  2026-02-17  5:27 ` [PATCH 7/8] audio: do not build audio-related sources with --disable-audio Sergei Heifetz
@ 2026-02-17  9:49   ` Paolo Bonzini
  2026-02-18  9:08     ` Sergei Heifetz
  0 siblings, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2026-02-17  9:49 UTC (permalink / raw)
  To: Sergei Heifetz, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Thomas Huth, Gerd Hoffmann,
	Laurent Vivier

On 2/17/26 06:27, Sergei Heifetz wrote:
> When QEMU is configured with `--disable-audio`, do not build any
> audio-related sources.
> 
> - audio/meson.build and replay/meson.build:
>    Exclude audio-related sources when audio is disabled.
> 
> - audio/audio-stub.c:
>    Provide a minimal set of straightforward stubs.
> 
> - replay/replay-audio-stub.c:
>    Move the existing stubs from replay/stubs-system.c into a separate
>    file.
> 
> - qapi/audio.json:
>    Remove the QMP `query-audiodevs` command.
> 
> - audio/audio-hmp-cmds-stub.c:
>    Provide meaningful messages for audio-related HMP commands:
>    stopcapture, wavcapture, info capture.
> 
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> ---
>   audio/audio-hmp-cmds-stub.c | 28 ++++++++++++++++++++++++++++

Can you remove the commands instead?

> +AudioBackend *audio_be_by_name(const char *name, Error **errp)
> +{
> +  error_setg(
> +      errp,
> +      "trying to find audiodev '%s' by name with audio component disabled",

This can be simplified to just  'audio disabled' or something like that.

> +      name);
> +  return NULL;
> +}
> +
> +const char *audio_be_get_id(AudioBackend *be) { return ""; }

Can you instead compile out qdev_prop_audiodev?

> +bool audio_be_set_dbus_server(AudioBackend *be,
> +                              GDBusObjectManagerServer *server, bool p2p,
> +                              Error **errp)
> +{
> +  error_setg(errp, "trying to set dbus server with audio component disabled");

Since this requires an AudioBackend, which you cannot get with audio 
disabled, it can be simply abort().

> +if audio_enabled
> +  system_ss.add(when: 'CONFIG_TCG',
> +  if_true: files('replay-audio.c'),
> +  if_false: files('replay-audio-stub.c'))
> +else
> +  system_ss.add(files('replay-audio-stub.c'))
> +endif

I think this can be simply

   system_ss.add(when: ['CONFIG_TCG', 'CONFIG_AUDIO'],
      if_true: files('replay-audio.c'),
      if_false: files('replay-audio-stub.c'))

but I may be incorrect.

Paolo



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 4/8] hw/audio/pcspk: change PCSPK behaviour with --disable-audio
  2026-02-17  5:27 ` [PATCH 4/8] hw/audio/pcspk: change PCSPK behaviour " Sergei Heifetz
  2026-02-17  9:14   ` Thomas Huth
@ 2026-02-17  9:56   ` Paolo Bonzini
  2026-02-18  8:24     ` Sergei Heifetz
  1 sibling, 1 reply; 32+ messages in thread
From: Paolo Bonzini @ 2026-02-17  9:56 UTC (permalink / raw)
  To: Sergei Heifetz, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Thomas Huth, Gerd Hoffmann,
	Laurent Vivier

On 2/17/26 06:27, Sergei Heifetz wrote:
> PCSPK (PC Speaker) is an embedded audio device. We don't want it to use audio
> when QEMU is configured with `--disable-audio`. This is achieved with minimal,
> non-invasive changes to the code.
> 
> In essence, the changes ensure that PCSPK does not use the corresponding
> audio backend, while functioning the same way in non-audio aspects.
> 
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> ---
>   hw/audio/pcspk.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
> index 916c56fa4c..03fe816024 100644
> --- a/hw/audio/pcspk.c
> +++ b/hw/audio/pcspk.c
> @@ -36,10 +36,12 @@
>   #include "qom/object.h"
>   #include "trace.h"
>   
> +#ifdef CONFIG_AUDIO
>   #define PCSPK_BUF_LEN 1792
>   #define PCSPK_SAMPLE_RATE 32000
>   #define PCSPK_MAX_FREQ (PCSPK_SAMPLE_RATE >> 1)
>   #define PCSPK_MIN_COUNT DIV_ROUND_UP(PIT_FREQ, PCSPK_MAX_FREQ)
> +#endif

Not needed.

>   
>   OBJECT_DECLARE_SIMPLE_TYPE(PCSpkState, PC_SPEAKER)
>   
> @@ -48,18 +50,25 @@ struct PCSpkState {
>   
>       MemoryRegion ioport;
>       uint32_t iobase;
> +#ifdef CONFIG_AUDIO
>       uint8_t sample_buf[PCSPK_BUF_LEN];
> +#endif
>       AudioBackend *audio_be;
> +#ifdef CONFIG_AUDIO
>       SWVoiceOut *voice;
> +#endif
>       PITCommonState *pit;
> +#ifdef CONFIG_AUDIO
>       unsigned int pit_count;
>       unsigned int samples;
>       unsigned int play_pos;
> +#endif

Please reorder the fields to have a single #ifdef/#endif.  Also leave out

DEFINE_AUDIO_PROPERTIES(PCSpkState, audio_be),

which lets you remove audio_be.

Thanks,

Paolo

>       uint8_t data_on;
>       uint8_t dummy_refresh_clock;
>       bool migrate;
>   };
>   
> +#ifdef CONFIG_AUDIO
>   static const char *s_spk = "pcspk";
>   
>   static inline void generate_samples(PCSpkState *s)
> @@ -131,6 +140,7 @@ static int pcspk_audio_init(PCSpkState *s)
>   
>       return 0;
>   }
> +#endif
>   
>   static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
>                                 unsigned size)
> @@ -161,11 +171,13 @@ static void pcspk_io_write(void *opaque, hwaddr addr, uint64_t val,
>   
>       s->data_on = (val >> 1) & 1;
>       pit_set_gate(s->pit, 2, gate);
> +#ifdef CONFIG_AUDIO
>       if (s->voice) {
>           if (gate) /* restart */
>               s->play_pos = 0;
>           AUD_set_active_out(s->voice, gate & s->data_on);
>       }
> +#endif
>   }
>   
>   static const MemoryRegionOps pcspk_io_ops = {
> @@ -196,10 +208,12 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)
>   
>       isa_register_ioport(isadev, &s->ioport, s->iobase);
>   
> +#ifdef CONFIG_AUDIO
>       if (s->audio_be && AUD_backend_check(&s->audio_be, errp)) {
>           pcspk_audio_init(s);
>           return;
>       }
> +#endif
>   }
>   
>   static bool migrate_needed(void *opaque)



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 0/8] add build option to disable audio subsystem
  2026-02-17  5:27 [PATCH 0/8] add build option to disable audio subsystem Sergei Heifetz
                   ` (7 preceding siblings ...)
  2026-02-17  5:27 ` [PATCH 8/8] meson.build: ignore audio drivers when configured " Sergei Heifetz
@ 2026-02-17  9:58 ` Marc-André Lureau
  2026-02-17 12:16   ` Sergei Heifetz
  8 siblings, 1 reply; 32+ messages in thread
From: Marc-André Lureau @ 2026-02-17  9:58 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Philippe Mathieu-Daudé, Alex Bennée,
	Eric Blake, Daniel P. Berrangé, Markus Armbruster,
	Fabiano Rosas, Paolo Bonzini, Thomas Huth, Gerd Hoffmann,
	Laurent Vivier

Hi Sergei

On Tue, Feb 17, 2026 at 6:28 AM Sergei Heifetz <heifetz@yandex-team.com> wrote:
>
> This patch series adds a compile-time option to disable building
> audio-related sources (mostly, files under `audio/` and `hw/audio/`).
> It adds `--disable-audio` and `--enable-audio` options to the
> `configure` script. Audio remains enabled by default, and the changes are
> harmless in that case.
>
> When audio is disabled, it may not be possible to build a number of
> devices and machines. This is expected, and can be addressed on a
> case-by-case basis if needed.
>
> This feature may be useful in production environments which only use a
> specific subset of QEMU’s functionality and, in particular, do not need
> the audio subsystem. In such environments it is generally beneficial to
> avoid building unused code, for both security and maintenance reasons.


I am planning to send a PR for "[PATCH 00/85] audio: cleanups & add a
manual test" soon, could you rebase your series on top?

thanks




>
> Sergei Heifetz (8):
>   audio: add `audio` build option for meson and Kconfig
>   ui/vnc: disable audio feature when configured with --disable-audio
>   tests/qtest: remove -audio none when configured with --disable-audio
>   hw/audio/pcspk: change PCSPK behaviour with --disable-audio
>   Kconfig: add AUDIO dependency to audio-related devices
>   system/vl: remove audio and audiodev options when audio is disabled
>   audio: do not build audio-related sources with --disable-audio
>   meson.build: ignore audio drivers when configured with --disable-audio
>
>  Kconfig.host                |  3 ++
>  audio/audio-hmp-cmds-stub.c | 28 +++++++++++++
>  audio/audio-stub.c          | 35 ++++++++++++++++
>  audio/meson.build           |  5 +++
>  configure                   |  4 ++
>  hw/audio/Kconfig            | 21 ++++++----
>  hw/audio/pcspk.c            | 14 +++++++
>  hw/usb/Kconfig              |  2 +-
>  meson.build                 | 83 +++++++++++++++++++++----------------
>  meson_options.txt           |  3 ++
>  qapi/audio.json             |  3 +-
>  replay/meson.build          |  9 +++-
>  replay/replay-audio-stub.c  | 16 +++++++
>  replay/stubs-system.c       |  6 ---
>  system/vl.c                 |  6 +++
>  tests/qtest/libqtest.c      |  2 +
>  ui/vnc.c                    | 31 ++++++++++++--
>  17 files changed, 215 insertions(+), 56 deletions(-)
>  create mode 100644 audio/audio-hmp-cmds-stub.c
>  create mode 100644 audio/audio-stub.c
>  create mode 100644 replay/replay-audio-stub.c
>
> --
> 2.34.1
>
>


-- 
Marc-André Lureau


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17  9:31   ` Peter Maydell
  2026-02-17  9:42     ` Paolo Bonzini
@ 2026-02-17 10:05     ` Daniel P. Berrangé
  1 sibling, 0 replies; 32+ messages in thread
From: Daniel P. Berrangé @ 2026-02-17 10:05 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Sergei Heifetz, qemu-devel, Philippe Mathieu-Daudé,
	Alex Bennée, Eric Blake, Marc-André Lureau,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Thomas Huth,
	Gerd Hoffmann, Laurent Vivier

On Tue, Feb 17, 2026 at 09:31:20AM +0000, Peter Maydell wrote:
> On Tue, 17 Feb 2026 at 05:29, Sergei Heifetz <heifetz@yandex-team.com> wrote:
> >
> > This patch adds the `audio` option to meson_options.txt. It is
> > propagated into Kconfig as AUDIO. It is enabled by default.
> > The corresponding `--disable-audio` and `--enable-audio` options
> > for `configure` are also added.
> >
> > For now, this option does nothing. In subsequent patches, it will
> > gradually disable audio in different places. The final goal is to stop
> > building sources from `audio/` and `hw/audio/` and other audio-related
> > files (except for some stubs). Note that this intent is different from
> > `-audio none`, which mutes audio but still compiles the audio subsystem.
> 
> Not building audio/ code makes sense, but do we really want to
> stop building hw/audio code ? That's the guest facing audio
> devices, and if for instance a machine type has an embedded
> sound device that would require us to stop compiling that
> machine. I think it would be very confusing for users if
> --disable-audio meant "we will silently not build half the
> Arm boards that have a pl041 in them".
> 
> Maybe it would be better if "--disable-audio" meant "don't build
> the audio backends, and everything behaves as if the user
> passed -audio none" ?

Don't we already have the ability to disable individual audio backends ?
Each of them relies on a different 3rd party library that we have to
check for, with none of them being mandatory. 

I feel like we shouldn't have a "--disable-audio" at all. For backends
we always go for having ways to disable individual dependencies, and
for frontends we provide Kconfig for fine tuning what's enabled for
a given target.

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 :|



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17  9:42     ` Paolo Bonzini
@ 2026-02-17 10:06       ` Peter Maydell
  2026-02-17 10:14         ` Daniel P. Berrangé
  2026-02-17 10:16         ` Paolo Bonzini
  0 siblings, 2 replies; 32+ messages in thread
From: Peter Maydell @ 2026-02-17 10:06 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sergei Heifetz, qemu-devel, Philippe Mathieu-Daudé,
	Alex Bennée, Eric Blake, Marc-André Lureau,
	Daniel P. Berrangé, Markus Armbruster, Fabiano Rosas,
	Thomas Huth, Gerd Hoffmann, Laurent Vivier

On Tue, 17 Feb 2026 at 09:42, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 2/17/26 10:31, Peter Maydell wrote:
> > On Tue, 17 Feb 2026 at 05:29, Sergei Heifetz <heifetz@yandex-team.com> wrote:
> >>
> >> This patch adds the `audio` option to meson_options.txt. It is
> >> propagated into Kconfig as AUDIO. It is enabled by default.
> >> The corresponding `--disable-audio` and `--enable-audio` options
> >> for `configure` are also added.
> >>
> >> For now, this option does nothing. In subsequent patches, it will
> >> gradually disable audio in different places. The final goal is to stop
> >> building sources from `audio/` and `hw/audio/` and other audio-related
> >> files (except for some stubs). Note that this intent is different from
> >> `-audio none`, which mutes audio but still compiles the audio subsystem.
> >
> > Not building audio/ code makes sense, but do we really want to
> > stop building hw/audio code ? That's the guest facing audio
> > devices, and if for instance a machine type has an embedded
> > sound device that would require us to stop compiling that
> > machine. I think it would be very confusing for users if
> > --disable-audio meant "we will silently not build half the
> > Arm boards that have a pl041 in them".
> >
> > Maybe it would be better if "--disable-audio" meant "don't build
> > the audio backends, and everything behaves as if the user
> > passed -audio none" ?
>
> The problem is that "-audio none" uses a silent backend but still keeps
> all the audio/ code around.  If you prefer to keep the Arm boards
> around, the solution would be to disable the audio code in the
> individual pl041 devices with "#ifdef CONFIG_AUDIO", so that the
> "depends on AUDIO" for pl041 can be removed too.

This seems weird, though -- why would we put in a lot of ifdefs
in every single audio device, when we could instead say "if you
disable audio at build time what you get is something that presents
the same API as the existing audio backends but does nothing" ?

Also, I think we should be consistent here, not put ifdefs in
some devices we think are "important" but skip it in others.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17 10:06       ` Peter Maydell
@ 2026-02-17 10:14         ` Daniel P. Berrangé
  2026-02-18  8:52           ` Sergei Heifetz
  2026-02-17 10:16         ` Paolo Bonzini
  1 sibling, 1 reply; 32+ messages in thread
From: Daniel P. Berrangé @ 2026-02-17 10:14 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Paolo Bonzini, Sergei Heifetz, qemu-devel,
	Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Markus Armbruster, Fabiano Rosas,
	Thomas Huth, Gerd Hoffmann, Laurent Vivier

On Tue, Feb 17, 2026 at 10:06:19AM +0000, Peter Maydell wrote:
> On Tue, 17 Feb 2026 at 09:42, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> > On 2/17/26 10:31, Peter Maydell wrote:
> > > On Tue, 17 Feb 2026 at 05:29, Sergei Heifetz <heifetz@yandex-team.com> wrote:
> > >>
> > >> This patch adds the `audio` option to meson_options.txt. It is
> > >> propagated into Kconfig as AUDIO. It is enabled by default.
> > >> The corresponding `--disable-audio` and `--enable-audio` options
> > >> for `configure` are also added.
> > >>
> > >> For now, this option does nothing. In subsequent patches, it will
> > >> gradually disable audio in different places. The final goal is to stop
> > >> building sources from `audio/` and `hw/audio/` and other audio-related
> > >> files (except for some stubs). Note that this intent is different from
> > >> `-audio none`, which mutes audio but still compiles the audio subsystem.
> > >
> > > Not building audio/ code makes sense, but do we really want to
> > > stop building hw/audio code ? That's the guest facing audio
> > > devices, and if for instance a machine type has an embedded
> > > sound device that would require us to stop compiling that
> > > machine. I think it would be very confusing for users if
> > > --disable-audio meant "we will silently not build half the
> > > Arm boards that have a pl041 in them".
> > >
> > > Maybe it would be better if "--disable-audio" meant "don't build
> > > the audio backends, and everything behaves as if the user
> > > passed -audio none" ?
> >
> > The problem is that "-audio none" uses a silent backend but still keeps
> > all the audio/ code around.  If you prefer to keep the Arm boards
> > around, the solution would be to disable the audio code in the
> > individual pl041 devices with "#ifdef CONFIG_AUDIO", so that the
> > "depends on AUDIO" for pl041 can be removed too.
> 
> This seems weird, though -- why would we put in a lot of ifdefs
> in every single audio device, when we could instead say "if you
> disable audio at build time what you get is something that presents
> the same API as the existing audio backends but does nothing" ?
>
> Also, I think we should be consistent here, not put ifdefs in
> some devices we think are "important" but skip it in others.

If we consider our security boundary guidance, none of these boards
with on-board audio frontends would be considered in scope for
security.

On arm, only the "virt" board is providing a secure deployment, and
that does not require this --disable-audio functionality.

The same applies broadly to other arch targets too, with perhaps the
only exception being the "PC speaker" on x86, and a "none" audio
backend should be sufficient there IMHO.

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 :|



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17 10:06       ` Peter Maydell
  2026-02-17 10:14         ` Daniel P. Berrangé
@ 2026-02-17 10:16         ` Paolo Bonzini
  1 sibling, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2026-02-17 10:16 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Sergei Heifetz, qemu-devel, Philippe Mathieu-Daudé,
	Alex Bennée, Eric Blake, Marc-André Lureau,
	Daniel P. Berrangé, Markus Armbruster, Fabiano Rosas,
	Thomas Huth, Gerd Hoffmann, Laurent Vivier

On Tue, Feb 17, 2026 at 11:06 AM Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Tue, 17 Feb 2026 at 09:42, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > The problem is that "-audio none" uses a silent backend but still keeps
> > all the audio/ code around.  If you prefer to keep the Arm boards
> > around, the solution would be to disable the audio code in the
> > individual pl041 devices with "#ifdef CONFIG_AUDIO", so that the
> > "depends on AUDIO" for pl041 can be removed too.
>
> This seems weird, though -- why would we put in a lot of ifdefs
> in every single audio device, when we could instead say "if you
> disable audio at build time what you get is something that presents
> the same API as the existing audio backends but does nothing" ?

Audio is special, it requires real time operation that is non-trivial
to setup and consumes CPU time (and takes the BQL, introducing jitter
in MMIO too). For pcspk for example the callback runs every 0.05
seconds (18 times a second) approximately.

The code to setup this is in audio/audio.c and is independent of the
backend. It is triggered by AUD_set_active_out (which causes
audio_is_timer_needed to return true), meaning that "-audio none" runs
a lot more code than just audio/noaudio.c.

In addition, this real time operation is reflected into the pl041's
interrupts, so you could have guest code that synchronizes itself on
audio interrupts and a hobbled pl041 might not work at all. Unlikely
for Linux guests, but bare metal code might do it.

> Also, I think we should be consistent here, not put ifdefs in
> some devices we think are "important" but skip it in others.

pcspk is indeed "important", but (especially) it has no interrupts so
there's no risk of breaking guests by removing audio output.

Paolo



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 0/8] add build option to disable audio subsystem
  2026-02-17  9:58 ` [PATCH 0/8] add build option to disable audio subsystem Marc-André Lureau
@ 2026-02-17 12:16   ` Sergei Heifetz
  0 siblings, 0 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-17 12:16 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Philippe Mathieu-Daudé, Alex Bennée,
	Eric Blake, Daniel P. Berrangé, Markus Armbruster,
	Fabiano Rosas, Paolo Bonzini, Thomas Huth, Gerd Hoffmann,
	Laurent Vivier

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

On 2/17/26 14:58, Marc-André Lureau wrote:
> I am planning to send a PR for "[PATCH 00/85] audio: cleanups & add a
> manual test" soon, could you rebase your series on top?
Hi. Yes, sure.

[-- Attachment #2: Type: text/html, Size: 596 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17  9:44   ` Paolo Bonzini
@ 2026-02-18  7:26     ` Sergei Heifetz
  0 siblings, 0 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-18  7:26 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Thomas Huth, Gerd Hoffmann,
	Laurent Vivier

[-- Attachment #1: Type: text/plain, Size: 3630 bytes --]

On 2/17/26 14:44, Paolo Bonzini wrote:
> On 2/17/26 06:27, Sergei Heifetz wrote:
>> This patch adds the `audio` option to meson_options.txt. It is
>> propagated into Kconfig as AUDIO. It is enabled by default.
>> The corresponding `--disable-audio` and `--enable-audio` options
>> for `configure` are also added.
>>
>> For now, this option does nothing. In subsequent patches, it will
>> gradually disable audio in different places. The final goal is to stop
>> building sources from `audio/` and `hw/audio/` and other audio-related
>> files (except for some stubs). Note that this intent is different from
>> `-audio none`, which mutes audio but still compiles the audio subsystem.
>>
>> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
>> ---
>>   Kconfig.host      | 3 +++
>>   configure         | 4 ++++
>>   meson.build       | 3 +++
>>   meson_options.txt | 3 +++
>>   4 files changed, 13 insertions(+)
>>
>> diff --git a/Kconfig.host b/Kconfig.host
>> index 933425c74b..ec129aa4fc 100644
>> --- a/Kconfig.host
>> +++ b/Kconfig.host
>> @@ -29,6 +29,9 @@ config IVSHMEM
>>   config TPM
>>       bool
>>   +config AUDIO
>> +    bool
>> +
>>   config FDT
>>       bool
>>   diff --git a/configure b/configure
>> index 4b61fd3bbf..ff391c79a1 100755
>> --- a/configure
>> +++ b/configure
>> @@ -762,6 +762,10 @@ for opt do
>>     ;;
>>     --wasm64-32bit-address-limit)
>>     ;;
>> +  --enable-audio) meson_option_add -Daudio=true
>> +  ;;
>> +  --disable-audio) meson_option_add -Daudio=false
>> +  ;;
>>     # everything else has the same name in configure and meson
>>     --*) meson_option_parse "$opt" "$optarg"
>>     ;;
>> diff --git a/meson.build b/meson.build
>> index 8c6c0a9a32..69aa7cd189 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -68,6 +68,8 @@ foreach target : target_dirs
>>   endforeach
>>   have_user = have_linux_user or have_bsd_user
>>   +audio_enabled = get_option('audio')
>
> You can use
>
> audio_enabled = get_option('audio').disable_auto_if(not have_system)
>
> and then replace all the "if have_system and audio_enabled" with just 
> "if audio_enabled".
>
> That said, I'd rename the variable to "have_audio" for consistency 
> with other names in meson.build.
>
> Paolo

It looks nicer this way—thanks. I’ll then make the option a feature 
rather than a boolean.

It would be `have_audio = get_option('audio').disable_auto_if(not 
have_system).*allowed()*`, though.

>
>> +
>>   ############
>>   # Programs #
>>   ############
>> @@ -3244,6 +3246,7 @@ disassemblers = {
>>   have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
>>   host_kconfig = \
>>     (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \
>> +  (audio_enabled ? ['CONFIG_AUDIO=y'] : []) + \
>>     (have_tpm ? ['CONFIG_TPM=y'] : []) + \
>>     (pixman.found() ? ['CONFIG_PIXMAN=y'] : []) + \
>>     (spice.found() ? ['CONFIG_SPICE=y'] : []) + \
>> diff --git a/meson_options.txt b/meson_options.txt
>> index 2836156257..172ed10ead 100644
>> --- a/meson_options.txt
>> +++ b/meson_options.txt
>> @@ -71,6 +71,9 @@ option('malloc_trim', type : 'feature', value : 
>> 'auto',
>>   option('malloc', type : 'combo', choices : ['system', 'tcmalloc', 
>> 'jemalloc'],
>>          value: 'system', description: 'choose memory allocator to use')
>>   +option('audio', type: 'boolean', value: true,
>> +       description: 'Audio support')
>> +
>>   option('kvm', type: 'feature', value: 'auto',
>>          description: 'KVM acceleration support')
>>   option('mshv', type: 'feature', value: 'auto',
>

[-- Attachment #2: Type: text/html, Size: 5859 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17  8:40   ` Thomas Huth
@ 2026-02-18  7:30     ` Sergei Heifetz
  0 siblings, 0 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-18  7:30 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Gerd Hoffmann,
	Laurent Vivier

On 2/17/26 13:40, Thomas Huth wrote:
>  Hi!
>
> On 17/02/2026 06.27, Sergei Heifetz wrote:
>> This patch adds the `audio` option to meson_options.txt. It is
>> propagated into Kconfig as AUDIO. It is enabled by default.
>> The corresponding `--disable-audio` and `--enable-audio` options
>> for `configure` are also added.
>>
>> For now, this option does nothing. In subsequent patches, it will
>> gradually disable audio in different places. The final goal is to stop
>> building sources from `audio/` and `hw/audio/` and other audio-related
>> files (except for some stubs). Note that this intent is different from
>> `-audio none`, which mutes audio but still compiles the audio subsystem.
>>
>> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
>> ---
> ...
>> diff --git a/configure b/configure
>> index 4b61fd3bbf..ff391c79a1 100755
>> --- a/configure
>> +++ b/configure
>> @@ -762,6 +762,10 @@ for opt do
>>     ;;
>>     --wasm64-32bit-address-limit)
>>     ;;
>> +  --enable-audio) meson_option_add -Daudio=true
>> +  ;;
>> +  --disable-audio) meson_option_add -Daudio=false
>> +  ;;
>
> Changing "configure" should not be necessary. Please run "make 
> scripts/meson-buildoptions.sh" instead and add the generated change to 
> that file to your patch instead.
>
>  Thanks,
>   Thomas
>
Oh, that's how it works. Thanks, I'll fix it.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 4/8] hw/audio/pcspk: change PCSPK behaviour with --disable-audio
  2026-02-17  9:14   ` Thomas Huth
@ 2026-02-18  7:36     ` Sergei Heifetz
  0 siblings, 0 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-18  7:36 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Paolo Bonzini, Gerd Hoffmann,
	Laurent Vivier

On 2/17/26 14:14, Thomas Huth wrote:
> On 17/02/2026 06.27, Sergei Heifetz wrote:
>> PCSPK (PC Speaker) is an embedded audio device. We don't want it to 
>> use audio
>> when QEMU is configured with `--disable-audio`. This is achieved with 
>> minimal,
>> non-invasive changes to the code.
>>
>> In essence, the changes ensure that PCSPK does not use the corresponding
>> audio backend, while functioning the same way in non-audio aspects.
>>
>> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
>> ---
>>   hw/audio/pcspk.c | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
>> index 916c56fa4c..03fe816024 100644
>> --- a/hw/audio/pcspk.c
>> +++ b/hw/audio/pcspk.c
>> @@ -36,10 +36,12 @@
>>   #include "qom/object.h"
>>   #include "trace.h"
>>   +#ifdef CONFIG_AUDIO
>>   #define PCSPK_BUF_LEN 1792
>>   #define PCSPK_SAMPLE_RATE 32000
>>   #define PCSPK_MAX_FREQ (PCSPK_SAMPLE_RATE >> 1)
>>   #define PCSPK_MIN_COUNT DIV_ROUND_UP(PIT_FREQ, PCSPK_MAX_FREQ)
>> +#endif
>>     OBJECT_DECLARE_SIMPLE_TYPE(PCSpkState, PC_SPEAKER)
>>   @@ -48,18 +50,25 @@ struct PCSpkState {
>>         MemoryRegion ioport;
>>       uint32_t iobase;
>> +#ifdef CONFIG_AUDIO
>>       uint8_t sample_buf[PCSPK_BUF_LEN];
>> +#endif
>>       AudioBackend *audio_be;
>> +#ifdef CONFIG_AUDIO
>>       SWVoiceOut *voice;
>> +#endif
>>       PITCommonState *pit;
>> +#ifdef CONFIG_AUDIO
>>       unsigned int pit_count;
>>       unsigned int samples;
>>       unsigned int play_pos;
>> +#endif
>
> Could you maybe group the fields that should get disabled together in 
> one #ifdef here? ... AFAIK the order of the fields should not matter, 
> so it should be ok to move them together.
>
>  Thomas
>
Yes, I agree — I don’t see any reason why the order would matter here. I 
just wanted to be extra careful. I’ll change it.

Thanks for reviewing.



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 4/8] hw/audio/pcspk: change PCSPK behaviour with --disable-audio
  2026-02-17  9:56   ` Paolo Bonzini
@ 2026-02-18  8:24     ` Sergei Heifetz
  0 siblings, 0 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-18  8:24 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Thomas Huth, Gerd Hoffmann,
	Laurent Vivier

On 2/17/26 14:56, Paolo Bonzini wrote:
> On 2/17/26 06:27, Sergei Heifetz wrote:
>> PCSPK (PC Speaker) is an embedded audio device. We don't want it to 
>> use audio
>> when QEMU is configured with `--disable-audio`. This is achieved with 
>> minimal,
>> non-invasive changes to the code.
>>
>> In essence, the changes ensure that PCSPK does not use the corresponding
>> audio backend, while functioning the same way in non-audio aspects.
>>
>> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
>> ---
>>   hw/audio/pcspk.c | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
>> index 916c56fa4c..03fe816024 100644
>> --- a/hw/audio/pcspk.c
>> +++ b/hw/audio/pcspk.c
>> @@ -36,10 +36,12 @@
>>   #include "qom/object.h"
>>   #include "trace.h"
>>   +#ifdef CONFIG_AUDIO
>>   #define PCSPK_BUF_LEN 1792
>>   #define PCSPK_SAMPLE_RATE 32000
>>   #define PCSPK_MAX_FREQ (PCSPK_SAMPLE_RATE >> 1)
>>   #define PCSPK_MIN_COUNT DIV_ROUND_UP(PIT_FREQ, PCSPK_MAX_FREQ)
>> +#endif
>
> Not needed.
It certainly isn’t needed, but I thought it made sense to add it for 
consistency. I’ll drop it.
>
>>     OBJECT_DECLARE_SIMPLE_TYPE(PCSpkState, PC_SPEAKER)
>>   @@ -48,18 +50,25 @@ struct PCSpkState {
>>         MemoryRegion ioport;
>>       uint32_t iobase;
>> +#ifdef CONFIG_AUDIO
>>       uint8_t sample_buf[PCSPK_BUF_LEN];
>> +#endif
>>       AudioBackend *audio_be;
>> +#ifdef CONFIG_AUDIO
>>       SWVoiceOut *voice;
>> +#endif
>>       PITCommonState *pit;
>> +#ifdef CONFIG_AUDIO
>>       unsigned int pit_count;
>>       unsigned int samples;
>>       unsigned int play_pos;
>> +#endif
>
> Please reorder the fields to have a single #ifdef/#endif. 

Ok.

>  Also leave out
>
> DEFINE_AUDIO_PROPERTIES(PCSpkState, audio_be),
>
> which lets you remove audio_be.

The reason I didn't remove audio_be initially is that it would require 
compiling out a few lines in `hw/i386/pc.c`:

```
     object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
                               OBJECT(pcms->pcspk), "audiodev");

```

I don't see any problems with that, so I can do it as well.

>
> Thanks,
>
> Paolo
>
>>       uint8_t data_on;
>>       uint8_t dummy_refresh_clock;
>>       bool migrate;
>>   };
>>   +#ifdef CONFIG_AUDIO
>>   static const char *s_spk = "pcspk";
>>     static inline void generate_samples(PCSpkState *s)
>> @@ -131,6 +140,7 @@ static int pcspk_audio_init(PCSpkState *s)
>>         return 0;
>>   }
>> +#endif
>>     static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
>>                                 unsigned size)
>> @@ -161,11 +171,13 @@ static void pcspk_io_write(void *opaque, hwaddr 
>> addr, uint64_t val,
>>         s->data_on = (val >> 1) & 1;
>>       pit_set_gate(s->pit, 2, gate);
>> +#ifdef CONFIG_AUDIO
>>       if (s->voice) {
>>           if (gate) /* restart */
>>               s->play_pos = 0;
>>           AUD_set_active_out(s->voice, gate & s->data_on);
>>       }
>> +#endif
>>   }
>>     static const MemoryRegionOps pcspk_io_ops = {
>> @@ -196,10 +208,12 @@ static void pcspk_realizefn(DeviceState *dev, 
>> Error **errp)
>>         isa_register_ioport(isadev, &s->ioport, s->iobase);
>>   +#ifdef CONFIG_AUDIO
>>       if (s->audio_be && AUD_backend_check(&s->audio_be, errp)) {
>>           pcspk_audio_init(s);
>>           return;
>>       }
>> +#endif
>>   }
>>     static bool migrate_needed(void *opaque)
>


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-17 10:14         ` Daniel P. Berrangé
@ 2026-02-18  8:52           ` Sergei Heifetz
  2026-02-18 10:50             ` Daniel P. Berrangé
  0 siblings, 1 reply; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-18  8:52 UTC (permalink / raw)
  To: Daniel P. Berrangé, Peter Maydell
  Cc: Paolo Bonzini, qemu-devel, Philippe Mathieu-Daudé,
	Alex Bennée, Eric Blake, Marc-André Lureau,
	Markus Armbruster, Fabiano Rosas, Thomas Huth, Gerd Hoffmann,
	Laurent Vivier

On 2/17/26 15:14, Daniel P. Berrangé wrote:
> On Tue, Feb 17, 2026 at 10:06:19AM +0000, Peter Maydell wrote:
>> On Tue, 17 Feb 2026 at 09:42, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>> On 2/17/26 10:31, Peter Maydell wrote:
>>>> On Tue, 17 Feb 2026 at 05:29, Sergei Heifetz <heifetz@yandex-team.com> wrote:
>>>>> This patch adds the `audio` option to meson_options.txt. It is
>>>>> propagated into Kconfig as AUDIO. It is enabled by default.
>>>>> The corresponding `--disable-audio` and `--enable-audio` options
>>>>> for `configure` are also added.
>>>>>
>>>>> For now, this option does nothing. In subsequent patches, it will
>>>>> gradually disable audio in different places. The final goal is to stop
>>>>> building sources from `audio/` and `hw/audio/` and other audio-related
>>>>> files (except for some stubs). Note that this intent is different from
>>>>> `-audio none`, which mutes audio but still compiles the audio subsystem.
>>>> Not building audio/ code makes sense, but do we really want to
>>>> stop building hw/audio code ? That's the guest facing audio
>>>> devices, and if for instance a machine type has an embedded
>>>> sound device that would require us to stop compiling that
>>>> machine. I think it would be very confusing for users if
>>>> --disable-audio meant "we will silently not build half the
>>>> Arm boards that have a pl041 in them".
>>>>
>>>> Maybe it would be better if "--disable-audio" meant "don't build
>>>> the audio backends, and everything behaves as if the user
>>>> passed -audio none" ?
>>> The problem is that "-audio none" uses a silent backend but still keeps
>>> all the audio/ code around.  If you prefer to keep the Arm boards
>>> around, the solution would be to disable the audio code in the
>>> individual pl041 devices with "#ifdef CONFIG_AUDIO", so that the
>>> "depends on AUDIO" for pl041 can be removed too.
>> This seems weird, though -- why would we put in a lot of ifdefs
>> in every single audio device, when we could instead say "if you
>> disable audio at build time what you get is something that presents
>> the same API as the existing audio backends but does nothing" ?
>>
>> Also, I think we should be consistent here, not put ifdefs in
>> some devices we think are "important" but skip it in others.
> If we consider our security boundary guidance, none of these boards
> with on-board audio frontends would be considered in scope for
> security.
>
> On arm, only the "virt" board is providing a secure deployment, and
> that does not require this --disable-audio functionality.
>
> The same applies broadly to other arch targets too, with perhaps the
> only exception being the "PC speaker" on x86, and a "none" audio
> backend should be sufficient there IMHO.
>
> With regards,
> Daniel
In some production environments, static analysers are used as part of 
broader security measures. If such an analyser reports a problem in an 
unused part of the code, you can’t simply ignore it because it’s unused: 
you either fix the issue (which is a strange thing to do for unused 
code) or remove the unused part. This is a general point about why such 
functionality may be useful for some users.

Other audio-specific reasons for having this option are already 
described by Paolo: 
https://mail.gnu.org/archive/html/qemu-devel/2026-02/msg04410.html.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 7/8] audio: do not build audio-related sources with --disable-audio
  2026-02-17  9:49   ` Paolo Bonzini
@ 2026-02-18  9:08     ` Sergei Heifetz
  0 siblings, 0 replies; 32+ messages in thread
From: Sergei Heifetz @ 2026-02-18  9:08 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel
  Cc: Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Daniel P. Berrangé,
	Markus Armbruster, Fabiano Rosas, Thomas Huth, Gerd Hoffmann,
	Laurent Vivier

On 2/17/26 14:49, Paolo Bonzini wrote:
> On 2/17/26 06:27, Sergei Heifetz wrote:
>> When QEMU is configured with `--disable-audio`, do not build any
>> audio-related sources.
>>
>> - audio/meson.build and replay/meson.build:
>>    Exclude audio-related sources when audio is disabled.
>>
>> - audio/audio-stub.c:
>>    Provide a minimal set of straightforward stubs.
>>
>> - replay/replay-audio-stub.c:
>>    Move the existing stubs from replay/stubs-system.c into a separate
>>    file.
>>
>> - qapi/audio.json:
>>    Remove the QMP `query-audiodevs` command.
>>
>> - audio/audio-hmp-cmds-stub.c:
>>    Provide meaningful messages for audio-related HMP commands:
>>    stopcapture, wavcapture, info capture.
>>
>> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
>> ---
>>   audio/audio-hmp-cmds-stub.c | 28 ++++++++++++++++++++++++++++
>
> Can you remove the commands instead?
>
Yes, sure.
>> +AudioBackend *audio_be_by_name(const char *name, Error **errp)
>> +{
>> +  error_setg(
>> +      errp,
>> +      "trying to find audiodev '%s' by name with audio component 
>> disabled",
>
> This can be simplified to just  'audio disabled' or something like that.
Ok.
>
>> +      name);
>> +  return NULL;
>> +}
>> +
>> +const char *audio_be_get_id(AudioBackend *be) { return ""; }
>
> Can you instead compile out qdev_prop_audiodev?
I think so. I'll try it.
>
>> +bool audio_be_set_dbus_server(AudioBackend *be,
>> +                              GDBusObjectManagerServer *server, bool 
>> p2p,
>> +                              Error **errp)
>> +{
>> +  error_setg(errp, "trying to set dbus server with audio component 
>> disabled");
>
> Since this requires an AudioBackend, which you cannot get with audio 
> disabled, it can be simply abort().
That's reasonable, I'll replace it with abort().
>
>> +if audio_enabled
>> +  system_ss.add(when: 'CONFIG_TCG',
>> +  if_true: files('replay-audio.c'),
>> +  if_false: files('replay-audio-stub.c'))
>> +else
>> +  system_ss.add(files('replay-audio-stub.c'))
>> +endif
>
> I think this can be simply
>
>   system_ss.add(when: ['CONFIG_TCG', 'CONFIG_AUDIO'],
>      if_true: files('replay-audio.c'),
>      if_false: files('replay-audio-stub.c'))
>
> but I may be incorrect.
>
I’ve already tried it, and it doesn’t work for some reason.
> Paolo
>
Thank you for reviewing and for participating in the discussion about 
the series. I probably wouldn’t have been able to summarise the points 
as clearly myself.



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-18  8:52           ` Sergei Heifetz
@ 2026-02-18 10:50             ` Daniel P. Berrangé
  2026-02-18 12:55               ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 32+ messages in thread
From: Daniel P. Berrangé @ 2026-02-18 10:50 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: Peter Maydell, Paolo Bonzini, qemu-devel,
	Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Markus Armbruster, Fabiano Rosas,
	Thomas Huth, Gerd Hoffmann, Laurent Vivier

On Wed, Feb 18, 2026 at 01:52:06PM +0500, Sergei Heifetz wrote:
> On 2/17/26 15:14, Daniel P. Berrangé wrote:
> > On Tue, Feb 17, 2026 at 10:06:19AM +0000, Peter Maydell wrote:
> > > On Tue, 17 Feb 2026 at 09:42, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > > > On 2/17/26 10:31, Peter Maydell wrote:
> > > > > On Tue, 17 Feb 2026 at 05:29, Sergei Heifetz <heifetz@yandex-team.com> wrote:
> > > > > > This patch adds the `audio` option to meson_options.txt. It is
> > > > > > propagated into Kconfig as AUDIO. It is enabled by default.
> > > > > > The corresponding `--disable-audio` and `--enable-audio` options
> > > > > > for `configure` are also added.
> > > > > > 
> > > > > > For now, this option does nothing. In subsequent patches, it will
> > > > > > gradually disable audio in different places. The final goal is to stop
> > > > > > building sources from `audio/` and `hw/audio/` and other audio-related
> > > > > > files (except for some stubs). Note that this intent is different from
> > > > > > `-audio none`, which mutes audio but still compiles the audio subsystem.
> > > > > Not building audio/ code makes sense, but do we really want to
> > > > > stop building hw/audio code ? That's the guest facing audio
> > > > > devices, and if for instance a machine type has an embedded
> > > > > sound device that would require us to stop compiling that
> > > > > machine. I think it would be very confusing for users if
> > > > > --disable-audio meant "we will silently not build half the
> > > > > Arm boards that have a pl041 in them".
> > > > > 
> > > > > Maybe it would be better if "--disable-audio" meant "don't build
> > > > > the audio backends, and everything behaves as if the user
> > > > > passed -audio none" ?
> > > > The problem is that "-audio none" uses a silent backend but still keeps
> > > > all the audio/ code around.  If you prefer to keep the Arm boards
> > > > around, the solution would be to disable the audio code in the
> > > > individual pl041 devices with "#ifdef CONFIG_AUDIO", so that the
> > > > "depends on AUDIO" for pl041 can be removed too.
> > > This seems weird, though -- why would we put in a lot of ifdefs
> > > in every single audio device, when we could instead say "if you
> > > disable audio at build time what you get is something that presents
> > > the same API as the existing audio backends but does nothing" ?
> > > 
> > > Also, I think we should be consistent here, not put ifdefs in
> > > some devices we think are "important" but skip it in others.
> > If we consider our security boundary guidance, none of these boards
> > with on-board audio frontends would be considered in scope for
> > security.
> > 
> > On arm, only the "virt" board is providing a secure deployment, and
> > that does not require this --disable-audio functionality.
> > 
> > The same applies broadly to other arch targets too, with perhaps the
> > only exception being the "PC speaker" on x86, and a "none" audio
> > backend should be sufficient there IMHO.
> > 
> > With regards,
> > Daniel
> In some production environments, static analysers are used as part of
> broader security measures. If such an analyser reports a problem in an
> unused part of the code, you can’t simply ignore it because it’s unused: you
> either fix the issue (which is a strange thing to do for unused code) or
> remove the unused part. This is a general point about why such functionality
> may be useful for some users.

IMHO "static analysers complain" is way too weak a justification
for taking on this work. Code analysers are always incredibly noisy
and reporting complaints about things that are not worth the cost
of addressing.

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 :|



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/8] audio: add `audio` build option for meson and Kconfig
  2026-02-18 10:50             ` Daniel P. Berrangé
@ 2026-02-18 12:55               ` Vladimir Sementsov-Ogievskiy
  0 siblings, 0 replies; 32+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2026-02-18 12:55 UTC (permalink / raw)
  To: Daniel P. Berrangé, Sergei Heifetz
  Cc: Peter Maydell, Paolo Bonzini, qemu-devel,
	Philippe Mathieu-Daudé, Alex Bennée, Eric Blake,
	Marc-André Lureau, Markus Armbruster, Fabiano Rosas,
	Thomas Huth, Gerd Hoffmann, Laurent Vivier

On 18.02.26 13:50, Daniel P. Berrangé wrote:
> On Wed, Feb 18, 2026 at 01:52:06PM +0500, Sergei Heifetz wrote:
>> On 2/17/26 15:14, Daniel P. Berrangé wrote:
>>> On Tue, Feb 17, 2026 at 10:06:19AM +0000, Peter Maydell wrote:
>>>> On Tue, 17 Feb 2026 at 09:42, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>>>> On 2/17/26 10:31, Peter Maydell wrote:
>>>>>> On Tue, 17 Feb 2026 at 05:29, Sergei Heifetz <heifetz@yandex-team.com> wrote:
>>>>>>> This patch adds the `audio` option to meson_options.txt. It is
>>>>>>> propagated into Kconfig as AUDIO. It is enabled by default.
>>>>>>> The corresponding `--disable-audio` and `--enable-audio` options
>>>>>>> for `configure` are also added.
>>>>>>>
>>>>>>> For now, this option does nothing. In subsequent patches, it will
>>>>>>> gradually disable audio in different places. The final goal is to stop
>>>>>>> building sources from `audio/` and `hw/audio/` and other audio-related
>>>>>>> files (except for some stubs). Note that this intent is different from
>>>>>>> `-audio none`, which mutes audio but still compiles the audio subsystem.
>>>>>> Not building audio/ code makes sense, but do we really want to
>>>>>> stop building hw/audio code ? That's the guest facing audio
>>>>>> devices, and if for instance a machine type has an embedded
>>>>>> sound device that would require us to stop compiling that
>>>>>> machine. I think it would be very confusing for users if
>>>>>> --disable-audio meant "we will silently not build half the
>>>>>> Arm boards that have a pl041 in them".
>>>>>>
>>>>>> Maybe it would be better if "--disable-audio" meant "don't build
>>>>>> the audio backends, and everything behaves as if the user
>>>>>> passed -audio none" ?
>>>>> The problem is that "-audio none" uses a silent backend but still keeps
>>>>> all the audio/ code around.  If you prefer to keep the Arm boards
>>>>> around, the solution would be to disable the audio code in the
>>>>> individual pl041 devices with "#ifdef CONFIG_AUDIO", so that the
>>>>> "depends on AUDIO" for pl041 can be removed too.
>>>> This seems weird, though -- why would we put in a lot of ifdefs
>>>> in every single audio device, when we could instead say "if you
>>>> disable audio at build time what you get is something that presents
>>>> the same API as the existing audio backends but does nothing" ?
>>>>
>>>> Also, I think we should be consistent here, not put ifdefs in
>>>> some devices we think are "important" but skip it in others.
>>> If we consider our security boundary guidance, none of these boards
>>> with on-board audio frontends would be considered in scope for
>>> security.
>>>
>>> On arm, only the "virt" board is providing a secure deployment, and
>>> that does not require this --disable-audio functionality.
>>>
>>> The same applies broadly to other arch targets too, with perhaps the
>>> only exception being the "PC speaker" on x86, and a "none" audio
>>> backend should be sufficient there IMHO.
>>>
>>> With regards,
>>> Daniel
>> In some production environments, static analysers are used as part of
>> broader security measures. If such an analyser reports a problem in an
>> unused part of the code, you can’t simply ignore it because it’s unused: you
>> either fix the issue (which is a strange thing to do for unused code) or
>> remove the unused part. This is a general point about why such functionality
>> may be useful for some users.
> 
> IMHO "static analysers complain" is way too weak a justification
> for taking on this work. Code analysers are always incredibly noisy
> and reporting complaints about things that are not worth the cost
> of addressing.
> 

Still we consider such complains as a good reason to drop extra code from
our production build. If we have to spend some time handling Coverity
complains, why not just drop extra parts we don't use, so that static
analyzers will never disturb us about these parts since removal?

Regardless static analyzers, I think it's always good to have a possibility
to not build for production the code which you don't need and don't want to
understand and support.

-- 
Best regards,
Vladimir


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2026-02-18 12:55 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-17  5:27 [PATCH 0/8] add build option to disable audio subsystem Sergei Heifetz
2026-02-17  5:27 ` [PATCH 1/8] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
2026-02-17  8:40   ` Thomas Huth
2026-02-18  7:30     ` Sergei Heifetz
2026-02-17  9:31   ` Peter Maydell
2026-02-17  9:42     ` Paolo Bonzini
2026-02-17 10:06       ` Peter Maydell
2026-02-17 10:14         ` Daniel P. Berrangé
2026-02-18  8:52           ` Sergei Heifetz
2026-02-18 10:50             ` Daniel P. Berrangé
2026-02-18 12:55               ` Vladimir Sementsov-Ogievskiy
2026-02-17 10:16         ` Paolo Bonzini
2026-02-17 10:05     ` Daniel P. Berrangé
2026-02-17  9:44   ` Paolo Bonzini
2026-02-18  7:26     ` Sergei Heifetz
2026-02-17  5:27 ` [PATCH 2/8] ui/vnc: disable audio feature when configured with --disable-audio Sergei Heifetz
2026-02-17  5:27 ` [PATCH 3/8] tests/qtest: remove -audio none " Sergei Heifetz
2026-02-17  9:19   ` Thomas Huth
2026-02-17  5:27 ` [PATCH 4/8] hw/audio/pcspk: change PCSPK behaviour " Sergei Heifetz
2026-02-17  9:14   ` Thomas Huth
2026-02-18  7:36     ` Sergei Heifetz
2026-02-17  9:56   ` Paolo Bonzini
2026-02-18  8:24     ` Sergei Heifetz
2026-02-17  5:27 ` [PATCH 5/8] Kconfig: add AUDIO dependency to audio-related devices Sergei Heifetz
2026-02-17  9:15   ` Thomas Huth
2026-02-17  5:27 ` [PATCH 6/8] system/vl: remove audio and audiodev options when audio is disabled Sergei Heifetz
2026-02-17  5:27 ` [PATCH 7/8] audio: do not build audio-related sources with --disable-audio Sergei Heifetz
2026-02-17  9:49   ` Paolo Bonzini
2026-02-18  9:08     ` Sergei Heifetz
2026-02-17  5:27 ` [PATCH 8/8] meson.build: ignore audio drivers when configured " Sergei Heifetz
2026-02-17  9:58 ` [PATCH 0/8] add build option to disable audio subsystem Marc-André Lureau
2026-02-17 12:16   ` Sergei Heifetz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.