All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/10] add build option to disable audio subsystem
@ 2026-02-23 20:25 Sergei Heifetz
  2026-02-23 20:25 ` [PATCH v2 01/10] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
                   ` (9 more replies)
  0 siblings, 10 replies; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

This 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. For now, this is done only for the
PC Speaker (PCSPK).

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
(for example, to satisfy various static code analysers).

Changes since v1:
- Rebased onto the master branch (in particular, onto the changes from the
  large series submitted by Marc-André Lureau).
- D-Bus is now handled differently when audio is disabled: instead of
  interrupting initialisation, we simply don’t initialise the audio
  interface.
- Incorporated a few changes suggested by Paolo Bonzini and Thomas Huth.
  The main ones are:
  - Cleaned up the PCSPK changes (removed redundant ifdefs and the
    `audio_be` field).
  - Removed the HMP commands rather than stubbing them out.
  - Replaced the `configure` change with a change in
    `scripts/meson-buildoptions.sh`.
  - Removed `qdev_prop_audiodev` in `hw/core/qdev-properties-system.c`
    rather than stubbing out `audio_be_get_id`.
  (Here "removed" means adding an appropriate ifdef.)

Sergei Heifetz (10):
  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
  ui/dbus: run without Audio interface when audio is disabled
  tests/audio: do not compile if 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-stub.c               | 22 +++++++++
 audio/meson.build                |  5 ++
 hmp-commands-info.hx             |  2 +
 hmp-commands.hx                  |  2 +
 hw/audio/Kconfig                 | 21 ++++----
 hw/audio/pcspk.c                 | 12 ++++-
 hw/core/qdev-properties-system.c |  2 +
 hw/i386/pc.c                     |  2 +
 hw/usb/Kconfig                   |  2 +-
 meson.build                      | 83 ++++++++++++++++++--------------
 meson_options.txt                |  3 ++
 qapi/audio.json                  |  3 +-
 replay/meson.build               |  9 +++-
 replay/replay-audio-stub.c       | 21 ++++++++
 replay/stubs-system.c            | 12 -----
 scripts/meson-buildoptions.sh    |  3 ++
 system/vl.c                      |  6 +++
 tests/audio/meson.build          |  2 +-
 tests/qtest/libqtest.c           |  2 +
 ui/dbus.c                        |  2 +
 ui/vnc.c                         | 31 ++++++++++--
 22 files changed, 186 insertions(+), 64 deletions(-)
 create mode 100644 audio/audio-stub.c
 create mode 100644 replay/replay-audio-stub.c

-- 
2.34.1



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

* [PATCH v2 01/10] audio: add `audio` build option for meson and Kconfig
  2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
@ 2026-02-23 20:25 ` Sergei Heifetz
  2026-02-24 11:05   ` Marc-André Lureau
  2026-02-23 20:25 ` [PATCH v2 02/10] ui/vnc: disable audio feature when configured with --disable-audio Sergei Heifetz
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

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 +++
 meson.build                   | 3 +++
 meson_options.txt             | 3 +++
 scripts/meson-buildoptions.sh | 3 +++
 4 files changed, 12 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/meson.build b/meson.build
index 414c8ea7e2..fdb2578447 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
 
+have_audio = get_option('audio').disable_auto_if(not have_system).allowed()
+
 ############
 # Programs #
 ############
@@ -3250,6 +3252,7 @@ disassemblers = {
 have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
 host_kconfig = \
   (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \
+  (have_audio ? ['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..d7c94e6d6d 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: 'feature', value: 'auto',
+       description: 'Audio support')
+
 option('kvm', type: 'feature', value: 'auto',
        description: 'KVM acceleration support')
 option('mshv', type: 'feature', value: 'auto',
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index e8edc5252a..642f06efc5 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -96,6 +96,7 @@ meson_options_help() {
   printf "%s\n" '  af-xdp          AF_XDP network backend support'
   printf "%s\n" '  alsa            ALSA sound support'
   printf "%s\n" '  attr            attr/xattr support'
+  printf "%s\n" '  audio           Audio support'
   printf "%s\n" '  auth-pam        PAM access control'
   printf "%s\n" '  blkio           libblkio block device driver'
   printf "%s\n" '  bochs           bochs image format support'
@@ -242,6 +243,8 @@ _meson_option_parse() {
     --disable-asan) printf "%s" -Dasan=false ;;
     --enable-attr) printf "%s" -Dattr=enabled ;;
     --disable-attr) printf "%s" -Dattr=disabled ;;
+    --enable-audio) printf "%s" -Daudio=enabled ;;
+    --disable-audio) printf "%s" -Daudio=disabled ;;
     --audio-drv-list=*) quote_sh "-Daudio_drv_list=$2" ;;
     --enable-auth-pam) printf "%s" -Dauth_pam=enabled ;;
     --disable-auth-pam) printf "%s" -Dauth_pam=disabled ;;
-- 
2.34.1



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

* [PATCH v2 02/10] ui/vnc: disable audio feature when configured with --disable-audio
  2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
  2026-02-23 20:25 ` [PATCH v2 01/10] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
@ 2026-02-23 20:25 ` Sergei Heifetz
  2026-02-24 11:05   ` Marc-André Lureau
  2026-02-23 20:25 ` [PATCH v2 03/10] tests/qtest: remove -audio none " Sergei Heifetz
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

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 daf5b01d34..e6b6a9f4f9 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.big_endian = false;
+#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] 27+ messages in thread

* [PATCH v2 03/10] tests/qtest: remove -audio none when configured with --disable-audio
  2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
  2026-02-23 20:25 ` [PATCH v2 01/10] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
  2026-02-23 20:25 ` [PATCH v2 02/10] ui/vnc: disable audio feature when configured with --disable-audio Sergei Heifetz
@ 2026-02-23 20:25 ` Sergei Heifetz
  2026-02-24 11:05   ` Marc-André Lureau
  2026-02-23 20:25 ` [PATCH v2 04/10] hw/audio/pcspk: change PCSPK behaviour " Sergei Heifetz
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

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>
Reviewed-by: Thomas Huth <thuth@redhat.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] 27+ messages in thread

* [PATCH v2 04/10] hw/audio/pcspk: change PCSPK behaviour with --disable-audio
  2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
                   ` (2 preceding siblings ...)
  2026-02-23 20:25 ` [PATCH v2 03/10] tests/qtest: remove -audio none " Sergei Heifetz
@ 2026-02-23 20:25 ` Sergei Heifetz
  2026-02-24 11:05   ` Marc-André Lureau
  2026-02-23 20:25 ` [PATCH v2 05/10] Kconfig: add AUDIO dependency to audio-related devices Sergei Heifetz
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

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 have a 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 | 12 +++++++++++-
 hw/i386/pc.c     |  2 ++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index 6b826507ce..54e1882265 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -48,17 +48,20 @@ struct PCSpkState {
 
     MemoryRegion ioport;
     uint32_t iobase;
+    PITCommonState *pit;
+#ifdef CONFIG_AUDIO
     uint8_t sample_buf[PCSPK_BUF_LEN];
     AudioBackend *audio_be;
     SWVoiceOut *voice;
-    PITCommonState *pit;
     unsigned int pit_count;
     unsigned int samples;
     unsigned int play_pos;
+#endif
     uint8_t data_on;
     uint8_t dummy_refresh_clock;
 };
 
+#ifdef CONFIG_AUDIO
 static const char *s_spk = "pcspk";
 
 static inline void generate_samples(PCSpkState *s)
@@ -130,6 +133,7 @@ static int pcspk_audio_init(PCSpkState *s)
 
     return 0;
 }
+#endif
 
 static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
                               unsigned size)
@@ -160,11 +164,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;
         audio_be_set_active_out(s->audio_be, s->voice, gate & s->data_on);
     }
+#endif
 }
 
 static const MemoryRegionOps pcspk_io_ops = {
@@ -195,10 +201,12 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)
 
     isa_register_ioport(isadev, &s->ioport, s->iobase);
 
+#ifdef CONFIG_AUDIO
     if (s->audio_be && audio_be_check(&s->audio_be, errp)) {
         pcspk_audio_init(s);
         return;
     }
+#endif
 }
 
 static const VMStateDescription vmstate_spk = {
@@ -213,7 +221,9 @@ static const VMStateDescription vmstate_spk = {
 };
 
 static const Property pcspk_properties[] = {
+#ifdef CONFIG_AUDIO
     DEFINE_AUDIO_PROPERTIES(PCSpkState, audio_be),
+#endif
     DEFINE_PROP_UINT32("iobase", PCSpkState, iobase,  0x61),
     DEFINE_PROP_LINK("pit", PCSpkState, pit, TYPE_PIT_COMMON, PITCommonState *),
 };
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 0dd3fd01d9..3992553c2a 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1679,8 +1679,10 @@ static void pc_machine_initfn(Object *obj)
 
     pc_system_flash_create(pcms);
     pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
+#ifdef CONFIG_AUDIO
     object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
                               OBJECT(pcms->pcspk), "audiodev");
+#endif
     if (pcmc->pci_enabled) {
         cxl_machine_init(obj, &pcms->cxl_devices_state);
     }
-- 
2.34.1



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

* [PATCH v2 05/10] Kconfig: add AUDIO dependency to audio-related devices
  2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
                   ` (3 preceding siblings ...)
  2026-02-23 20:25 ` [PATCH v2 04/10] hw/audio/pcspk: change PCSPK behaviour " Sergei Heifetz
@ 2026-02-23 20:25 ` Sergei Heifetz
  2026-02-24 11:06   ` Marc-André Lureau
  2026-02-23 20:25 ` [PATCH v2 06/10] system/vl: remove audio and audiodev options when audio is disabled Sergei Heifetz
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

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>
Reviewed-by: Thomas Huth <thuth@redhat.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] 27+ messages in thread

* [PATCH v2 06/10] system/vl: remove audio and audiodev options when audio is disabled
  2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
                   ` (4 preceding siblings ...)
  2026-02-23 20:25 ` [PATCH v2 05/10] Kconfig: add AUDIO dependency to audio-related devices Sergei Heifetz
@ 2026-02-23 20:25 ` Sergei Heifetz
  2026-02-24 11:06   ` Marc-André Lureau
  2026-02-23 20:25 ` [PATCH v2 07/10] ui/dbus: run without Audio interface " Sergei Heifetz
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

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 3e341142a0..1034a4688f 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")) {
         /*
@@ -3057,6 +3061,7 @@ void qemu_init(int argc, char **argv)
                 }
                 break;
 #endif
+#ifdef CONFIG_AUDIO
             case QEMU_OPTION_audiodev:
                 default_audio = 0;
                 audio_parse_option(optarg);
@@ -3097,6 +3102,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] 27+ messages in thread

* [PATCH v2 07/10] ui/dbus: run without Audio interface when audio is disabled
  2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
                   ` (5 preceding siblings ...)
  2026-02-23 20:25 ` [PATCH v2 06/10] system/vl: remove audio and audiodev options when audio is disabled Sergei Heifetz
@ 2026-02-23 20:25 ` Sergei Heifetz
  2026-02-24 11:06   ` Marc-André Lureau
  2026-02-23 20:25 ` [PATCH v2 08/10] tests/audio: do not compile if " Sergei Heifetz
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

D-Bus display can be used even when QEMU is configured with
`--disable-audio`. In that case, audio interface will not be available
on `/org/qemu/Display1/Audio`.

(The current handling of the situation when audio is enabled but
no D-Bus-compatible audio backend is available is different and
hasn’t been changed.)

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

diff --git a/ui/dbus.c b/ui/dbus.c
index 905ee6fea7..60c8e0b473 100644
--- a/ui/dbus.c
+++ b/ui/dbus.c
@@ -219,6 +219,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp)
         return;
     }
 
+#ifdef CONFIG_AUDIO
     {
         AudioBackend *audio_be = audio_get_default_audio_be(NULL);
         if (audio_be && !audio_be_can_set_dbus_server(audio_be)) {
@@ -234,6 +235,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp)
             return;
         }
     }
+#endif
 
     consoles = g_array_new(FALSE, FALSE, sizeof(guint32));
     for (idx = 0;; idx++) {
-- 
2.34.1



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

* [PATCH v2 08/10] tests/audio: do not compile if audio is disabled
  2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
                   ` (6 preceding siblings ...)
  2026-02-23 20:25 ` [PATCH v2 07/10] ui/dbus: run without Audio interface " Sergei Heifetz
@ 2026-02-23 20:25 ` Sergei Heifetz
  2026-02-24 11:06   ` Marc-André Lureau
  2026-02-23 20:25 ` [PATCH v2 09/10] audio: do not build audio-related sources with --disable-audio Sergei Heifetz
  2026-02-23 20:25 ` [PATCH v2 10/10] meson.build: ignore audio drivers when configured " Sergei Heifetz
  9 siblings, 1 reply; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

If QEMU is configured with --disable-audio, do not compile the audio
tests.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 tests/audio/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/audio/meson.build b/tests/audio/meson.build
index 84754bde22..97c1d623bb 100644
--- a/tests/audio/meson.build
+++ b/tests/audio/meson.build
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-if not have_system
+if not have_audio
   subdir_done()
 endif
 
-- 
2.34.1



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

* [PATCH v2 09/10] audio: do not build audio-related sources with --disable-audio
  2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
                   ` (7 preceding siblings ...)
  2026-02-23 20:25 ` [PATCH v2 08/10] tests/audio: do not compile if " Sergei Heifetz
@ 2026-02-23 20:25 ` Sergei Heifetz
  2026-02-24  8:02   ` Markus Armbruster
  2026-02-23 20:25 ` [PATCH v2 10/10] meson.build: ignore audio drivers when configured " Sergei Heifetz
  9 siblings, 1 reply; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

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.

- hmp-commands*.hx:
  Remove the HMP `info capture`, `stopcapture` and `wavcapture`
  commands.

Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
---
 audio/audio-stub.c               | 22 ++++++++++++++++++++++
 audio/meson.build                |  5 +++++
 hmp-commands-info.hx             |  2 ++
 hmp-commands.hx                  |  2 ++
 hw/core/qdev-properties-system.c |  2 ++
 qapi/audio.json                  |  3 ++-
 replay/meson.build               |  9 ++++++++-
 replay/replay-audio-stub.c       | 21 +++++++++++++++++++++
 replay/stubs-system.c            | 12 ------------
 9 files changed, 64 insertions(+), 14 deletions(-)
 create mode 100644 audio/audio-stub.c
 create mode 100644 replay/replay-audio-stub.c

diff --git a/audio/audio-stub.c b/audio/audio-stub.c
new file mode 100644
index 0000000000..f58f88cd83
--- /dev/null
+++ b/audio/audio-stub.c
@@ -0,0 +1,22 @@
+/*
+ * 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, "audio disabled");
+  return NULL;
+}
+
+void audio_init_audiodevs(void) {}
+
+void audio_create_default_audiodevs(void) {}
diff --git a/audio/meson.build b/audio/meson.build
index 0e33b6f983..19d43dc315 100644
--- a/audio/meson.build
+++ b/audio/meson.build
@@ -1,4 +1,9 @@
 audio_ss = ss.source_set()
+if not have_audio
+  audio_ss.add(files('audio-stub.c'))
+  subdir_done()
+endif
+
 audio_ss.add(files(
   'audio.c',
   'audio-be.c',
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 74c741f80e..a959479024 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -364,6 +364,7 @@ SRST
 ERST
 
 /* BEGIN deprecated */
+#ifdef CONFIG_AUDIO
     {
         .name       = "capture",
         .args_type  = "",
@@ -376,6 +377,7 @@ SRST
   ``info capture``
     Show capture information (deprecated).
 ERST
+#endif
 /* END deprecated */
 
     {
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 5cc4788f12..e8b8175bb9 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -765,6 +765,7 @@ SRST
 ERST
 
 /* BEGIN deprecated */
+#ifdef CONFIG_AUDIO
     {
         .name       = "wavcapture",
         .args_type  = "path:F,audiodev:s,freq:i?,bits:i?,nchannels:i?",
@@ -802,6 +803,7 @@ SRST
 
   Deprecated.
 ERST
+#endif
 /* END deprecated */
 
     {
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index a402321f42..8679a71b53 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -483,6 +483,7 @@ const PropertyInfo qdev_prop_netdev = {
 };
 
 
+#ifdef CONFIG_AUDIO
 /* --- audiodev --- */
 static void get_audiodev(Object *obj, Visitor *v, const char* name,
                          void *opaque, Error **errp)
@@ -519,6 +520,7 @@ const PropertyInfo qdev_prop_audiodev = {
     .get = get_audiodev,
     .set = set_audiodev,
 };
+#endif
 
 bool qdev_prop_set_drive_err(DeviceState *dev, const char *name,
                              BlockBackend *value, Error **errp)
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..dc2e94e897 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 have_audio
+  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..b3da8e1558
--- /dev/null
+++ b/replay/replay-audio-stub.c
@@ -0,0 +1,21 @@
+/*
+ * 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_start(size_t *nsamples)
+{
+}
+void replay_audio_in_sample_lr(uint64_t *left, uint64_t *right)
+{
+}
+void replay_audio_in_finish(void)
+{
+}
+void replay_audio_out(size_t *played)
+{
+}
diff --git a/replay/stubs-system.c b/replay/stubs-system.c
index b2c52bc404..454415ae8e 100644
--- a/replay/stubs-system.c
+++ b/replay/stubs-system.c
@@ -15,18 +15,6 @@ void replay_input_sync_event(void)
 void replay_add_blocker(const char *feature)
 {
 }
-void replay_audio_in_start(size_t *nsamples)
-{
-}
-void replay_audio_in_sample_lr(uint64_t *left, uint64_t *right)
-{
-}
-void replay_audio_in_finish(void)
-{
-}
-void replay_audio_out(size_t *played)
-{
-}
 void replay_breakpoint(void)
 {
 }
-- 
2.34.1



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

* [PATCH v2 10/10] meson.build: ignore audio drivers when configured with --disable-audio
  2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
                   ` (8 preceding siblings ...)
  2026-02-23 20:25 ` [PATCH v2 09/10] audio: do not build audio-related sources with --disable-audio Sergei Heifetz
@ 2026-02-23 20:25 ` Sergei Heifetz
  2026-02-24 11:05   ` Marc-André Lureau
  9 siblings, 1 reply; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-23 20:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Marcel Apfelbaum, Marc-André Lureau,
	Paolo Bonzini, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Markus Armbruster,
	Dr. David Alan Gilbert

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 fdb2578447..ae71a0dd91 100644
--- a/meson.build
+++ b/meson.build
@@ -2272,46 +2272,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', have_audio)
+if have_audio
+  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'))
@@ -4684,7 +4693,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 support':     have_audio}
+if have_audio
   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] 27+ messages in thread

* Re: [PATCH v2 09/10] audio: do not build audio-related sources with --disable-audio
  2026-02-23 20:25 ` [PATCH v2 09/10] audio: do not build audio-related sources with --disable-audio Sergei Heifetz
@ 2026-02-24  8:02   ` Markus Armbruster
  2026-02-24  8:33     ` Paolo Bonzini
  2026-02-25  7:56     ` Sergei Heifetz
  0 siblings, 2 replies; 27+ messages in thread
From: Markus Armbruster @ 2026-02-24  8:02 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum,
	Marc-André Lureau, Paolo Bonzini, Daniel P. Berrangé,
	Fabiano Rosas, Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Dr. David Alan Gilbert

Sergei Heifetz <heifetz@yandex-team.com> writes:

> 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.
>
> - hmp-commands*.hx:
>   Remove the HMP `info capture`, `stopcapture` and `wavcapture`
>   commands.
>
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>

[...]

> 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' }

You compile out just the command, and keep all the audio types.

According to the cover letter: "In [certain] environments it is
generally beneficial to avoid building unused code, for both security
and maintenance reasons."  True.  But if we still need the audio types,
could there be more code we'd rather not build?

To find out, I emptied out qapi/audio.json completely, then fixed what
broke without regard for neatness.  Diff appended.

I'm not demanding anything here.  I merely want to show where audio
stuff is still used, so we can make an informed decision on where
exactly to make the cut.

[...]



diff --git a/qapi/audio.json b/qapi/audio.json
index 28fda7c8ac..e69de29bb2 100644
--- a/qapi/audio.json
+++ b/qapi/audio.json
@@ -1,544 +0,0 @@
-# -*- mode: python -*-
-# vim: filetype=python
-#
-# Copyright (C) 2015-2019 Zoltán Kővágó <DirtY.iCE.hu@gmail.com>
-#
-# This work is licensed under the terms of the GNU GPL, version 2 or later.
-# See the COPYING file in the top-level directory.
-
-##
-# *****
-# Audio
-# *****
-##
-
-##
-# @AudiodevPerDirectionOptions:
-#
-# General audio backend options that are used for both playback and
-# recording.
-#
-# @mixing-engine: use QEMU's mixing engine to mix all streams inside
-#     QEMU and convert audio formats when not supported by the
-#     backend.  When set to off, fixed-settings must be also off
-#     (default on, since 4.2)
-#
-# @fixed-settings: use fixed settings for host input/output.  When
-#     off, frequency, channels and format must not be specified
-#     (default true)
-#
-# @frequency: frequency to use when using fixed settings (default
-#     44100)
-#
-# @channels: number of channels when using fixed settings (default 2)
-#
-# @voices: number of voices to use (default 1)
-#
-# @format: sample format to use when using fixed settings (default
-#     s16)
-#
-# @buffer-length: the buffer length in microseconds
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevPerDirectionOptions',
-  'data': {
-    '*mixing-engine':  'bool',
-    '*fixed-settings': 'bool',
-    '*frequency':      'uint32',
-    '*channels':       'uint32',
-    '*voices':         'uint32',
-    '*format':         'AudioFormat',
-    '*buffer-length':  'uint32' } }
-
-##
-# @AudiodevGenericOptions:
-#
-# Generic driver-specific options.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevGenericOptions',
-  'data': {
-    '*in':  'AudiodevPerDirectionOptions',
-    '*out': 'AudiodevPerDirectionOptions' } }
-
-##
-# @AudiodevDBusOptions:
-#
-# Options of the D-Bus audio backend.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# @nsamples: set the number of samples per read/write calls
-#     (default to 480, 10ms at 48kHz).
-#
-# Since: 10.0
-##
-{ 'struct': 'AudiodevDBusOptions',
-  'data': {
-    '*in':  'AudiodevPerDirectionOptions',
-    '*out': 'AudiodevPerDirectionOptions',
-    '*nsamples': 'uint32'} }
-
-##
-# @AudiodevAlsaPerDirectionOptions:
-#
-# Options of the ALSA backend that are used for both playback and
-# recording.
-#
-# @dev: the name of the ALSA device to use (default 'default')
-#
-# @period-length: the period length in microseconds
-#
-# @try-poll: attempt to use poll mode, falling back to non-polling
-#     access on failure (default false)
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevAlsaPerDirectionOptions',
-  'base': 'AudiodevPerDirectionOptions',
-  'data': {
-    '*dev':           'str',
-    '*period-length': 'uint32',
-    '*try-poll':      'bool' } }
-
-##
-# @AudiodevAlsaOptions:
-#
-# Options of the ALSA audio backend.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# @threshold: set the threshold (in microseconds) when playback starts
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevAlsaOptions',
-  'data': {
-    '*in':        'AudiodevAlsaPerDirectionOptions',
-    '*out':       'AudiodevAlsaPerDirectionOptions',
-    '*threshold': 'uint32' } }
-
-##
-# @AudiodevSndioOptions:
-#
-# Options of the sndio audio backend.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# @dev: the name of the sndio device to use (default 'default')
-#
-# @latency: play buffer size (in microseconds)
-#
-# Since: 7.2
-##
-{ 'struct': 'AudiodevSndioOptions',
-  'data': {
-    '*in':        'AudiodevPerDirectionOptions',
-    '*out':       'AudiodevPerDirectionOptions',
-    '*dev':       'str',
-    '*latency':   'uint32'} }
-
-##
-# @AudiodevCoreaudioPerDirectionOptions:
-#
-# Options of the Core Audio backend that are used for both playback
-# and recording.
-#
-# @buffer-count: number of buffers
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevCoreaudioPerDirectionOptions',
-  'base': 'AudiodevPerDirectionOptions',
-  'data': {
-    '*buffer-count': 'uint32' } }
-
-##
-# @AudiodevCoreaudioOptions:
-#
-# Options of the coreaudio audio backend.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevCoreaudioOptions',
-  'data': {
-    '*in':  'AudiodevCoreaudioPerDirectionOptions',
-    '*out': 'AudiodevCoreaudioPerDirectionOptions' } }
-
-##
-# @AudiodevDsoundOptions:
-#
-# Options of the DirectSound audio backend.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# @latency: add extra latency to playback in microseconds (default
-#     10000)
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevDsoundOptions',
-  'data': {
-    '*in':      'AudiodevPerDirectionOptions',
-    '*out':     'AudiodevPerDirectionOptions',
-    '*latency': 'uint32' } }
-
-##
-# @AudiodevJackPerDirectionOptions:
-#
-# Options of the JACK backend that are used for both playback and
-# recording.
-#
-# @server-name: select from among several possible concurrent server
-#     instances (default: environment variable $JACK_DEFAULT_SERVER if
-#     set, else "default")
-#
-# @client-name: the client name to use.  The server will modify this
-#     name to create a unique variant, if needed unless @exact-name is
-#     true (default: the guest's name)
-#
-# @connect-ports: if set, a regular expression of JACK client port
-#     name(s) to monitor for and automatically connect to
-#
-# @start-server: start a jack server process if one is not already
-#     present (default: false)
-#
-# @exact-name: use the exact name requested otherwise JACK
-#     automatically generates a unique one, if needed (default: false)
-#
-# Since: 5.1
-##
-{ 'struct': 'AudiodevJackPerDirectionOptions',
-  'base': 'AudiodevPerDirectionOptions',
-  'data': {
-    '*server-name':   'str',
-    '*client-name':   'str',
-    '*connect-ports': 'str',
-    '*start-server':  'bool',
-    '*exact-name':    'bool' } }
-
-##
-# @AudiodevJackOptions:
-#
-# Options of the JACK audio backend.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# Since: 5.1
-##
-{ 'struct': 'AudiodevJackOptions',
-  'data': {
-    '*in':  'AudiodevJackPerDirectionOptions',
-    '*out': 'AudiodevJackPerDirectionOptions' } }
-
-##
-# @AudiodevOssPerDirectionOptions:
-#
-# Options of the OSS backend that are used for both playback and
-# recording.
-#
-# @dev: file name of the OSS device (default '/dev/dsp')
-#
-# @buffer-count: number of buffers
-#
-# @try-poll: attempt to use poll mode, falling back to non-polling
-#     access on failure (default true)
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevOssPerDirectionOptions',
-  'base': 'AudiodevPerDirectionOptions',
-  'data': {
-    '*dev':          'str',
-    '*buffer-count': 'uint32',
-    '*try-poll':     'bool' } }
-
-##
-# @AudiodevOssOptions:
-#
-# Options of the OSS audio backend.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# @try-mmap: try using memory-mapped access, falling back to
-#     non-memory-mapped access on failure (default true)
-#
-# @exclusive: open device in exclusive mode (vmix won't work) (default
-#     false)
-#
-# @dsp-policy: set the timing policy of the device (between 0 and 10,
-#     where smaller number means smaller latency but higher CPU usage)
-#     or -1 to use fragment mode (option ignored on some platforms)
-#     (default 5)
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevOssOptions',
-  'data': {
-    '*in':         'AudiodevOssPerDirectionOptions',
-    '*out':        'AudiodevOssPerDirectionOptions',
-    '*try-mmap':   'bool',
-    '*exclusive':  'bool',
-    '*dsp-policy': 'uint32' } }
-
-##
-# @AudiodevPaPerDirectionOptions:
-#
-# Options of the Pulseaudio backend that are used for both playback
-# and recording.
-#
-# @name: name of the sink/source to use
-#
-# @stream-name: name of the PulseAudio stream created by QEMU.  Can be
-#     used to identify the stream in PulseAudio when you create
-#     multiple PulseAudio devices or run multiple QEMU instances
-#     (default: audiodev's id, since 4.2)
-#
-# @latency: latency you want PulseAudio to achieve in microseconds
-#     (default 15000)
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevPaPerDirectionOptions',
-  'base': 'AudiodevPerDirectionOptions',
-  'data': {
-    '*name': 'str',
-    '*stream-name': 'str',
-    '*latency': 'uint32' } }
-
-##
-# @AudiodevPaOptions:
-#
-# Options of the PulseAudio audio backend.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# @server: PulseAudio server address (default: let PulseAudio choose)
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevPaOptions',
-  'data': {
-    '*in':     'AudiodevPaPerDirectionOptions',
-    '*out':    'AudiodevPaPerDirectionOptions',
-    '*server': 'str' } }
-
-##
-# @AudiodevPipewirePerDirectionOptions:
-#
-# Options of the PipeWire backend that are used for both playback and
-# recording.
-#
-# @name: name of the sink/source to use
-#
-# @stream-name: name of the PipeWire stream created by QEMU.  Can be
-#     used to identify the stream in PipeWire when you create multiple
-#     PipeWire devices or run multiple QEMU instances (default:
-#     audiodev's id)
-#
-# @latency: latency you want PipeWire to achieve in microseconds
-#     (default 46000)
-#
-# Since: 8.1
-##
-{ 'struct': 'AudiodevPipewirePerDirectionOptions',
-  'base': 'AudiodevPerDirectionOptions',
-  'data': {
-    '*name': 'str',
-    '*stream-name': 'str',
-    '*latency': 'uint32' } }
-
-##
-# @AudiodevPipewireOptions:
-#
-# Options of the PipeWire audio backend.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# Since: 8.1
-##
-{ 'struct': 'AudiodevPipewireOptions',
-  'data': {
-    '*in':     'AudiodevPipewirePerDirectionOptions',
-    '*out':    'AudiodevPipewirePerDirectionOptions' } }
-
-##
-# @AudiodevSdlPerDirectionOptions:
-#
-# Options of the SDL audio backend that are used for both playback and
-# recording.
-#
-# @buffer-count: number of buffers (default 4)
-#
-# Since: 6.0
-##
-{ 'struct': 'AudiodevSdlPerDirectionOptions',
-  'base': 'AudiodevPerDirectionOptions',
-  'data': {
-    '*buffer-count': 'uint32' } }
-
-##
-# @AudiodevSdlOptions:
-#
-# Options of the SDL audio backend.
-#
-# @in: options of the recording stream
-#
-# @out: options of the playback stream
-#
-# Since: 6.0
-##
-{ 'struct': 'AudiodevSdlOptions',
-  'data': {
-    '*in':  'AudiodevSdlPerDirectionOptions',
-    '*out': 'AudiodevSdlPerDirectionOptions' } }
-
-##
-# @AudiodevWavOptions:
-#
-# Options of the wav audio backend.
-#
-# @in: options of the capture stream
-#
-# @out: options of the playback stream
-#
-# @path: name of the wav file to record (default 'qemu.wav')
-#
-# Since: 4.0
-##
-{ 'struct': 'AudiodevWavOptions',
-  'data': {
-    '*in':   'AudiodevPerDirectionOptions',
-    '*out':  'AudiodevPerDirectionOptions',
-    '*path': 'str' } }
-
-##
-# @AudioFormat:
-#
-# An enumeration of possible audio formats.
-#
-# @u8: unsigned 8 bit integer
-#
-# @s8: signed 8 bit integer
-#
-# @u16: unsigned 16 bit integer
-#
-# @s16: signed 16 bit integer
-#
-# @u32: unsigned 32 bit integer
-#
-# @s32: signed 32 bit integer
-#
-# @f32: single precision floating-point (since 5.0)
-#
-# Since: 4.0
-##
-{ 'enum': 'AudioFormat',
-  'data': [ 'u8', 's8', 'u16', 's16', 'u32', 's32', 'f32' ] }
-
-##
-# @AudiodevDriver:
-#
-# An enumeration of possible audio backend drivers.
-#
-# @jack: JACK audio backend (since 5.1)
-#
-# Since: 4.0
-##
-{ 'enum': 'AudiodevDriver',
-  'data': [ 'none',
-            { 'name': 'alsa', 'if': 'CONFIG_AUDIO_ALSA' },
-            { 'name': 'coreaudio', 'if': 'CONFIG_AUDIO_COREAUDIO' },
-            { 'name': 'dbus', 'if': 'CONFIG_DBUS_DISPLAY' },
-            { 'name': 'dsound', 'if': 'CONFIG_AUDIO_DSOUND' },
-            { 'name': 'jack', 'if': 'CONFIG_AUDIO_JACK' },
-            { 'name': 'oss', 'if': 'CONFIG_AUDIO_OSS' },
-            { 'name': 'pa', 'if': 'CONFIG_AUDIO_PA' },
-            { 'name': 'pipewire', 'if': 'CONFIG_AUDIO_PIPEWIRE' },
-            { 'name': 'sdl', 'if': 'CONFIG_AUDIO_SDL' },
-            { 'name': 'sndio', 'if': 'CONFIG_AUDIO_SNDIO' },
-            { 'name': 'spice', 'if': 'CONFIG_SPICE' },
-            'wav' ] }
-
-##
-# @Audiodev:
-#
-# Options of an audio backend.
-#
-# @id: identifier of the backend
-#
-# @driver: the backend driver to use
-#
-# @timer-period: timer period (in microseconds, 0: use lowest
-#     possible)
-#
-# Since: 4.0
-##
-{ 'union': 'Audiodev',
-  'base': {
-    'id':            'str',
-    'driver':        'AudiodevDriver',
-    '*timer-period': 'uint32' },
-  'discriminator': 'driver',
-  'data': {
-    'none':      'AudiodevGenericOptions',
-    'alsa':      { 'type': 'AudiodevAlsaOptions',
-                   'if': 'CONFIG_AUDIO_ALSA' },
-    'coreaudio': { 'type': 'AudiodevCoreaudioOptions',
-                   'if': 'CONFIG_AUDIO_COREAUDIO' },
-    'dbus':      { 'type': 'AudiodevDBusOptions',
-                   'if': 'CONFIG_DBUS_DISPLAY' },
-    'dsound':    { 'type': 'AudiodevDsoundOptions',
-                   'if': 'CONFIG_AUDIO_DSOUND' },
-    'jack':      { 'type': 'AudiodevJackOptions',
-                   'if': 'CONFIG_AUDIO_JACK' },
-    'oss':       { 'type': 'AudiodevOssOptions',
-                   'if': 'CONFIG_AUDIO_OSS' },
-    'pa':        { 'type': 'AudiodevPaOptions',
-                   'if': 'CONFIG_AUDIO_PA' },
-    'pipewire':  { 'type': 'AudiodevPipewireOptions',
-                   'if': 'CONFIG_AUDIO_PIPEWIRE' },
-    'sdl':       { 'type': 'AudiodevSdlOptions',
-                   'if': 'CONFIG_AUDIO_SDL' },
-    'sndio':     { 'type': 'AudiodevSndioOptions',
-                   'if': 'CONFIG_AUDIO_SNDIO' },
-    'spice':     { 'type': 'AudiodevGenericOptions',
-                   'if': 'CONFIG_SPICE' },
-    'wav':       'AudiodevWavOptions' } }
-
-##
-# @query-audiodevs:
-#
-# Return information about audiodev configuration
-#
-# Since: 8.0
-##
-{ 'command': 'query-audiodevs',
-  'returns': ['Audiodev'],
-  'if': 'CONFIG_AUDIO' }
diff --git a/include/qemu/audio-capture.h b/include/qemu/audio-capture.h
index f1319c9002..f80f6c98d4 100644
--- a/include/qemu/audio-capture.h
+++ b/include/qemu/audio-capture.h
@@ -8,6 +8,8 @@
 
 #include "audio.h"
 
+#ifdef CONFIG_AUDIO
+
 struct capture_ops {
     void (*info) (void *opaque);
     void (*destroy) (void *opaque);
@@ -30,4 +32,6 @@ void audio_be_del_capture(
     CaptureVoiceOut *cap,
     void *cb_opaque);
 
+#endif
+
 #endif /* QEMU_AUDIO_CAPTURE_H */
diff --git a/include/qemu/audio.h b/include/qemu/audio.h
index cff8a334f3..552689116c 100644
--- a/include/qemu/audio.h
+++ b/include/qemu/audio.h
@@ -32,6 +32,8 @@
 #include "gio/gio.h"
 #endif
 
+#ifdef CONFIG_AUDIO
+
 typedef void (*audio_callback_fn) (void *opaque, int avail);
 
 typedef struct audsettings {
@@ -240,4 +242,7 @@ static inline bool audio_format_is_signed(AudioFormat fmt)
 #define TYPE_AUDIO_BACKEND "audio-backend"
 OBJECT_DECLARE_TYPE(AudioBackend, AudioBackendClass, AUDIO_BACKEND)
 
+#else
+#define audio_cleanup() ((void)0)
+#endif
 #endif /* QEMU_AUDIO_H */
diff --git a/ui/vnc.h b/ui/vnc.h
index ec8d0c91b5..89e0199be1 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -184,7 +184,9 @@ struct VncDisplay
     VncDisplaySASL sasl;
 #endif
 
+#ifdef CONFIG_AUDIO
     AudioBackend *audio_be;
+#endif
 
     VMChangeStateEntry *vmstate_handler_entry;
 };
@@ -325,8 +327,10 @@ struct VncState
     pixman_format_code_t client_format;
     int client_endian; /* G_LITTLE_ENDIAN or G_BIG_ENDIAN */
 
+#ifdef CONFIG_AUDIO
     CaptureVoiceOut *audio_cap;
     struct audsettings as;
+#endif
 
     VncReadEvent *read_handler;
     size_t read_handler_expect;
diff --git a/audio/audio-stub.c b/audio/audio-stub.c
index f58f88cd83..e69de29bb2 100644
--- a/audio/audio-stub.c
+++ b/audio/audio-stub.c
@@ -1,22 +0,0 @@
-/*
- * 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, "audio disabled");
-  return NULL;
-}
-
-void audio_init_audiodevs(void) {}
-
-void audio_create_default_audiodevs(void) {}
diff --git a/hw/core/machine.c b/hw/core/machine.c
index d4ef620c17..12fbe0b0a6 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -750,6 +750,7 @@ static char *machine_get_audiodev(Object *obj, Error **errp)
 static void machine_set_audiodev(Object *obj, const char *value,
                                  Error **errp)
 {
+#ifdef CONFIG_AUDIO
     MachineState *ms = MACHINE(obj);
 
     if (!audio_be_by_name(value, errp)) {
@@ -758,6 +759,9 @@ static void machine_set_audiodev(Object *obj, const char *value,
 
     g_free(ms->audiodev);
     ms->audiodev = g_strdup(value);
+#else
+    error_setg(errp, "audio disabled");
+#endif
 }
 
 HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine)
diff --git a/system/vl.c b/system/vl.c
index 1034a4688f..6b2e7bc26e 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2067,10 +2067,12 @@ static void qemu_create_early_backends(void)
      * setting machine properties, so they can be referred to.
      */
     configure_blockdev(&bdo_queue, machine_class, snapshot);
+#ifdef CONFIG_AUDIO
     audio_init_audiodevs();
     if (default_audio) {
         audio_create_default_audiodevs();
     }
+#endif
 }
 
 
diff --git a/ui/dbus.c b/ui/dbus.c
index 60c8e0b473..2354e5d805 100644
--- a/ui/dbus.c
+++ b/ui/dbus.c
@@ -35,7 +35,9 @@
 #include "ui/egl-context.h"
 #endif
 #include "qemu/audio.h"
+#ifdef CONFIG_AUDIO
 #include "audio/audio_int.h" /* FIXME: use QOM dynamic cast instead of drv->name */
+#endif
 #include "qapi/error.h"
 #include "trace.h"
 



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

* Re: [PATCH v2 09/10] audio: do not build audio-related sources with --disable-audio
  2026-02-24  8:02   ` Markus Armbruster
@ 2026-02-24  8:33     ` Paolo Bonzini
  2026-02-25  7:56     ` Sergei Heifetz
  1 sibling, 0 replies; 27+ messages in thread
From: Paolo Bonzini @ 2026-02-24  8:33 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Sergei Heifetz, qemu-devel, Gerd Hoffmann, Marcel Apfelbaum,
	Marc-André Lureau, Daniel P. Berrangé, Fabiano Rosas,
	Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Dr. David Alan Gilbert

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

Il mar 24 feb 2026, 09:02 Markus Armbruster <armbru@redhat.com> ha scritto:

> Sergei Heifetz <heifetz@yandex-team.com> writes:
>
> > 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.
> >
> > - hmp-commands*.hx:
> >   Remove the HMP `info capture`, `stopcapture` and `wavcapture`
> >   commands.
> >
> > Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
>
> [...]
>
> diff --git a/include/qemu/audio-capture.h b/include/qemu/audio-capture.h
> index f1319c9002..f80f6c98d4 100644
> --- a/include/qemu/audio-capture.h
> +++ b/include/qemu/audio-capture.h
> @@ -8,6 +8,8 @@
>
>  #include "audio.h"
>
> +#ifdef CONFIG_AUDIO
> +
>  struct capture_ops {
>      void (*info) (void *opaque);
>      void (*destroy) (void *opaque);
> @@ -30,4 +32,6 @@ void audio_be_del_capture(
>      CaptureVoiceOut *cap,
>      void *cb_opaque);
>
> +#endif
> +
>  #endif /* QEMU_AUDIO_CAPTURE_H */
> diff --git a/include/qemu/audio.h b/include/qemu/audio.h
> index cff8a334f3..552689116c 100644
> --- a/include/qemu/audio.h
> +++ b/include/qemu/audio.h
> @@ -32,6 +32,8 @@
>  #include "gio/gio.h"
>  #endif
>
> +#ifdef CONFIG_AUDIO
> +
>  typedef void (*audio_callback_fn) (void *opaque, int avail);
>
>  typedef struct audsettings {
> @@ -240,4 +242,7 @@ static inline bool audio_format_is_signed(AudioFormat
> fmt)
>  #define TYPE_AUDIO_BACKEND "audio-backend"
>  OBJECT_DECLARE_TYPE(AudioBackend, AudioBackendClass, AUDIO_BACKEND)
>
> +#else
> +#define audio_cleanup() ((void)0)
> +#endif
>  #endif /* QEMU_AUDIO_H */
> diff --git a/ui/vnc.h b/ui/vnc.h
> index ec8d0c91b5..89e0199be1 100644
> --- a/ui/vnc.h
> +++ b/ui/vnc.h
> @@ -184,7 +184,9 @@ struct VncDisplay
>      VncDisplaySASL sasl;
>  #endif
>
> +#ifdef CONFIG_AUDIO
>      AudioBackend *audio_be;
> +#endif
>
>      VMChangeStateEntry *vmstate_handler_entry;
>  };
> @@ -325,8 +327,10 @@ struct VncState
>      pixman_format_code_t client_format;
>      int client_endian; /* G_LITTLE_ENDIAN or G_BIG_ENDIAN */
>
> +#ifdef CONFIG_AUDIO
>      CaptureVoiceOut *audio_cap;
>      struct audsettings as;
> +#endif
>
>      VncReadEvent *read_handler;
>      size_t read_handler_expect;
> diff --git a/audio/audio-stub.c b/audio/audio-stub.c
> index f58f88cd83..e69de29bb2 100644
> --- a/audio/audio-stub.c
> +++ b/audio/audio-stub.c
> @@ -1,22 +0,0 @@
> -/*
> - * 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, "audio disabled");
> -  return NULL;
> -}
> -
> -void audio_init_audiodevs(void) {}
> -
> -void audio_create_default_audiodevs(void) {}
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index d4ef620c17..12fbe0b0a6 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -750,6 +750,7 @@ static char *machine_get_audiodev(Object *obj, Error
> **errp)
>  static void machine_set_audiodev(Object *obj, const char *value,
>                                   Error **errp)
>  {
> +#ifdef CONFIG_AUDIO
>      MachineState *ms = MACHINE(obj);
>
>      if (!audio_be_by_name(value, errp)) {
> @@ -758,6 +759,9 @@ static void machine_set_audiodev(Object *obj, const
> char *value,
>
>      g_free(ms->audiodev);
>      ms->audiodev = g_strdup(value);
> +#else
> +    error_setg(errp, "audio disabled");
> +#endif
>  }
>
>  HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState
> *machine)
> diff --git a/system/vl.c b/system/vl.c
> index 1034a4688f..6b2e7bc26e 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -2067,10 +2067,12 @@ static void qemu_create_early_backends(void)
>       * setting machine properties, so they can be referred to.
>       */
>      configure_blockdev(&bdo_queue, machine_class, snapshot);
> +#ifdef CONFIG_AUDIO
>      audio_init_audiodevs();
>      if (default_audio) {
>          audio_create_default_audiodevs();
>      }
> +#endif
>  }
>
>
> diff --git a/ui/dbus.c b/ui/dbus.c
> index 60c8e0b473..2354e5d805 100644
> --- a/ui/dbus.c
> +++ b/ui/dbus.c
> @@ -35,7 +35,9 @@
>  #include "ui/egl-context.h"
>  #endif
>  #include "qemu/audio.h"
> +#ifdef CONFIG_AUDIO
>  #include "audio/audio_int.h" /* FIXME: use QOM dynamic cast instead of
> drv->name */
> +#endif
>  #include "qapi/error.h"
>  #include "trace.h"
>
>
>

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

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

* Re: [PATCH v2 10/10] meson.build: ignore audio drivers when configured with --disable-audio
  2026-02-23 20:25 ` [PATCH v2 10/10] meson.build: ignore audio drivers when configured " Sergei Heifetz
@ 2026-02-24 11:05   ` Marc-André Lureau
  0 siblings, 0 replies; 27+ messages in thread
From: Marc-André Lureau @ 2026-02-24 11:05 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

On Mon, Feb 23, 2026 at 9:27 PM Sergei Heifetz <heifetz@yandex-team.com> wrote:
>
> 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>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  meson.build | 80 ++++++++++++++++++++++++++++++-----------------------
>  1 file changed, 45 insertions(+), 35 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index fdb2578447..ae71a0dd91 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2272,46 +2272,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', have_audio)
> +if have_audio
> +  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'))
> @@ -4684,7 +4693,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 support':     have_audio}
> +if have_audio
>    summary_info += {'Audio drivers':     ' '.join(audio_drivers_selected)}
>  endif
>  summary_info += {'Trace backends':    ','.join(get_option('trace_backends'))}
> --
> 2.34.1
>
>


-- 
Marc-André Lureau


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

* Re: [PATCH v2 01/10] audio: add `audio` build option for meson and Kconfig
  2026-02-23 20:25 ` [PATCH v2 01/10] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
@ 2026-02-24 11:05   ` Marc-André Lureau
  0 siblings, 0 replies; 27+ messages in thread
From: Marc-André Lureau @ 2026-02-24 11:05 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

Hi

On Mon, Feb 23, 2026 at 9:27 PM 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.
>
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  Kconfig.host                  | 3 +++
>  meson.build                   | 3 +++
>  meson_options.txt             | 3 +++
>  scripts/meson-buildoptions.sh | 3 +++
>  4 files changed, 12 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/meson.build b/meson.build
> index 414c8ea7e2..fdb2578447 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
>
> +have_audio = get_option('audio').disable_auto_if(not have_system).allowed()
> +
>  ############
>  # Programs #
>  ############
> @@ -3250,6 +3252,7 @@ disassemblers = {
>  have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
>  host_kconfig = \
>    (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \
> +  (have_audio ? ['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..d7c94e6d6d 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: 'feature', value: 'auto',
> +       description: 'Audio support')
> +
>  option('kvm', type: 'feature', value: 'auto',
>         description: 'KVM acceleration support')
>  option('mshv', type: 'feature', value: 'auto',
> diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> index e8edc5252a..642f06efc5 100644
> --- a/scripts/meson-buildoptions.sh
> +++ b/scripts/meson-buildoptions.sh
> @@ -96,6 +96,7 @@ meson_options_help() {
>    printf "%s\n" '  af-xdp          AF_XDP network backend support'
>    printf "%s\n" '  alsa            ALSA sound support'
>    printf "%s\n" '  attr            attr/xattr support'
> +  printf "%s\n" '  audio           Audio support'
>    printf "%s\n" '  auth-pam        PAM access control'
>    printf "%s\n" '  blkio           libblkio block device driver'
>    printf "%s\n" '  bochs           bochs image format support'
> @@ -242,6 +243,8 @@ _meson_option_parse() {
>      --disable-asan) printf "%s" -Dasan=false ;;
>      --enable-attr) printf "%s" -Dattr=enabled ;;
>      --disable-attr) printf "%s" -Dattr=disabled ;;
> +    --enable-audio) printf "%s" -Daudio=enabled ;;
> +    --disable-audio) printf "%s" -Daudio=disabled ;;
>      --audio-drv-list=*) quote_sh "-Daudio_drv_list=$2" ;;
>      --enable-auth-pam) printf "%s" -Dauth_pam=enabled ;;
>      --disable-auth-pam) printf "%s" -Dauth_pam=disabled ;;
> --
> 2.34.1
>
>


--
Marc-André Lureau


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

* Re: [PATCH v2 02/10] ui/vnc: disable audio feature when configured with --disable-audio
  2026-02-23 20:25 ` [PATCH v2 02/10] ui/vnc: disable audio feature when configured with --disable-audio Sergei Heifetz
@ 2026-02-24 11:05   ` Marc-André Lureau
  2026-02-25  7:26     ` Sergei Heifetz
  0 siblings, 1 reply; 27+ messages in thread
From: Marc-André Lureau @ 2026-02-24 11:05 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

Hi

On Mon, Feb 23, 2026 at 9:26 PM Sergei Heifetz <heifetz@yandex-team.com> wrote:
>
> Disable the audio feature in VNC when QEMU is configured with
> `--disable-audio`. Do not compile the corresponding audio-related
> code.

Users will have to call query-command-line-options to figure out if
audio support was disabled. Since this is an optional build option, I
don't know if we treat it as a breaking change.

>
> 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 daf5b01d34..e6b6a9f4f9 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

Indentation is off

>      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();

I'd keep the if AUDIO case first, for consistency


> +#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.big_endian = false;
> +#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
>
>


--
Marc-André Lureau


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

* Re: [PATCH v2 03/10] tests/qtest: remove -audio none when configured with --disable-audio
  2026-02-23 20:25 ` [PATCH v2 03/10] tests/qtest: remove -audio none " Sergei Heifetz
@ 2026-02-24 11:05   ` Marc-André Lureau
  2026-02-25  7:31     ` Sergei Heifetz
  0 siblings, 1 reply; 27+ messages in thread
From: Marc-André Lureau @ 2026-02-24 11:05 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

Hi

On Mon, Feb 23, 2026 at 9:27 PM Sergei Heifetz <heifetz@yandex-team.com> 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>
> Reviewed-by: Thomas Huth <thuth@redhat.com>

Tbh, I feel like we could still allow "-audio none" for compatibility
reasons, even if compiled without CONFIG_AUDIO. But "-audio none" does
not mean "no audio"! it's actually the "none" backend, so better to
remove "-audio" altogether indeed. It may be worth explaining that in
the commit message.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.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
>
>


--
Marc-André Lureau


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

* Re: [PATCH v2 04/10] hw/audio/pcspk: change PCSPK behaviour with --disable-audio
  2026-02-23 20:25 ` [PATCH v2 04/10] hw/audio/pcspk: change PCSPK behaviour " Sergei Heifetz
@ 2026-02-24 11:05   ` Marc-André Lureau
  0 siblings, 0 replies; 27+ messages in thread
From: Marc-André Lureau @ 2026-02-24 11:05 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

On Mon, Feb 23, 2026 at 9:27 PM Sergei Heifetz <heifetz@yandex-team.com> 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 have a corresponding
> audio backend, while functioning the same way in non-audio aspects.
>
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>

looks ok

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  hw/audio/pcspk.c | 12 +++++++++++-
>  hw/i386/pc.c     |  2 ++
>  2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
> index 6b826507ce..54e1882265 100644
> --- a/hw/audio/pcspk.c
> +++ b/hw/audio/pcspk.c
> @@ -48,17 +48,20 @@ struct PCSpkState {
>
>      MemoryRegion ioport;
>      uint32_t iobase;
> +    PITCommonState *pit;
> +#ifdef CONFIG_AUDIO
>      uint8_t sample_buf[PCSPK_BUF_LEN];
>      AudioBackend *audio_be;
>      SWVoiceOut *voice;
> -    PITCommonState *pit;
>      unsigned int pit_count;
>      unsigned int samples;
>      unsigned int play_pos;
> +#endif
>      uint8_t data_on;
>      uint8_t dummy_refresh_clock;
>  };
>
> +#ifdef CONFIG_AUDIO
>  static const char *s_spk = "pcspk";
>
>  static inline void generate_samples(PCSpkState *s)
> @@ -130,6 +133,7 @@ static int pcspk_audio_init(PCSpkState *s)
>
>      return 0;
>  }
> +#endif
>
>  static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
>                                unsigned size)
> @@ -160,11 +164,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;
>          audio_be_set_active_out(s->audio_be, s->voice, gate & s->data_on);
>      }
> +#endif
>  }
>
>  static const MemoryRegionOps pcspk_io_ops = {
> @@ -195,10 +201,12 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)
>
>      isa_register_ioport(isadev, &s->ioport, s->iobase);
>
> +#ifdef CONFIG_AUDIO
>      if (s->audio_be && audio_be_check(&s->audio_be, errp)) {
>          pcspk_audio_init(s);
>          return;
>      }
> +#endif
>  }
>
>  static const VMStateDescription vmstate_spk = {
> @@ -213,7 +221,9 @@ static const VMStateDescription vmstate_spk = {
>  };
>
>  static const Property pcspk_properties[] = {
> +#ifdef CONFIG_AUDIO
>      DEFINE_AUDIO_PROPERTIES(PCSpkState, audio_be),
> +#endif

we could make DEFINE_AUDIO_PROPERTIES compile down to nothing if
!CONFIG_AUDIO, to avoid ifdefry

>      DEFINE_PROP_UINT32("iobase", PCSpkState, iobase,  0x61),
>      DEFINE_PROP_LINK("pit", PCSpkState, pit, TYPE_PIT_COMMON, PITCommonState *),
>  };
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 0dd3fd01d9..3992553c2a 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1679,8 +1679,10 @@ static void pc_machine_initfn(Object *obj)
>
>      pc_system_flash_create(pcms);
>      pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
> +#ifdef CONFIG_AUDIO
>      object_property_add_alias(OBJECT(pcms), "pcspk-audiodev",
>                                OBJECT(pcms->pcspk), "audiodev");
> +#endif
>      if (pcmc->pci_enabled) {
>          cxl_machine_init(obj, &pcms->cxl_devices_state);
>      }
> --
> 2.34.1
>
>


--
Marc-André Lureau


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

* Re: [PATCH v2 05/10] Kconfig: add AUDIO dependency to audio-related devices
  2026-02-23 20:25 ` [PATCH v2 05/10] Kconfig: add AUDIO dependency to audio-related devices Sergei Heifetz
@ 2026-02-24 11:06   ` Marc-André Lureau
  0 siblings, 0 replies; 27+ messages in thread
From: Marc-André Lureau @ 2026-02-24 11:06 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

On Mon, Feb 23, 2026 at 9:26 PM Sergei Heifetz <heifetz@yandex-team.com> 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>
> Reviewed-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.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
>
>


--
Marc-André Lureau


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

* Re: [PATCH v2 06/10] system/vl: remove audio and audiodev options when audio is disabled
  2026-02-23 20:25 ` [PATCH v2 06/10] system/vl: remove audio and audiodev options when audio is disabled Sergei Heifetz
@ 2026-02-24 11:06   ` Marc-André Lureau
  2026-02-25  7:39     ` Sergei Heifetz
  0 siblings, 1 reply; 27+ messages in thread
From: Marc-André Lureau @ 2026-02-24 11:06 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

Hi

On Mon, Feb 23, 2026 at 9:26 PM Sergei Heifetz <heifetz@yandex-team.com> wrote:
>
> Remove the audio and audiodev runtime options when QEMU is configured
> with `--disable-audio`.
>
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>

This change should also modify qemu-options.hx


> ---
>  system/vl.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/system/vl.c b/system/vl.c
> index 3e341142a0..1034a4688f 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")) {
>          /*
> @@ -3057,6 +3061,7 @@ void qemu_init(int argc, char **argv)
>                  }
>                  break;
>  #endif
> +#ifdef CONFIG_AUDIO
>              case QEMU_OPTION_audiodev:
>                  default_audio = 0;
>                  audio_parse_option(optarg);
> @@ -3097,6 +3102,7 @@ void qemu_init(int argc, char **argv)
>                  }
>                  break;
>              }
> +#endif
>              case QEMU_OPTION_h:
>                  help(0);
>                  break;
> --
> 2.34.1
>
>


--
Marc-André Lureau


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

* Re: [PATCH v2 07/10] ui/dbus: run without Audio interface when audio is disabled
  2026-02-23 20:25 ` [PATCH v2 07/10] ui/dbus: run without Audio interface " Sergei Heifetz
@ 2026-02-24 11:06   ` Marc-André Lureau
  2026-02-25  7:35     ` Sergei Heifetz
  0 siblings, 1 reply; 27+ messages in thread
From: Marc-André Lureau @ 2026-02-24 11:06 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

Hi

On Mon, Feb 23, 2026 at 9:26 PM Sergei Heifetz <heifetz@yandex-team.com> wrote:
>
> D-Bus display can be used even when QEMU is configured with
> `--disable-audio`. In that case, audio interface will not be available
> on `/org/qemu/Display1/Audio`.
>

I think it should also disable "audiodev" (from QAPI DisplayDBus etc).
Or at the minimum, it should return an error if the option is given
and qemu is compiled with !CONFIG_AUDIO.


> (The current handling of the situation when audio is enabled but
> no D-Bus-compatible audio backend is available is different and
> hasn’t been changed.)
>
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> ---
>  ui/dbus.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/ui/dbus.c b/ui/dbus.c
> index 905ee6fea7..60c8e0b473 100644
> --- a/ui/dbus.c
> +++ b/ui/dbus.c
> @@ -219,6 +219,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp)
>          return;
>      }
>
> +#ifdef CONFIG_AUDIO
>      {
>          AudioBackend *audio_be = audio_get_default_audio_be(NULL);
>          if (audio_be && !audio_be_can_set_dbus_server(audio_be)) {
> @@ -234,6 +235,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp)
>              return;
>          }
>      }
> +#endif
>
>      consoles = g_array_new(FALSE, FALSE, sizeof(guint32));
>      for (idx = 0;; idx++) {
> --
> 2.34.1
>
>


--
Marc-André Lureau


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

* Re: [PATCH v2 08/10] tests/audio: do not compile if audio is disabled
  2026-02-23 20:25 ` [PATCH v2 08/10] tests/audio: do not compile if " Sergei Heifetz
@ 2026-02-24 11:06   ` Marc-André Lureau
  0 siblings, 0 replies; 27+ messages in thread
From: Marc-André Lureau @ 2026-02-24 11:06 UTC (permalink / raw)
  To: Sergei Heifetz
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

On Mon, Feb 23, 2026 at 9:26 PM Sergei Heifetz <heifetz@yandex-team.com> wrote:
>
> If QEMU is configured with --disable-audio, do not compile the audio
> tests.
>
> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  tests/audio/meson.build | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/audio/meson.build b/tests/audio/meson.build
> index 84754bde22..97c1d623bb 100644
> --- a/tests/audio/meson.build
> +++ b/tests/audio/meson.build
> @@ -1,6 +1,6 @@
>  # SPDX-License-Identifier: GPL-2.0-or-later
>
> -if not have_system
> +if not have_audio
>    subdir_done()
>  endif
>
> --
> 2.34.1
>
>


--
Marc-André Lureau


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

* Re: [PATCH v2 02/10] ui/vnc: disable audio feature when configured with --disable-audio
  2026-02-24 11:05   ` Marc-André Lureau
@ 2026-02-25  7:26     ` Sergei Heifetz
  0 siblings, 0 replies; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-25  7:26 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

Hi, Marc-André.

On 2/24/26 16:05, Marc-André Lureau wrote:
> Hi
>
> On Mon, Feb 23, 2026 at 9:26 PM Sergei Heifetz<heifetz@yandex-team.com> wrote:
>> Disable the audio feature in VNC when QEMU is configured with
>> `--disable-audio`. Do not compile the corresponding audio-related
>> code.
> Users will have to call query-command-line-options to figure out if
> audio support was disabled. Since this is an optional build option, I
> don't know if we treat it as a breaking change.

1. I don’t think it makes sense to treat this as a breaking change, 
because it’s impossible that anything would break after an update unless 
QEMU has been deliberately reconfigured with `--disable-audio`. If it 
has, then the consequences are expected.

2. More importantly, I think it should be assumed that a client can 
handle the situation where QEMU does not support the audio feature.

See this excerpt from Section 6 of the RFB protocol specification (RFC 
6143):

"A server that does not support the extension will simply ignore the 
pseudo-encoding. Note that this means the client must assume that the 
server does not support the extension until it gets some 
extension-specific confirmation from the server."

In QEMU, use of the audio feature is requested by the client by adding 
VNC_ENCODING_AUDIO to a SetEncodings message. For confirmation, there is 
a send_ext_audio_ack function that sends a FrameBufferUpdate message to 
the client with VNC_ENCODING_AUDIO. The VNCDoTool (0.8.0) documentation, 
for example, explicitly says that this is used as confirmation for the 
relevant custom feature (see 1.7.4.12, "QEMU Client Message"):

"This message may only be sent if the client has previously received a 
FrameBufferUpdate that confirms support for the intended submessage-type 
[...]" (where the submessage type is "Audio" in our case).

With this patch, the audio feature is disabled in a way that makes a 
QEMU server behave like a non-QEMU server (as far as audio is 
concerned). The client sends the audio pseudo-encoding, but the server 
does not respond with confirmation, because send_ext_audio_ack is now 
behind an #ifdef. A well-behaved client should handle this accordingly 
and continue using VNC without sending any audio-related messages to the 
server. If a client misbehaves and sends VNC_MSG_CLIENT_QEMU_AUDIO while 
the audio feature is disabled, the server will close the connection with 
an error.

Also note that the behaviour described above is already present when 
there is no audiodev (`vs->vd->audio_be` is NULL).

>> 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 daf5b01d34..e6b6a9f4f9 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
> Indentation is off
Oh. I'll fix it.
>>       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();
> I'd keep the if AUDIO case first, for consistency
Sure.
>> +#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.big_endian = false;
>> +#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
>>
>>
> --
> Marc-André Lureau


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

* Re: [PATCH v2 03/10] tests/qtest: remove -audio none when configured with --disable-audio
  2026-02-24 11:05   ` Marc-André Lureau
@ 2026-02-25  7:31     ` Sergei Heifetz
  0 siblings, 0 replies; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-25  7:31 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

On 2/24/26 16:05, Marc-André Lureau wrote:
> Hi
>
> On Mon, Feb 23, 2026 at 9:27 PM Sergei Heifetz <heifetz@yandex-team.com> 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>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Tbh, I feel like we could still allow "-audio none" for compatibility
> reasons, even if compiled without CONFIG_AUDIO. But "-audio none" does
> not mean "no audio"! it's actually the "none" backend, so better to
> remove "-audio" altogether indeed. It may be worth explaining that in
> the commit message.
>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
Yes, that was my reasoning as well. I’ll explain it in the commit message.
>
>> ---
>>   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
>>
>>
>
> --
> Marc-André Lureau


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

* Re: [PATCH v2 07/10] ui/dbus: run without Audio interface when audio is disabled
  2026-02-24 11:06   ` Marc-André Lureau
@ 2026-02-25  7:35     ` Sergei Heifetz
  0 siblings, 0 replies; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-25  7:35 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

On 2/24/26 16:06, Marc-André Lureau wrote:
> Hi
>
> On Mon, Feb 23, 2026 at 9:26 PM Sergei Heifetz <heifetz@yandex-team.com> wrote:
>> D-Bus display can be used even when QEMU is configured with
>> `--disable-audio`. In that case, audio interface will not be available
>> on `/org/qemu/Display1/Audio`.
>>
> I think it should also disable "audiodev" (from QAPI DisplayDBus etc).
> Or at the minimum, it should return an error if the option is given
> and qemu is compiled with !CONFIG_AUDIO.
OK, I’ll remove `audiodev`, then.
>
>> (The current handling of the situation when audio is enabled but
>> no D-Bus-compatible audio backend is available is different and
>> hasn’t been changed.)
>>
>> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
>> ---
>>   ui/dbus.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/ui/dbus.c b/ui/dbus.c
>> index 905ee6fea7..60c8e0b473 100644
>> --- a/ui/dbus.c
>> +++ b/ui/dbus.c
>> @@ -219,6 +219,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp)
>>           return;
>>       }
>>
>> +#ifdef CONFIG_AUDIO
>>       {
>>           AudioBackend *audio_be = audio_get_default_audio_be(NULL);
>>           if (audio_be && !audio_be_can_set_dbus_server(audio_be)) {
>> @@ -234,6 +235,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp)
>>               return;
>>           }
>>       }
>> +#endif
>>
>>       consoles = g_array_new(FALSE, FALSE, sizeof(guint32));
>>       for (idx = 0;; idx++) {
>> --
>> 2.34.1
>>
>>
>
> --
> Marc-André Lureau


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

* Re: [PATCH v2 06/10] system/vl: remove audio and audiodev options when audio is disabled
  2026-02-24 11:06   ` Marc-André Lureau
@ 2026-02-25  7:39     ` Sergei Heifetz
  0 siblings, 0 replies; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-25  7:39 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum, Paolo Bonzini,
	Daniel P. Berrangé, Fabiano Rosas, Laurent Vivier,
	Thomas Huth, Eduardo Habkost, Philippe Mathieu-Daudé,
	Eric Blake, Alex Bennée, Richard Henderson,
	Michael S. Tsirkin, Markus Armbruster, Dr. David Alan Gilbert

On 2/24/26 16:06, Marc-André Lureau wrote:
> Hi
>
> On Mon, Feb 23, 2026 at 9:26 PM Sergei Heifetz <heifetz@yandex-team.com> wrote:
>> Remove the audio and audiodev runtime options when QEMU is configured
>> with `--disable-audio`.
>>
>> Signed-off-by: Sergei Heifetz <heifetz@yandex-team.com>
> This change should also modify qemu-options.hx
Oh, yes, of course. I somehow forgot about this.

Thank you for all the feedback.
>
>> ---
>>   system/vl.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/system/vl.c b/system/vl.c
>> index 3e341142a0..1034a4688f 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")) {
>>           /*
>> @@ -3057,6 +3061,7 @@ void qemu_init(int argc, char **argv)
>>                   }
>>                   break;
>>   #endif
>> +#ifdef CONFIG_AUDIO
>>               case QEMU_OPTION_audiodev:
>>                   default_audio = 0;
>>                   audio_parse_option(optarg);
>> @@ -3097,6 +3102,7 @@ void qemu_init(int argc, char **argv)
>>                   }
>>                   break;
>>               }
>> +#endif
>>               case QEMU_OPTION_h:
>>                   help(0);
>>                   break;
>> --
>> 2.34.1
>>
>>
>
> --
> Marc-André Lureau


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

* Re: [PATCH v2 09/10] audio: do not build audio-related sources with --disable-audio
  2026-02-24  8:02   ` Markus Armbruster
  2026-02-24  8:33     ` Paolo Bonzini
@ 2026-02-25  7:56     ` Sergei Heifetz
  1 sibling, 0 replies; 27+ messages in thread
From: Sergei Heifetz @ 2026-02-25  7:56 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: qemu-devel, Gerd Hoffmann, Marcel Apfelbaum,
	Marc-André Lureau, Paolo Bonzini, Daniel P. Berrangé,
	Fabiano Rosas, Laurent Vivier, Thomas Huth, Eduardo Habkost,
	Philippe Mathieu-Daudé, Eric Blake, Alex Bennée,
	Richard Henderson, Michael S. Tsirkin, Dr. David Alan Gilbert

Hi, Markus.

On 2/24/26 13:02, Markus Armbruster wrote:
> Sergei Heifetz<heifetz@yandex-team.com> writes:
>
>> When QEMU is configured with `--disable-audio`, do not build any
>> audio-related sources.
[...]
> You compile out just the command, and keep all the audio types.
>
> According to the cover letter: "In [certain] environments it is
> generally beneficial to avoid building unused code, for both security
> and maintenance reasons."  True.  But if we still need the audio types,
> could there be more code we'd rather not build?
>
> To find out, I emptied out qapi/audio.json completely, then fixed what
> broke without regard for neatness.  Diff appended.
>
> I'm not demanding anything here.  I merely want to show where audio
> stuff is still used, so we can make an informed decision on where
> exactly to make the cut.

Indeed, it was a question of where to draw the line, and my main goal 
was to remove the audio/* files. However, I think it’s great that we can 
remove qapi/audio.json entirely. Thank you very much for the suggestion 
— I’ll try to incorporate it in the next version of the series.

[...]


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

end of thread, other threads:[~2026-02-25  7:56 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 20:25 [PATCH v2 00/10] add build option to disable audio subsystem Sergei Heifetz
2026-02-23 20:25 ` [PATCH v2 01/10] audio: add `audio` build option for meson and Kconfig Sergei Heifetz
2026-02-24 11:05   ` Marc-André Lureau
2026-02-23 20:25 ` [PATCH v2 02/10] ui/vnc: disable audio feature when configured with --disable-audio Sergei Heifetz
2026-02-24 11:05   ` Marc-André Lureau
2026-02-25  7:26     ` Sergei Heifetz
2026-02-23 20:25 ` [PATCH v2 03/10] tests/qtest: remove -audio none " Sergei Heifetz
2026-02-24 11:05   ` Marc-André Lureau
2026-02-25  7:31     ` Sergei Heifetz
2026-02-23 20:25 ` [PATCH v2 04/10] hw/audio/pcspk: change PCSPK behaviour " Sergei Heifetz
2026-02-24 11:05   ` Marc-André Lureau
2026-02-23 20:25 ` [PATCH v2 05/10] Kconfig: add AUDIO dependency to audio-related devices Sergei Heifetz
2026-02-24 11:06   ` Marc-André Lureau
2026-02-23 20:25 ` [PATCH v2 06/10] system/vl: remove audio and audiodev options when audio is disabled Sergei Heifetz
2026-02-24 11:06   ` Marc-André Lureau
2026-02-25  7:39     ` Sergei Heifetz
2026-02-23 20:25 ` [PATCH v2 07/10] ui/dbus: run without Audio interface " Sergei Heifetz
2026-02-24 11:06   ` Marc-André Lureau
2026-02-25  7:35     ` Sergei Heifetz
2026-02-23 20:25 ` [PATCH v2 08/10] tests/audio: do not compile if " Sergei Heifetz
2026-02-24 11:06   ` Marc-André Lureau
2026-02-23 20:25 ` [PATCH v2 09/10] audio: do not build audio-related sources with --disable-audio Sergei Heifetz
2026-02-24  8:02   ` Markus Armbruster
2026-02-24  8:33     ` Paolo Bonzini
2026-02-25  7:56     ` Sergei Heifetz
2026-02-23 20:25 ` [PATCH v2 10/10] meson.build: ignore audio drivers when configured " Sergei Heifetz
2026-02-24 11:05   ` Marc-André Lureau

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.