Setting up an audio VM

I was able to run the salt formula and create sys-audio.

I successfully had sys-audio handling my soundcard, but I cannot create pulseaudio streams to it.
I used pacat-simple-vchan (dom-id of sys-audio) sys-audio in appvms, and most of them said command not found.

So I installed qubes-audio-daemon in my templates of my appvms. Now the command could be run, but nothing happened. No new “Application” stream in sys-audio. After I set qubes-prefs default_audiovm sys-audio, newly created qubes didn’t created streams in dom0, but not in sys-audio either, even after I had rerun pacat-simple-vchan.

So could anyone help me please? Thanks in advance.

1 Like

Update:Now I’m able to see virtual streams in sys-audio pulseaudio control panel.

However, playing songs is impossible because the pulseaudio doesn’t automatically update the sound buffer. I made this guess because everytime I click at any botton of the pavucontrol window, the sound will update a bit and replay that bit again and again(making a lot of noise). As long as I click quick enough, I can tell from the rather scratchy and intermittent sound that the song is being played.

So how can I fix that? Thanks.

There’s an error message when starting pulseaudio.

E: [pulseaudio] bluez5-util.c: GetManagedObjects() failed: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

So this might be the problem.

idk if you launched the pacat processes in the sys-audio vm… They are the processes that receive the audio streams from the other vms and they’re normally started by the qvm-start-daemon --all --watch command in the sys-audio vm.

w/ scratchy audio it kind of sounds like a buffer issue. There are a lot of posts out there about adjusting the pulse audio configuration to suite the audio hardware. iirc it’s mostly getting the buffering configured properly so playback is smooth. One fellow wrote a formula on how to calculate the buffer settings from lspci and other command output.

I had exact same problem with ‘scratchy’ sound. Was able to trace it down to audio qube first and then to sound card there falling asleep.

To fix this I created /etc/modprobe.d/liteqube.conf (you can use any mane ending with .conf) in template qube and put one line there:

options snd_hda_intel power_save=0
2 Likes

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

What I couldn’t make it work is the mic. When trying to attach the mic to a vm, I get the following error in a popup:

QubesVMError: Failed to attach audio input from sys-audio to <vmname>: pulseaudio agent not running.

Skip this step due to qvm.sys-audio has been in the state.sls

I am getting the same error. I only have a limited understanding of how Qubes works under the hood, but when watching journalctl in sys-audio while trying to attach the mic to a vm the following error is thrown:

sys-audio qubes.AudioInputEnable+[vmname]-dom0: socat E connect(5, AF=1 "/var/run/qubes/audio-control.[vmname]", 40): No such file or directory

When reading the Audio Virtualization Documentation these locations are mentioned as UNIX sockets which enable the audio input of a vm.
When running the pacat-simple-vchan command in sys-audio the following message is displayed:

Another instance of pacat-simple-vchan is already running for this VM

Could it be that the pacat-simple-vchan instances are supposed to create the UNIX sockets but for some reason don’t and so the qvm-device mic attach [vmname] dom0:mic command is not able to enable the vm for audio input, and if so is there a possibility create the socket or QubesDB entrance manually?

1 Like

I guess this fixs the problem.

Also feel free to look at my experience for reference if anyone is still having problem about sys-audio:

3 Likes

Just an update, in case you are searching for info here: a better guide for setting up an audiovm is in the following thread.

2 Likes

For what is worth, I have a fully working sys-audio for several months, based on fedora-36-minimal and this package is not installed, so obviously not necessary.

[user@fedora-36-minimal-sys-audio ~]$ sudo dnf list qubes*
...
Available Packages
...
qubes-audio-dom0.x86_64                     4.1.24-1.fc36 qubes-vm-r4.1-current 

I’ve been trying to write a debian minimal sys-audio for a few days and ran into the issue where no matter what I did, pulseadio on the sys-audio qube wouldn’t recognize my audio device.

So I decided to try this instead, even though it would end up on (now) Fedora-36. I followed the instructions in post 24, which I’ll quote (and annotate) here. I’m going to delete steps that were moot (no need to re-download Fedora-36, for instance.

  1. 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.
  1. [Not needed]
  2. Run the salt script to create the sys-audio VM
    sudo qubesctl state.sls qvm.sys-audio

[4a I added these lines to the 50 policy file that (apparently) the salt script created.]

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). [Already done.]
  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;

OK, between steps 6 and 7, if I ran pulse audio volume control, my “output devices” tab showed:

Qubes VCHAN sink with port “Qubes Vchan Output (plugged in)”

It would not show my source qube (Clementine) in the playback list, until I restarted sys-audio.

When I added the files in 7 and restarted, the output device was replaced by Dummy Output.

I verified, my audio device is attached to sys-audio (and it’s an “Intel Tiger Lake-LP Smart Sound Technology Audio Controller” on 00:1f.3)

Like hamenarin, I can see the audio level jumping in the playback for my Clementine AudioVM. I infer that the ONLY thing wrong with my setup is that sys-audio won’t do anything with the sound card. (And this is where I got with my home-grown deb11 minimal setup, too.)

The only missing step I didn’t perform was his step 8:

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

which I will do as soon as I post this (I just saw it requires a reboot, and I don’t want to lose what I’ve written thus far). During my prior attempt at this (this is my second try with the salt recipe), this step had no effect.

EDIT TO ADD: Audio works well when I’m not trying to use sys-audio. So dom0 apparently still has something this sys-audio does not.

ALSO EDIT TO ADD: the file in dom0 had no effect.

1 Like

dom0

$ qvm-tags sys-audio?

sys-audio

$ aplay /usr/share/sounds/alsa/Front_Center.wav?

did you install packages from here

Will check. I’m reasonably sure I have the tags but a double-check can’t hurt.

This is the first time I’ve seen that thread (of course it’s about usb-audio not sys-audio, but obviously the two are related) so I’ll have to look closely at it tonight once I am seated in front of Qubeville.

No qube on my system has the tag sys-audio. Nor do any have audiovm-sys-audio. Should they?

Trying the aplay command threw a bunch of error messages:

ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5703:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:831: audio open error: No such file or directory

I’m not sure which list of packages you are referencing, to be honest…there’s an awful lot there. There’s a collapsed list. Most of those were installed. the two pipewire packages couldn’t be installed (no functioning mirror) and the rest got installed, but I must have borked something because now the qubes trying to use audiovm don’t show up in pavucontrol.

[EDIT…no, somehow my setting my source qubes’ audiovm didn’t stick. I had to do it again, once I did, my situation is unchanged…sys-audio is receiving audio, but has no idea how to send it to my audio device.

I’ve tried to figure out if maybe I’m just missing a driver on sys-audio, but not sure what I’m seeing.

Run this in dom0 and then paste the output here.

Did you ever run something like

[user@dom0 ~] $ qvm-prefs some-VM audiovm sys-audio
[user@dom0 ~] $ qvm-prefs sys-audio audiovm ‘’

Sorry, I completely misunderstood your question as asking me if I had set that tag somewhere–not as a request for the tags for that VM. Will run it tonight.

I DID do what’s in your last statement, meaning I did set the audio vm on my music VM (otherwise I’d not see the levels jumping in pavucontrol) to be sys-audio, and I set audiovm to none on sys-audio (so that it doesn’t reference itself).

As I said the entire problem right now seems to be that sys-audio doesn’t know how to talk to my sound device–everything upstream from that is happening. Other qubes are talking to sys-audio just fine; sys-audio isn’t talking to my controller and therefore not to my speakers–it’s sending sound to “dummy.”

You should run first

# dnf install alsa-plugins-pulseaudio alsa-utils pulseaudio-utils pipewire-utils webrtc-audio-processing xfce4-pulseaudio-plugin pavucontrol

and then

# dnf install qubes-audio-daemon --allowerasing

in your sys-audio's fedora-36 template. This worked for my f36-mminimal audo template.

It would be good idea after that to create sys-audio and set what you set above in a post #31
After creating and setting 50-alsa.conf, Qubes reboot is needed.

Output of qvm-tags sys-audio:

audiovm-dom0
created-by-dom0
guivm-dom0

Trying to do the installs you mentioned (which looks close to the list I tried yesterday) pipewire fails to download and install because ‘all mirrors were already tried without success’ (as it did yesterday). So I installed the other packages without pipewire.

Qubes-audio-daemon won’t install either (and I think this message may have appeared early on when I tried to install the first list):

Fedora 36 openh264 (From Cisco) - x86_64                                                                   0.0  B/s |   0  B     00:01    
Errors during downloading metadata for repository 'fedora-cisco-openh264':
  - Curl error (56): Failure when receiving data from the peer for https://codecs.fedoraproject.org/openh264/36/x86_64/os/repodata/repomd.xml [Received HTTP code 403 from proxy after CONNECT]
Error: Failed to download metadata for repo 'fedora-cisco-openh264': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: fedora-cisco-openh264
Last metadata expiration check: 0:00:56 ago on Wed Nov 23 18:57:41 2022.
Package qubes-audio-daemon-4.1.25-1.fc36.x86_64 is already installed.

On the other hand it declared qubes-audio-daemon to already be installed so maybe this isn’t a problem.

OK, so I created a new sys-audio AppVM and made its template my fedora-36-xfce template (I made a copy of the latter before monkeying with it, so I can recover it). And here is what I did: In Settings, added a service named audiovm; set the virtualization mode to HVM, ensured memory balancing was not set, then went to the devices tab and moved "Audio device: Intel Corporation Tiger Lake-LP Smart Sound Technology Audio Controller over to “selected” and turned off strict reset. I confirmed this latter part with qvm-pci.

I didn’t do the desktop entries because it has been my experience that the two executables start up anyway. (I can always add them later.)

Last thing, in dom0 (it is supposed to be in dom0, right?) created /etc/modprobe.d/50-alsa.conf

I am now about to reboot; I will continue this with “edit” once I get back.

EDIT. Back. I have NOT started sys-audio yet. I ran pavucontrol in dom0 and my output device is listed as “Built-In Audio Digital Stereo (HDMI).” [which makes sense, this little NUC doesn’t have an audio jack; to get sound out of it I have to use an HDMI splitter.] Port is: “HDMI / DisplayPort (plugged in).” That’s in a dropdown; there are no other options. When I start my music VM, “Recording” shows that vm (and an output levle); so does Playback. Output devices shows the sound level bouncing as well. Most importantly, sound comes out of my speakers.

OK, shut down my music VM, and start sys-audio: dom0 ballon warns it has no audio device (because sys-audio “grabbed” it).

pavucontrol run from sys-audio shows output device port “Qubes VCHAN sink” with port “Qubes vchan Output (plugged in)”

setting qvm-prefs audovm to sys-audio on the music qube.

Starting my music VM, it will play the music; the music appears in sys-audio’s pavucontrol, just like it did in dom0. But no sound comes out of the speakers, and the device and port name are as above.

Again: sys-audio cannot see my device. The only thing I couldn’t do which you asked me about was pipewire.

1 Like