Daniel P. Berrangé <berra...@redhat.com> writes: > Currently the -audiodev accepts any audiodev type regardless of what is > built in to QEMU. An error only occurs later at runtime when a sound > device tries to use the audio backend. > > With this change QEMU will immediately reject -audiodev args that are > not compiled into the binary. The QMP schema will also be introspectable > to identify what is compiled in. > > Signed-off-by: Daniel P. Berrangé <berra...@redhat.com>
Subject "qapi, audio: respect build time conditions in audio schema" feels too narrow. The patch goes beyond the schema, because it has to: guarding QAPI schema parts with 'if' requires guarding use of C code generated for it with #if. An easy way out is perhaps stating just the aim: audio: Make introspection reflect build configuration This assumes the patch does a complete job. If there's more audio build configuration to reflect, add a suitable qualifier like "more closely". Fun: before the patch, the CONFIG_AUDIO_ conditionals are effectively applied just to output of -help. [...] > diff --git a/qapi/audio.json b/qapi/audio.json > index d7b91230d7..9af1b8140c 100644 > --- a/qapi/audio.json > +++ b/qapi/audio.json > @@ -386,8 +386,24 @@ > # Since: 4.0 > ## > { 'enum': 'AudiodevDriver', > - 'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'jack', 'oss', 'pa', > - 'sdl', 'spice', 'wav' ] } > + 'data': [ 'none', > + { 'name': 'alsa', > + 'if': 'defined(CONFIG_AUDIO_ALSA)' }, > + { 'name': 'coreaudio', > + 'if': 'defined(CONFIG_AUDIO_COREAUDIO)' }, > + { 'name': 'dsound', > + 'if': 'defined(CONFIG_AUDIO_DSOUND)' }, > + { 'name': 'jack', > + 'if': 'defined(CONFIG_AUDIO_JACK)' }, > + { 'name': 'oss', > + 'if': 'defined(CONFIG_AUDIO_OSS)' }, > + { 'name': 'pa', > + 'if': 'defined(CONFIG_AUDIO_PA)' }, > + { 'name': 'sdl', > + 'if': 'defined(CONFIG_AUDIO_SDL)' }, > + { 'name': 'spice', > + 'if': 'defined(CONFIG_SPICE)' }, > + 'wav' ] } > > ## > # @Audiodev: > @@ -410,14 +426,22 @@ > 'discriminator': 'driver', > 'data': { > 'none': 'AudiodevGenericOptions', > - 'alsa': 'AudiodevAlsaOptions', > - 'coreaudio': 'AudiodevCoreaudioOptions', > - 'dsound': 'AudiodevDsoundOptions', > - 'jack': 'AudiodevJackOptions', > - 'oss': 'AudiodevOssOptions', > - 'pa': 'AudiodevPaOptions', > - 'sdl': 'AudiodevSdlOptions', > - 'spice': 'AudiodevGenericOptions', > + 'alsa': { 'type': 'AudiodevAlsaOptions', > + 'if': 'defined(CONFIG_AUDIO_ALSA)' }, > + 'coreaudio': { 'type': 'AudiodevCoreaudioOptions', > + 'if': 'defined(CONFIG_AUDIO_COREAUDIO)' }, > + 'dsound': { 'type': 'AudiodevDsoundOptions', > + 'if': 'defined(CONFIG_AUDIO_DSOUND)' }, > + 'jack': { 'type': 'AudiodevJackOptions', > + 'if': 'defined(CONFIG_AUDIO_JACK)' }, > + 'oss': { 'type': 'AudiodevOssOptions', > + 'if': 'defined(CONFIG_AUDIO_OSS)' }, > + 'pa': { 'type': 'AudiodevPaOptions', > + 'if': 'defined(CONFIG_AUDIO_PA)' }, > + 'sdl': { 'type': 'AudiodevSdlOptions', > + 'if': 'defined(CONFIG_AUDIO_SDL)' }, > + 'spice': { 'type': 'AudiodevGenericOptions', > + 'if': 'defined(CONFIG_SPICE)' }, > 'wav': 'AudiodevWavOptions' } } > > ## For the QAPI schema part: Acked-by: Markus Armbruster <arm...@redhat.com>