Audio qube

Do you have USB devices attached persistently to it?

If you are replying to me than yes I do.

1 Like

This issue is going to be solved forever very soon:

1 Like

I’ve updated the script, since it was error-prone and with updated script you don’t need to specify the attached USB devices:

Disable sys-audio autostart.
Run these commands in dom0:

sudo mkdir /etc/libvirt/hooks/
cat << 'EOF' | sudo tee /etc/libvirt/hooks/libxl >/dev/null
#!/bin/bash
guest_name="$1"
libvirt_operation="$2"
timeout=60
guest_to_start_on_usb="sys-audio"

if [ "$guest_name" = "sys-usb" ] && [ "$libvirt_operation" = "started" ]; then
    (
        exec 0</dev/null
        exec 1>/dev/null
        exec 2>/dev/null
        guest_attached_usb_list=$(qvm-usb list "$guest_to_start_on_usb" | awk '{ print $1 }')
        for i in $(seq 1 $timeout);
        do
            if qvm-ls --running $guest_name | grep -q Running; then
                present_usb_list=$(qvm-usb list | grep -w "$guest_to_start_on_usb" | awk '{ print $1 }')
                if  [ "$guest_attached_usb_list" = "$present_usb_list" ]; then
                    qvm-start --skip-if-running -q $guest_to_start_on_usb
                    break
                fi
            fi
            sleep 1
        done
    ) & disown
fi
EOF
sudo chmod +x /etc/libvirt/hooks/libxl

Reboot.

Related issue:
Require sys-usb to start before starting qubes with persistently attached USB devices ¡ Issue #7498 ¡ QubesOS/qubes-issues ¡ GitHub

1 Like

I attached the only device, which i think is related to audio.
It is the device which produces an error.
Here is output of the command:

Apr 30 14:32:19 dom0 qubesd[2333]: vm.sys-audio: Starting sys-audio
Apr 30 14:32:19 dom0 systemd[1]: Stopped target sound.target - Sound Card.
Apr 30 14:32:20 dom0 rtkit-daemon[4184]: Successfully made thread 5771 of process 4172 (/usr/bin/pulseaudio) owned by ‘1000’ RT at priority 5.
Apr 30 14:32:20 dom0 kernel: pciback 0000:00:1f.3: xen_pciback: seizing device
Apr 30 14:32:20 dom0 kernel: xen: registering gsi 22 triggering 0 polarity 1
Apr 30 14:32:20 dom0 kernel: Already setup the GSI :22
Apr 30 14:32:20 dom0 lvm[1640]: No longer monitoring thin pool qubes_dom0-vm–pool-tpool.
Apr 30 14:32:20 dom0 lvm[1640]: Monitoring thin pool qubes_dom0-vm–pool-tpool.
Apr 30 14:32:21 dom0 lvm[1640]: No longer monitoring thin pool qubes_dom0-vm–pool-tpool.
Apr 30 14:32:21 dom0 lvm[1640]: Monitoring thin pool qubes_dom0-vm–pool-tpool.
Apr 30 14:32:21 dom0 libvirtd[2003]: Interner Fehler: PCI-Gerät 0000:00:1f.3 kann nicht zurßckgesetzt werden: Kein FLR, PM Reset oder Bus-Reset verfßgbar
Apr 30 14:32:21 dom0 libvirtd[2003]: Zurßcksetzen von PCI-Gerät fehlgeschlagen: Interner Fehler: PCI-Gerät 0000:00:1f.3 kann nicht zurßckgesetzt werden: Kein FLR, PM Reset oder Bus-Reset verfßgbar
Apr 30 14:32:21 dom0 qubesd[2333]: vm.sys-audio: Start failed: Interner Fehler: PCI-Gerät 0000:00:1f.3 kann nicht zurßckgesetzt werden: Kein FLR, PM Reset oder Bus-Reset verfßgbar
Apr 30 14:32:21 dom0 qubesd[2333]: unhandled exception while calling src=b’dom0’ meth=b’admin.vm.Start’ dest=b’sys-audio’ arg=b’’ len(untrusted_payload)=0
Apr 30 14:32:21 dom0 qubesd[2333]: Traceback (most recent call last):
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib/python3.11/site-packages/qubes/vm/qubesvm.py”, line 1205, in start
Apr 30 14:32:21 dom0 qubesd[2333]: self.libvirt_domain.createWithFlags(
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib/python3.11/site-packages/qubes/app.py”, line 103, in wrapper
Apr 30 14:32:21 dom0 qubesd[2333]: return attr(*args, **kwargs)
Apr 30 14:32:21 dom0 qubesd[2333]: ^^^^^^^^^^^^^^^^^^^^^
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib64/python3.11/site-packages/libvirt.py”, line 1409, in createWithFlags
Apr 30 14:32:21 dom0 qubesd[2333]: raise libvirtError(‘virDomainCreateWithFlags() failed’)
Apr 30 14:32:21 dom0 qubesd[2333]: libvirt.libvirtError: Interner Fehler: PCI-Gerät 0000:00:1f.3 kann nicht zurßckgesetzt werden: Kein FLR, PM Reset oder Bus-Reset verfßgbar
Apr 30 14:32:21 dom0 qubesd[2333]: During handling of the above exception, another exception occurred:
Apr 30 14:32:21 dom0 qubesd[2333]: Traceback (most recent call last):
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib/python3.11/site-packages/qubes/api/init.py”, line 297, in respond
Apr 30 14:32:21 dom0 qubesd[2333]: response = await self.mgmt.execute(
Apr 30 14:32:21 dom0 qubesd[2333]: ^^^^^^^^^^^^^^^^^^^^^^^^
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib/python3.11/site-packages/qubes/api/admin.py”, line 864, in vm_start
Apr 30 14:32:21 dom0 qubesd[2333]: await self.dest.start()
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib/python3.11/site-packages/qubes/vm/dispvm.py”, line 253, in start
Apr 30 14:32:21 dom0 qubesd[2333]: await super().start(**kwargs)
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib/python3.11/site-packages/qubes/vm/qubesvm.py”, line 1222, in start
Apr 30 14:32:21 dom0 qubesd[2333]: await self.fire_event_async(‘domain-start-failed’,
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib/python3.11/site-packages/qubes/events.py”, line 227, in fire_event_async
Apr 30 14:32:21 dom0 qubesd[2333]: sync_effects, async_effects = self._fire_event(event,
Apr 30 14:32:21 dom0 qubesd[2333]: ^^^^^^^^^^^^^^^^^^^^^^^
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib/python3.11/site-packages/qubes/events.py”, line 164, in _fire_event
Apr 30 14:32:21 dom0 qubesd[2333]: effect = func(self, event, **kwargs)
Apr 30 14:32:21 dom0 qubesd[2333]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib/python3.11/site-packages/qubes/api/admin.py”, line 70, in vm_handler
Apr 30 14:32:21 dom0 qubesd[2333]: self.send_event(subject, event, **kwargs)
Apr 30 14:32:21 dom0 qubesd[2333]: File “/usr/lib/python3.11/site-packages/qubes/api/init.py”, line 374, in send_event
Apr 30 14:32:21 dom0 qubesd[2333]: self.transport.write(‘{}\0{}\0’.format(k, str(v)).encode(‘ascii’))
Apr 30 14:32:21 dom0 qubesd[2333]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 30 14:32:21 dom0 qubesd[2333]: UnicodeEncodeError: ‘ascii’ codec can’t encode character ‘\xe4’ in position 31: ordinal not in range(128)
Apr 30 14:32:21 dom0 qubes-app-menu[5759]: Got empty response from qubesd. See journalctl in dom0 for details.
Apr 30 14:32:28 dom0 qrexec-policy-daemon[2337]: qrexec: qubes.NotifyUpdates+: mail → @adminvm: allowed to dom0
Apr 30 14:32:28 dom0 audit: BPF prog-id=63 op=LOAD
Apr 30 14:32:28 dom0 audit: BPF prog-id=64 op=LOAD
Apr 30 14:32:28 dom0 kernel: audit: type=1334 audit(1714480348.948:376): prog-id=63 op=LOAD
Apr 30 14:32:28 dom0 kernel: audit: type=1334 audit(1714480348.948:377): prog-id=64 op=LOAD
Apr 30 14:32:28 dom0 kernel: audit: type=1334 audit(1714480348.949:378): prog-id=65 op=LOAD
Apr 30 14:32:28 dom0 audit: BPF prog-id=65 op=LOAD
Apr 30 14:32:28 dom0 systemd[1]: Starting systemd-hostnamed.service - Hostname Service…
Apr 30 14:32:29 dom0 systemd[1]: Started systemd-hostnamed.service - Hostname Service.
Apr 30 14:32:29 dom0 audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg=‘unit=systemd-hostnamed comm=“systemd” exe=“/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
Apr 30 14:32:29 dom0 kernel: audit: type=1130 audit(1714480349.000:379): pid=1 uid=0 auid=4294967295 ses=4294967295 msg=‘unit=systemd-hostnamed comm=“systemd” exe=“/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
Apr 30 14:32:59 dom0 systemd[1]: systemd-hostnamed.service: Deactivated successfully.
Apr 30 14:32:59 dom0 audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg=‘unit=systemd-hostnamed comm=“systemd” exe=“/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
Apr 30 14:32:59 dom0 kernel: audit: type=1131 audit(1714480379.007:380): pid=1 uid=0 auid=4294967295 ses=4294967295 msg=‘unit=systemd-hostnamed comm=“systemd” exe=“/usr/lib/systemd/systemd” hostname=? addr=? terminal=? res=success’
Apr 30 14:32:59 dom0 audit: BPF prog-id=65 op=UNLOAD
Apr 30 14:32:59 dom0 audit: BPF prog-id=64 op=UNLOAD
Apr 30 14:32:59 dom0 audit: BPF prog-id=63 op=UNLOAD
Apr 30 14:32:59 dom0 kernel: audit: type=1334 audit(1714480379.068:381): prog-id=65 op=UNLOAD
Apr 30 14:32:59 dom0 kernel: audit: type=1334 audit(1714480379.068:382): prog-id=64 op=UNLOAD
Apr 30 14:32:59 dom0 kernel: audit: type=1334 audit(1714480379.068:383): prog-id=63 op=UNLOAD

Try to use no-strict-reset for your PCI device:

@neowutran Is there any way to make this solution compatible with switching keyboard layouts on 4.2? If audiovm enabled I need to press switch shortcut multiple times for the layout to switch. Imagine the frustration during writing something when you need to switch layouts multiple time or sometimes it takes a huge delay to switch.

Layout switches in dom0 just fine, but I guess something is wrong with RPC policies because audiovm just suppresses some layout change events for some reason.

1 Like

Sorry I am not familiar with that part, I never need to switch keyboard layout so I didn’t tested it.

check with the RPC policy file, I have not allowed the layout change event in my proposed policy configuration

I understand, but could you please consider testing it on your end and seeing if it works? That is not really a niche case and your guide is the best I could find.

I also tried to allow property get and set on +keyboard_layout, but the issue still persists making using a keyboard on qubes with audiovm enabled almost unbearable.

The only solution for me after multiple hours of tinkering was to return to dom0 hdmi audio and ask for help.

Can you give me the exact command / gui / shortcut / … you use to change the keyboard layout and that trigger the issue you are having.

I will test that when I have some free time, but want to be sure to test the correct thing

Do you use USB keyboard with sys-usb?
And when you start sys-audio qube then layout switching is being unreliable?

Sorry I missed part of the directions. Please ignore.

I see this patch is still pending, was it ever sent as a PR? Or is there something blocking it being added officially? This guide has been helping many people for a long time so it would be nice to make it easier for more people to use.

I did sent a pull request last year.

Currently, there is quite a lot of activities on this subject by the QubesOS team: Dynamic audiovm switching ¡ Issue #8975 ¡ QubesOS/qubes-issues ¡ GitHub

I did not sent a pull request for the the last ~5 lines of modification still currently required. Will do maybe later.

This guide has been helping many people for a long time so it would be nice to make it easier for more people to use.

Most of this guide could be automated with a bash script / Salt script. But currently, I don’t really want to try to understand how Salt work

2 Likes

Thanks for this guide. I’ve tried to follow it step by step but I’ve some problems to get it working. In the sys-audio qube when I test that sound works via aplay I get the error:

$ aplay /usr/share/sounds/alsa/Noise.wav
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

The status of pulseaudio service is:

● pulseaudio.service - Sound Service
     Loaded: loaded (/usr/lib/systemd/user/pulseaudio.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/user/service.d
             └─10-timeout-abort.conf
             /usr/lib/systemd/user/pulseaudio.service.d
             └─30_qubes.conf
     Active: activating (start-pre) since Thu 2024-05-23 20:11:40 CEST; 15s ago
TriggeredBy: ● pulseaudio.socket
  Cntrl PID: 1116 (qubesdb-read)
      Tasks: 1 (limit: 381)
     Memory: 212.0K
        CPU: 10ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/pulseaudio.service
             └─1116 /usr/bin/qubesdb-read -w /qubes-audio-domain-xid

May 23 20:11:40 sys-audio systemd[623]: Failed to start pulseaudio.service - Sound Service.
May 23 20:11:40 sys-audio systemd[623]: pulseaudio.service: Scheduled restart job, restart counter is at 29.
May 23 20:11:40 sys-audio systemd[623]: Starting pulseaudio.service - Sound Service...

but when I try to start it, after a few seconds, I get the error:

systemctl --user start pulseaudio.service
Job for pulseaudio.service failed because a timeout was exceeded.
See "systemctl --user status pulseaudio.service" and "journalctl --user -xeu pulseaudio.service" for details.

Running pulseaudio -v outputs the error:

I: [pulseaudio] module.c: Loaded "module-filter-apply" (index: #19; argument: "").
W: [pulseaudio] cli-command.c: stat('/etc/pulse/default.pa.d'): No such file or directory
I: [pulseaudio] main.c: Daemon startup complete.
E: [pulseaudio] bluez5-util.c: GetManagedObjects() failed: org.freedesktop.DBus.Error.NameHasNoOwner: Could not activate remote peer 'org.bluez': unit failed
I: [pulseaudio] module-suspend-on-idle.c: Sink alsa_output.pci-0000_00_07.0.hdmi-stereo idle for too long, suspending ...
I: [alsa-sink-HDMI 0] alsa-sink.c: Device suspended...
I: [pulseaudio] main.c: Got signal SIGINT.
I: [pulseaudio] main.c: Exiting.
I: [pulseaudio] main.c: Daemon shutdown initiated.

With journalctl I can see that pulseaudio is restarting continuously:

May 23 21:02:26 sys-audio systemd[623]: Failed to start pulseaudio.service - Sound Service.
May 23 21:02:27 sys-audio systemd[623]: pulseaudio.service: Scheduled restart job, restart counter is at 57.
May 23 21:02:27 sys-audio systemd[623]: Starting pulseaudio.service - Sound Service...
May 23 21:03:12 sys-audio systemd[623]: pulseaudio.service: start-pre operation timed out. Terminating.
May 23 21:03:12 sys-audio systemd[623]: pulseaudio.service: Failed with result 'timeout'.
May 23 21:03:12 sys-audio systemd[623]: Failed to start pulseaudio.service - Sound Service.
May 23 21:03:12 sys-audio systemd[623]: pulseaudio.service: Scheduled restart job, restart counter is at 58.
May 23 21:03:12 sys-audio systemd[623]: Starting pulseaudio.service - Sound Service...

I don’t know how to fix these problems. Help would be really appreciated.

Could be related to recent change in how audio work. Need to update the guide it you confirm the following things solve your issue.

In your sys-audio vm:

qubesdb-write '/qubes-audio-domain-xid' 1
systemctl --user restart pipewire

Does it work now ?
If it work, try to set the audiovm of sys-audio as itself.
In dom0

qvm-prefs sys-audio audiovm sys-audio
1 Like

It helped but not fixed completely the problem. After restarting pipewire I tried to play again the test sound. Now the pulseaudio is started but no sound is played:

$ aplay /usr/share/sounds/alsa/Noise.wav
Playing WAVE  '/usr/share/sounds/alsa/Noise.wav' : Signed 16 bit Little Endian, Rated 48000 Hz, Mono

and the prompt is not returned.

Do the other part of the guide too. Especially the “configure service” part

I’ve already done the full guide, but still I’m not able to make it work. Currently the sound test fails and in pavucontrol I only see my Nvidia card (HDMI) and vchan. No analog duplex. But I’ve two attached devices: Intel Corporation Comet Lake PCH cAVS and NVIDIA Corporation.

Anyway I will repeat the full process if it makes easier for you to help me.