Setting up an audio VM

As a newbie, I had to gather information and found it could be useful to summarize the steps to make it easier for others to repeat. Some steps might be not necessary.

  1. The Salt script will create sys-audio based on fedora-34-xfce. I didn’t have it installed, so decided to do it
    sudo qubes-dom0-update qubes-template-fedora-34-xfce
    Maybe it is not necessary and Qubes would select the default template (fedora-34) if it was not installed.

  2. In dom0:
    sudo qubes-dom0-update qubes-audio-dom0
    In the TemplateVM for sys-audio (fedora-34-xfce):
    sudo dnf install qubes-audio-daemon qubes-core-admin-client
    This is necessary to get the qvm-start-daemon command in the sys-audio VM.

  3. Don’t know exactly if it was needed to download the sys-audio.sls and sys-audio.top to /srv/pillar/base/qvm. I did it since haven’t seen those files there. Used the command to copy the files downloaded from github to src-vm to dom0:
    sudo qvm-run --pass-io <src-vm> 'cat /path/to/file_in_src_domain' > /path/to/file_name_in_dom0

  4. Run the salt script to create the sys-audio VM
    sudo qubesctl state.sls qvm.sys-audio

About the policy errors, I got some when I’ve tried running qubesctl before installing the fedora-34-xfce template. Then I removed the created sys-audio qube and the /etc/qubes/policy.d/50-sys-audio.policy file, run the steps above and then the qubesctl command run without errors. I have not investigated further.

After running this, I rebooted and got policy errors when starting qubes. I’ve added the following lines to file /etc/qubes/policy.d/50-sys-audio.policy and got rit of them:

admin.vm.feature.CheckWithTemplate  +audio-model   sys-audio     @tag:audiovm-sys-audio  allow   target=dom0
admin.vm.property.Get               +keyboard_layout sys-audio     @tag:audiovm-sys-audio  allow   target=dom0
admin.vm.property.GetAll * sys-audio	sys-audio	allow	target=dom0
admin.vm.property.GetAll * sys-audio	@adminvm	allow	target=dom0
admin.vm.property.GetAll * sys-audio	@tag:audiovm-sys-audio	allow	target=dom0
  1. In sys-audio settings, open Services tab and add the audiovm service (a custom service).

  2. In dom0, run the commands to assign sys-audio as its audiovm.
    qvm-prefs <targetVM> audiovm sys-audio
    One can also use this one to set sys-audio as audiovm for all other vms:
    qubes-prefs default_audiovm sys-audio

  3. Run sys-audio VM and create the files inside ~/.config/autostart folder

 ~/.config/autostart/pulseaudio.desktop
[Desktop Entry]
Name=Pulseaudio
Comment=Starts Pulseaudio
Icon=qubes
Exec=pulseaudio
Terminal=False
Type=Application
NotShowIn=KDE;

 ~/.config/autostart/qvm-start-daemon.desktop
[Desktop Entry]
Name=Qubes Guid/Pacat
Comment=Starts GUI/AUDIO daemon for Qubes VMs
Icon=qubes
Exec=qvm-start-daemon --all --watch
Terminal=False
Type=Application
NotShowIn=KDE;
  1. Fix sound. So now I could see in the sys-audio pavucontrol the streams coming from other qubes, their sound bars are jumping when playing something in other qubes and stop that when I stop playing. But no sound was coming out. Audio playback started in sys-audio also do not produce any sound (tried both youtube videos or with aplay /usr/share/sounds/alsa/...). I have tested with headset plugged in and out.

In dom0, I created a file /etc/modprobe.d/50-alsa.conf and audio started working after rebooting:

options snd_hda_intel enable=1 index=0 power_save=0
6 Likes