Jaythanks, overall, that's very well written and all the more useful as everybody needed that proof of concept in the end.
That said,
pin Unfortunately, and as mentioned sound doesn't work yet. The system boots fine but warns that "could not init 'oss' audio driver"
Up to 7.x the NetBSD's implementation of OSSv3 sound subsystem couldn't listen to more than one process at a time (as opposed to Linux' ALSA). In order to manage multiple programs playing sound at a time one had to rely on userspace-level sound servers like Esound first and Pluseaudio later on. This changed in 8.x since the introduction of the in-kernel mixer, so at least we can safely assume that this is not where the problem lays.
Yet, QEMU is still failing in speaking to /dev/audio
(see audio(4)). If we exclude a privilege/permission, my suspicion falls onto QEMU's default settings for OSS: given both Linux under udevd and FreeBSD with devfs use /dev/dsp*
as generic OSS i/o pseudo-interface , QEMU may be pointing to it by default in place of /dev/audio
.
Indeed once installed QEMU and issued $ qemu-system-x86_64 -audio-help | egrep "DAC_DEV|ADC_DEV"
, I get:
QEMU_OSS_DAC_DEV: string, default = /dev/dsp
QEMU_OSS_ADC_DEV: string, default = /dev/dsp
While I don't have the time to test it myself, a possible solution could be pointing QEMU to the right interface. Fortunately, QEMU provides a ton of tunable environmental variables:
$ export QEMU_OSS_{ADC,DAC}_DEV=/dev/audio
$ sudo -E qemu-system-x86_64 -boot d --accel hax -m 4G -soundhw hda vm.img
Another possible workaround would be changing the audio backend. QEMU's current default configuration for NetBSD....
NetBSD)
bsd="yes"
hax="yes"
make="${MAKE-gmake}"
audio_drv_list="oss try-sdl"
audio_possible_drivers="oss sdl"
oss_lib="-lossaudio"
HOST_VARIANT_DIR="netbsd"
supported_os="yes"
Reveals support for devel/SDL2 API (which provides an audio abstraction layer for programs to use, via OpenGL) (still no PulseAudio support on NetBSD apparently).
To use SDL2 in place of baremetal OSS:
$ export QEMU_AUDIO_DRV=sdl QEMU_SDL_SAMPLES=2048
$ sudo -E qemu-system-x86_64 -boot d --accel hax -m 4G -soundhw hda vm.img
Let us know if either of those works ?