Ok. So I will structure this post by the issues I have expirienced. But first I think it would be better to start on a good note as a baseline - I actually got debian based sys-audio running and working. Once.
Here are the screenshots of what you should see in your working sys-audio pavucontrol panel with misc
here being another vm.


If your soundcard doesn’t get initialized - you wouldn’t see anything related to your Built-in Audio
here. You can test your audio from inside the sys-audio by running the following command aplay /usr/share/sounds/alsa/Noise.wav
So that’s all for good news. The issues are as follows:
Issue 1 - Inability to shutdown sys-audio when you make it a default_audiovm
as a vm can’t be shutdown when it is an audiovm
of the other running vms. And in the default config at minimum sys-audio becomes an audiovm
of sys-audio, ie you can’t shutdown it without first changing its audiovm
. Which you can do with the command qvm-prefs sys-audio audiovm dom0
. Also you can’t leave audiovm
field empty because then pulseaudio server wouldn’t be starting.
So I dunno of what use is that restarting script itt when the author forgot to mention this CRUCIAL detail. 
Issue 2 - Random hung ups at startup with the error Qube sys-audio has failed to start: Cannot connect to qrexec agent for 60 seconds, see /var/log/xen/console/guest-sys-audio.log for details
/var/log/xen/console/guest-sys-audio.log has the following messages related to audio before it shuts down due to timeout
[2023-06-19 18:41:05] [ 56.275679] watchdog: BUG: soft lockup - CPU#1 stuck for 52s! [kworker/1:3:251]
[2023-06-19 18:41:05] [ 56.275703] Modules linked in: snd_soc_sst_dsp snd_soc_acpi_intel_match snd_soc_acpi snd_soc_core crct10dif_pclmul crc32_pclmul snd_compress crc32c_intel ac97_bus snd_pcm_dmaengine snd_hda_intel snd_intel_dspcfg snd_intel_sdw_acpi snd_hda_codec snd_hda_core snd_hwdep ghash_clmulni_intel snd_seq drm_vram_helper drm_ttm_helper snd_seq_device snd_pcm ttm serio_raw pcspkr drm_kms_helper i2c_piix4 floppy ehci_pci snd_timer cec snd ehci_hcd soundcore ata_generic pata_acpi xen_scsiback target_core_mod xen_netback xen_privcmd xen_gntdev xen_gntalloc xen_blkback xen_evtchn fuse loop drm bpf_preload overlay xen_blkfront
[2023-06-19 18:41:05] [ 56.275889] CPU: 1 PID: 251 Comm: kworker/1:3 Tainted: G L 5.15.103-1.qubes.fc32.x86_64 #1
[2023-06-19 18:41:05] [ 56.275913] Hardware name: Xen HVM domU, BIOS 4.14.5 03/21/2023
[2023-06-19 18:41:05] [ 56.275930] Workqueue: events azx_probe_work [snd_hda_intel]
[2023-06-19 18:41:05] [ 56.275950] RIP: 0010:snd_hdac_bus_send_cmd+0xac/0xd0 [snd_hda_core]
[2023-06-19 18:41:05] [ 56.275973] Code: 28 a8 ec 66 90 fb 66 0f 1f 44 00 00 31 c0 5b 5d 41 5c 41 5d c3 cc cc cc cc 4c 89 ef e8 a1 28 a8 ec 66 90 fb 66 0f 1f 44 00 00 <b8> f5 ff ff ff eb dd 4c 89 ef e8 89 28 a8 ec 66 90 fb 66 0f 1f 44
[2023-06-19 18:41:05] [ 56.276018] RSP: 0018:ffff9b01004abc18 EFLAGS: 00000246
[2023-06-19 18:41:05] [ 56.276033] RAX: 0000000000000001 RBX: ffff8d9b09c80028 RCX: ffff8d9b09c80038
[2023-06-19 18:41:05] [ 56.276053] RDX: 000000000000001f RSI: 00000000405f0005 RDI: ffff8d9b09c804c0
[2023-06-19 18:41:05] [ 56.276072] RBP: 00000000405f0005 R08: 0000000000000000 R09: ffff8d9b09c80428
[2023-06-19 18:41:05] [ 56.276092] R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000004
[2023-06-19 18:41:05] [ 56.276112] R13: ffff8d9b09c804c0 R14: ffff8d9b09c80028 R15: ffff8d9b09c804c8
[2023-06-19 18:41:05] [ 56.276131] FS: 0000000000000000(0000) GS:ffff8d9b79700000(0000) knlGS:0000000000000000
[2023-06-19 18:41:05] [ 56.276152] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[2023-06-19 18:41:05] [ 56.276168] CR2: 00007c8f3983bd37 CR3: 00000000013bc003 CR4: 00000000003706e0
[2023-06-19 18:41:05] [ 56.276189] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[2023-06-19 18:41:05] [ 56.276208] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[2023-06-19 18:41:05] [ 56.276228] Call Trace:
[2023-06-19 18:41:05] [ 56.276236] <TASK>
[2023-06-19 18:41:05] [ 56.276244] snd_hdac_bus_exec_verb_unlocked+0x7d/0x170 [snd_hda_core]
[2023-06-19 18:41:05] [ 56.276264] snd_hdac_bus_exec_verb+0x3a/0x60 [snd_hda_core]
[2023-06-19 18:41:05] [ 56.276283] hda_reg_read+0x1c8/0x260 [snd_hda_core]
[2023-06-19 18:41:05] [ 56.276301] __snd_hdac_regmap_read_raw+0x86/0xf0 [snd_hda_core]
[2023-06-19 18:41:05] [ 56.276321] setup_fg_nodes+0xc5/0x130 [snd_hda_core]
[2023-06-19 18:41:05] [ 56.276338] snd_hdac_device_init+0x18c/0x360 [snd_hda_core]
[2023-06-19 18:41:05] [ 56.276358] snd_hda_codec_device_init+0xc8/0x150 [snd_hda_codec]
[2023-06-19 18:41:05] [ 56.276381] snd_hda_codec_new+0x1c/0x50 [snd_hda_codec]
[2023-06-19 18:41:05] [ 56.276399] azx_probe_codecs+0xe3/0x150 [snd_hda_codec]
[2023-06-19 18:41:05] [ 56.276419] azx_probe_continue+0x358/0x3c0 [snd_hda_intel]
[2023-06-19 18:41:05] [ 56.276435] process_one_work+0x1ee/0x390
[2023-06-19 18:41:05] [ 56.276447] worker_thread+0x4c/0x320
[2023-06-19 18:41:05] [ 56.276458] ? process_one_work+0x390/0x390
[2023-06-19 18:41:05] [ 56.276470] kthread+0x124/0x150
[2023-06-19 18:41:05] [ 56.276481] ? set_kthread_struct+0x50/0x50
[2023-06-19 18:41:05] [ 56.276493] ret_from_fork+0x1f/0x30
[2023-06-19 18:41:05] [ 56.276506] </TASK>
[2023-06-19 18:41:06] .M
.[K[ .[0;31m*.[0;1;31m*.[0m.[0;31m* .[0m] Job qubes-mount-dirs.service/start running (53s / no limit)
[2023-06-19 18:41:06] .M
.[K[ .[0;31m*.[0;1;31m*.[0m.[0;31m* .[0m] Job qubes-mount-dirs.service/start running (54s / no limit)
[2023-06-19 18:41:07] .M
.[K[ .[0;31m*.[0;1;31m*.[0m.[0;31m*.[0m] Job qubes-mount-dirs.service/start running (54s / no limit)
[2023-06-19 18:41:07] .M
.[K[ .[0;31m*.[0;1;31m*.[0m] Job qubes-mount-dirs.service/start running (55s / no limit)
[2023-06-19 18:41:08] .M
.[K[ .[0;31m*.[0m] Job qubes-mount-dirs.service/start running (55s / no limit)
[2023-06-19 18:41:08] .M
.[K[ .[0;31m*.[0;1;31m*.[0m] Job qubes-mount-dirs.service/start running (56s / no limit)
And /var/log/xen/console/guest-sys-audio-dm.log has the following:
[2023-06-19 18:40:08] wrote 34 bytes to vchan
[2023-06-19 18:40:08] from-vchan: {"execute":"device_add","id":2020372736,"arguments":{"driver":"xen-pci-passthrough","id":"pci-pt-00_1f.3","hostaddr":"0000:00:1f.3"}}
[2023-06-19 18:40:08]
[2023-06-19 18:40:08] [00:06.0] xen_pt_realize: Assigning real physical device 00:1f.3 to devfn 0x30
[2023-06-19 18:40:08] [00:06.0] xen_pt_register_regions: IO region 0 registered (size=0x00004000 base_addr=0xa1330000 type: 0x4)
[2023-06-19 18:40:08] [00:06.0] xen_pt_register_regions: IO region 4 registered (size=0x00100000 base_addr=0xa1000000 type: 0x4)
[2023-06-19 18:40:08] [00:06.0] xen_pt_config_reg_init: Offset 0x000e mismatch! Emulated=0x0080, host=0x0000, syncing to 0x0000.
[2023-06-19 18:40:08] [00:06.0] xen_pt_config_reg_init: Offset 0x0010 mismatch! Emulated=0x0000, host=0xa1330004, syncing to 0xa1330004.
[2023-06-19 18:40:08] [00:06.0] xen_pt_config_reg_init: Offset 0x0020 mismatch! Emulated=0x0000, host=0xa1000004, syncing to 0xa1000004.
[2023-06-19 18:40:08] [00:06.0] xen_pt_config_reg_init: Offset 0x0052 mismatch! Emulated=0x0000, host=0x0043, syncing to 0x0003.
[2023-06-19 18:40:08] [00:06.0] xen_pt_config_reg_init: Offset 0x0062 mismatch! Emulated=0x0000, host=0x0080, syncing to 0x0080.
[2023-06-19 18:40:08] [00:06.0] xen_pt_pci_intx: intx=1
[2023-06-19 18:40:08] [00:06.0] xen_pt_realize: Real physical device 00:1f.3 registered successfully
[2023-06-19 18:40:08] from-unix: {"return": {}, "id": 2020372736}
[2023-06-19 18:40:08]
[2023-06-19 18:40:08] wrote 34 bytes to vchan
[2023-06-19 18:40:08] from-vchan: {"execute":"query-pci","id":2020372738}
[2023-06-19 18:40:08]
[2023-06-19 18:40:08] from-unix: {"return": [{"bus": 0, "devices": [{"irq_pin": 0, "bus": 0, "qdev_id": "", "slot": 0, "class_info": {"class": 1536, "desc": "Host bridge"}, "id": {"device": 4663, "subsystem-vendor": 6900, "vendor": 32902, "subsystem": 4352}, "function": 0, "regions": []}, {"irq_pin": 0, "bus": 0, "qdev_id": "", "slot": 1, "class_info": {"class": 1537, "desc": "ISA bridge"}, "id": {"device": 28672, "subsystem-vendor": 6900, "vendor": 32902, "subsystem": 4352}, "function": 0, "regions": []}, {"irq_pin": 0, "bus": 0, "qdev_id": "", "slot": 1, "class_info": {"class": 257, "desc": "IDE controller"}, "id": {"device": 28688, "subsystem-vendor": 6900, "vendor": 32902, "subsystem": 4352}, "function": 1, "regions": [{"bar": 4, "size": 16, "address": -1, "type": "io"}]}, {"irq_pin": 1, "bus": 0, "qdev_id": "", "irq": 0, "slot": 1, "class_info": {"class": 1664, "desc": "Bridge"}, "id": {"device": 28947, "subsystem-vendor": 6900, "vendor": 32902, "subsystem": 4352}, "function": 3, "regions": []}, {"irq_pin": 1, "bus": 0, "qdev_id": "", "irq": 0, "slot": 2, "class_info": {"class": 65408}, "id": {"device": 1, "subsystem-vendor": 22611, "vendor": 22611, "subsystem": 1}, "function": 0, "regions": [{"bar": 0, "size": 256, "address": -1, "type": "io"}, {"prefetch": true, "mem_type_64": false, "bar": 1, "size": 16777216, "address": -1, "type": "memory"}]}, {"irq_pin": 1, "bus": 0, "qdev_id": "", "irq": 0, "slot": 3, "class_info": {"class": 256, "desc": "SCSI controller"}, "id": {"device": 18, "subsystem-vendor": 0, "vendor": 4096, "subsystem": 4096}, "function": 0, "regions": [{"bar": 0, "size": 256, "address": -1, "type": "io"}, {"prefetch": false, "mem_type_64": false, "bar": 1, "size": 1024, "address": -1, "type": "memory"}, {"prefetch": false, "mem_type_64": false, "bar": 2, "size": 8192, "address": -1, "type": "memory"}]}, {"irq_pin": 0, "bus": 0, "qdev_id": "", "slot": 4, "class_info": {"class": 768, "desc": "VGA controller"}, "id": {"device": 4369, "subsystem-vendor": 6900, "vendor": 4660, "subsystem": 4352}, "function": 0, "regions": [{"prefetch": true, "mem_type_64": false, "bar": 0, "size": 16777216, "address": -1, "type": "memory"}, {"prefetch": false, "mem_type_64": false, "bar": 2, "size": 4096, "address": -1, "type": "memory"}, {"prefetch": false, "mem_type_64": false, "bar": 6, "size": 65536, "address": -1, "type": "memory"}]}, {"irq_pin": 4, "bus": 0, "qdev_id": "ehci", "irq": 0, "slot": 5, "class_info": {"class": 3075, "desc": "USB controller"}, "id": {"device": 9421, "subsystem-vendor": 6900, "vendor": 32902, "subsystem": 4352}, "function": 0, "regions": [{"prefetch": false, "mem_type_64": false, "bar": 0, "size": 4096, "address": -1, "type": "memory"}]}, {"irq_pin": 1, "bus": 0, "qdev_id": "pci-pt-00_1f.3", "irq": 0, "slot": 6, "class_info": {"class": 0}, "id": {"device": 41800, "subsystem-vendor": 0, "vendor": 32902, "subsystem": 0}, "function": 0, "regions": [{"prefetch": false, "mem_type_64": true, "bar": 0, "size": 16384, "address": -1, "type": "memory"}, {"prefetch": false, "mem_type_64": true, "bar": 4, "size": 1048576, "address": -1, "type": "memory"}]}]}], "id": 2020372738}
[2023-06-19 18:40:08]
[2023-06-19 18:40:08] wrote 2048 bytes to vchan
[2023-06-19 18:40:08] wrote 1075 bytes to vchan
[2023-06-19 18:40:08] vchan client disconnected
[2023-06-19 18:40:09] {"timestamp": {"seconds": 1687189209, "microseconds": 524449}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral-anon/device[3]"}}
[2023-06-19 18:40:09] {"timestamp": {"seconds": 1687189209, "microseconds": 524520}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral-anon/device[0]"}}
[2023-06-19 18:40:09] random: crng init done
[2023-06-19 18:40:13] [00:06.0] xen_pt_msgctrl_reg_write: setup MSI (register: 81).
[2023-06-19 18:40:13] [00:06.0] msi_msix_setup: requested pirq 151 for MSI (vec: 0x0, entry: 0x0)
[2023-06-19 18:40:13] [00:06.0] xen_pt_msi_setup: MSI mapped with pirq 151.
[2023-06-19 18:40:13] [00:06.0] msi_msix_update: Updating MSI with pirq 151 gvec 0x0 gflags 0x7097 (entry: 0x0)
[2023-06-19 18:40:13] [00:06.0] Write-back to unknown field 0x44 (partially) inhibited (0x00)
[2023-06-19 18:40:13] [00:06.0] If the device doesn't work, try enabling permissive mode
[2023-06-19 18:40:13] [00:06.0] (unsafe) and if it helps report the problem to xen-devel
[2023-06-19 18:41:08] pcifront pci-0: Rescanning PCI Frontend Bus 0000:00
Note these lines:
[2023-06-19 18:40:13] [00:06.0] Write-back to unknown field 0x44 (partially) inhibited (0x00)
[2023-06-19 18:40:13] [00:06.0] If the device doesn't work, try enabling permissive mode
[2023-06-19 18:40:13] [00:06.0] (unsafe) and if it helps report the problem to xen-devel
Possible Xen bug?
Tho it is difficult to determine if it is related to this specific sys-audio issue or not as I’ve seen similar hang ups on ordinary vms (with not pci devices attached). Maybe it is just an irrelevant Qubes “feature” (ie bug) that just gets in there because of the sheer number of restarts. And speaking of restarts…
Issue 3 - audio card gets initialized 1 out of random number of restarts. And no, it is not 1 out of 3. More like 1 out of 10. Reproduced on both debian and fedora.
Relevant logs:
[ 3.779104] hdaudio hdaudioC0D0: no AFG or MFG node found
[ 3.779108] snd_hda_intel 0000:00:06.0: no codecs initialized
[ 3.956895] snd_hda_codec_realtek hdaudioC0D0: autoconfig for ALC892: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:line
[ 3.956929] snd_hda_codec_realtek hdaudioC0D0: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[ 3.956950] snd_hda_codec_realtek hdaudioC0D0: hp_outs=1 (0x1b/0x0/0x0/0x0/0x0)
[ 3.956973] snd_hda_codec_realtek hdaudioC0D0: mono: mono_out=0x0
[ 3.956990] snd_hda_codec_realtek hdaudioC0D0: inputs:
[ 3.957005] snd_hda_codec_realtek hdaudioC0D0: Front Mic=0x19
[ 3.957022] snd_hda_codec_realtek hdaudioC0D0: Rear Mic=0x18
[ 3.957040] snd_hda_codec_realtek hdaudioC0D0: Line=0x1a
[ 4.070581] input: HDA Intel PCH Front Mic as /devices/pci0000:00/0000:00:06.0/sound/card0/input6
[ 4.071734] input: HDA Intel PCH Rear Mic as /devices/pci0000:00/0000:00:06.0/sound/card0/input7
[ 4.073122] input: HDA Intel PCH Line as /devices/pci0000:00/0000:00:06.0/sound/card0/input8
[ 4.074564] input: HDA Intel PCH Line Out as /devices/pci0000:00/0000:00:06.0/sound/card0/input9
[ 4.075419] input: HDA Intel PCH Front Headphone as /devices/pci0000:00/0000:00:06.0/sound/card0/input10
Issue 4 - Even when the card gets initialized sometimes there are no streams from the client vms. But sometimes there are. Hard to test in detail because of the Issue 3 and Issue 1.
So that’s about it. My guess is that it’s some xen bug related to pci passthrough that produces this erratic behavior. Maybe I will test this sys-audio thing again in Qubes 6.0 or something.