Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 716202 - app-emulation/qemu-4.2.0-r2: Order of audio drivers (--audio-drv-list) is reversed from that of previous ebuilds
Summary: app-emulation/qemu-4.2.0-r2: Order of audio drivers (--audio-drv-list) is re...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Matthias Maier
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-04 16:58 UTC by Stephen Freeman
Modified: 2020-04-09 19:00 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Emerge output (file_716202.txt,5.06 KB, text/plain)
2020-04-04 17:07 UTC, Stephen Freeman
Details
Details of tests performed (file_716202.txt,2.92 KB, text/plain)
2020-04-05 09:57 UTC, Stephen Freeman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Freeman 2020-04-04 16:58:42 UTC
My first report here, so please let me know what I need to do differently.

After upgrading QEMU, I noticed that I had developed an intermittent issue with having no sound output from my virtual machines.

I am using PulseAudio.  My profile is default/linux/amd64/17.1/hardened.  My resulting USE flags for QEMU include alsa, oss, sdl, and pa (among others).

During times when the no sound issue was actually occurring, I often saw *huge* numbers of error messages, such as:
"alsa: Could not prepare handle for playback"
AND
"alsa: snd_pcm_poll_descriptors_reventsalsa: Reason: Input/output error"

(The errors were not immediately noticeable to me because I redirect QEMU output to a log file, which eventually used all available drive space.)

I eventually discovered that the audio-drv-list generated by app-emulation/qemu-4.2.0-r2.ebuild is reversed from what I had seen on previous ebuilds, and also appears to have a stray comma at the end, specifically "--audio-drv-list=alsa,oss,sdl,pa,".

Previous ebuilds (for example qemu-3.1.0-r4.ebuild, which is the only other ebuild I have available) generated "--audio-drv-list=pa,sdl,alsa,oss" instead.

I'm guessing that QEMU was trying to use ALSA instead of PulseAudio due to the new ordering of audio-dev-list.  Since my coding skills are pfft!, I have worked around the problem by simply setting QEMU_AUDIO_DRV=pa before starting my guests.

If the new order of audio-drv-list is intended behavior, then perhaps a message to users might be helpful.


I believe this is the relevant code of qemu-4.2.0-r2.ebuild (beginning at 491):
	if [[ ! ${buildtype} == "user" ]] ; then
		# audio options
		local audio_opts=(
			$(usev alsa)
			$(usev oss)
			$(usev sdl)
			$(usex pulseaudio pa "")
		)
		conf_opts+=(
			--audio-drv-list=$(printf "%s," "${audio_opts[@]}")
		)
	fi

I do not know in which version this was changed but, for comparison, this is the equivalent in qemu-3.1.0-r4.ebuild (beginning at Line 484):
	if [[ ! ${buildtype} == "user" ]] ; then
		# audio options
		local audio_opts="oss"
		use alsa && audio_opts="alsa,${audio_opts}"
		use sdl && audio_opts="sdl,${audio_opts}"
		use pulseaudio && audio_opts="pa,${audio_opts}"
		conf_opts+=(
			--audio-drv-list="${audio_opts}"
		)
		use sdl && conf_opts+=( --with-sdlabi=2.0 )
	fi


Reproducible: Sometimes

Steps to Reproduce:
1.  Emerge app-emulation/qemu-4.2.0-r2 with alsa and pa USE flags on host configured to use PulseAudio.
2.  Start virtual machine.
3.  Test sound in the VM.
Actual Results:  
Usually, there is no sound output from the guest where there was sound before upgrading QEMU.  Occasionally, the QEMU process will show very large numbers of ALSA errors.  Setting QEMU_AUDIO_DRV=pa seems to reliably work around the problem.

Expected Results:  
Working sound, no errors.

# emerge --info
Portage 2.3.89 (python 3.7.7-final-0, default/linux/amd64/17.1/hardened, gcc-9.2.0, glibc-2.29-r7, 5.4.28-gentoo x86_64)
=================================================================
System uname: Linux-5.4.28-gentoo-x86_64-Intel-R-_Core-TM-_i7_CPU_X_980_@_3.33GHz-with-gentoo-2.6
KiB Mem:    12288428 total,   9224968 free
KiB Swap:    8384504 total,   8362232 free
Timestamp of repository gentoo: Sat, 04 Apr 2020 10:45:01 +0000
Head commit of repository gentoo: f69d467ba2054724d2591e70303152d6e38cafeb
sh bash 4.4_p23-r1
ld GNU ld (Gentoo 2.33.1 p2) 2.33.1
app-shells/bash:          4.4_p23-r1::gentoo
dev-java/java-config:     2.2.0-r4::gentoo
dev-lang/perl:            5.30.1::gentoo
dev-lang/python:          3.6.10-r1::gentoo, 3.7.7-r1::gentoo
dev-util/cmake:           3.16.5::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.33.1-r1::gentoo
sys-devel/gcc:            9.2.0-r2::gentoo
sys-devel/gcc-config:     2.2.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.29-r7::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://gentoo/gentoo-portage
    priority: -1000
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts: 

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/easy-rsa /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
GENTOO_MIRRORS="https://gentoo.ussg.indiana.edu/ https://gentoo.osuosl.org/ http://gentoo.mirrors.pair.com/ http://gentoo.mirrors.tds.net/gentoo"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j13"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl additions alsa amd64 asf bzip2 caps cdinstall cdr clamav consolekit crypt cups dbus dvd dvdnav dvdr dvdread encode fbcon ffmpeg gif gpm hardened iconv imlib jpeg libtirpc mbrola mikmod mp3 mp4 mpeg multilib ncurses nls nocd nptl ogg openal opengl openmp pam pcre pie png pulseaudio pvr quicktime radio readline seccomp sndfile spell split-usr ssl ssp symlink threads tiff tls unicode usb vcd verbose videos vorbis xattr xine xinerama xpm xtpax xv xvid xvmc zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" L10N="en en-US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_7" PYTHON_TARGETS="python3_7" QEMU_SOFTMMU_TARGETS="x86_64" QEMU_USER_TARGETS="x86_64" RUBY_TARGETS="ruby24 ruby25" USERLAND="GNU" VIDEO_CARDS="nouveau" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Stephen Freeman 2020-04-04 17:07:43 UTC
Created attachment 630018 [details]
Emerge output

The "--audio-drv-list=alsa,oss,sdl,pa," is near the bottom of this emerge output (truncated).
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2020-04-04 22:08:14 UTC
I'd say it's a user configuration problem if alsa libraries don't work on pulseaudio system. You might want to install media-plugins/alsa-plugins[pulseautio] if you did not already to repair it.

Generally we should not rely on init order of audio backends. 

To prove your theory of sound ordering you can try to change ebuild locally and see if it restores audio for you.
Comment 3 Matthias Maier gentoo-dev 2020-04-04 22:10:47 UTC
This has been changed in

commit 79eb2ebdcc7ed50c2a2ca66ebbb6691921fbbf40
Author: James Le Cuirot <chewi@gentoo.org>
Date:   Sun Sep 22 00:00:22 2019 +0100

    app-emulation/qemu: Add oss USE flag instead of always enabling
    
    It requires no additional dependencies but some platforms like Windows
    cannot build the OSS driver and have the oss flag masked.
    
    Package-Manager: Portage-2.3.76, Repoman-2.3.17
    Signed-off-by: James Le Cuirot <chewi@gentoo.org>
    Signed-off-by: Matthias Maier <tamiko@gentoo.org>
Comment 4 Matthias Maier gentoo-dev 2020-04-04 22:13:02 UTC
(In reply to Sergei Trofimovich from comment #2)

> Generally we should not rely on init order of audio backends. 

That's true but I agree with Steve that preferring abstraction layers first (before alsa/oss/etc. backends) might be a better course of action :-)
Comment 5 Stephen Freeman 2020-04-05 09:57:49 UTC
Created attachment 630362 [details]
Details of tests performed

Thanks for the help.  In reply to Sergei Trofimovich (comment #2), I do have media-plugins/alsa-plugins [-abi_x86_32 -arcam_av -debug +ffmpeg -jack -libsamplerate +mix -oss +pulseaudio -speex +usb_stream].  It was built January 23.

I have run several tests.  Attached are the details.

It still appears to me that the reordering of the audio-drv-list option does indeed break sound for my guests.

SUGGESTED FIXES:
1)  In future builds, revert the setting of audio-drv-list to the previous ordering.  Systems should behave essentially as they always did.
OR
2)  The simplest workaround that I see is for users to manually set QEMU_AUDIO_DRV=pa.  Notify users of this during installation.  This is easy to set, but not knowing this in advance caused me hours of research and some downtime (as a result of rapidly expanding log files filling the filesystem).
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2020-04-05 10:19:17 UTC
Reverting to original ordering sounds fine. Do you want to craft a patch against ::gentoo?

Should be a matter of 'repoman commit' / 'git format-patch' against gentoo's git tree.
Comment 7 Larry the Git Cow gentoo-dev 2020-04-08 18:51:28 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0d77f947c3b17674479e6727c863708c369a75fd

commit 0d77f947c3b17674479e6727c863708c369a75fd
Author:     Matthias Maier <tamiko@gentoo.org>
AuthorDate: 2020-04-08 18:43:48 +0000
Commit:     Matthias Maier <tamiko@gentoo.org>
CommitDate: 2020-04-08 18:51:13 +0000

    app-emulation/qemu: reverse order of audio backends
    
    Closes: https://bugs.gentoo.org/716202
    Package-Manager: Portage-2.3.96, Repoman-2.3.22
    Signed-off-by: Matthias Maier <tamiko@gentoo.org>

 app-emulation/qemu/qemu-4.2.0-r2.ebuild | 4 ++--
 app-emulation/qemu/qemu-9999.ebuild     | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Comment 8 Larry the Git Cow gentoo-dev 2020-04-09 19:00:02 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=75f31320689f76b7c55f5c854d3015de2737bf92

commit 75f31320689f76b7c55f5c854d3015de2737bf92
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2020-04-09 18:59:51 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2020-04-09 18:59:56 +0000

    app-emulation/qemu: add a comment that backend ordering matters
    
    Bug: https://bugs.gentoo.org/716202
    Package-Manager: Portage-2.3.97, Repoman-2.3.22
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 app-emulation/qemu/qemu-4.2.0-r3.ebuild | 2 ++
 app-emulation/qemu/qemu-9999.ebuild     | 2 ++
 2 files changed, 4 insertions(+)