QEMU Native JACK Audio Support

<domain>
  [...]
  <devices>
    <audio id='1' type='jack'>
      <output mixingEngine='yes' fixedSettings='yes' clientName='vm-win' connectPorts='Hi-Res.*playback_F[LR]'>
        <settings frequency='48000' channels='2' format='f32'/>
      </output>
    </audio>
    [...]
  </devices>
  [...]
  <qemu:commandline>
    [...]
    <qemu:env name='PIPEWIRE_RUNTIME_DIR' value='/run/user/1000'/>
    <qemu:env name='PIPEWIRE_LATENCY' value='512/48000'/>
  </qemu:commandline>
</domain>

After I slightly modified the VM configuration, everything was ready to use.
PS: And it seems to be due to the sound card, I need to use alsamixer to adjust the sound card volume.
:smile:

How did you get information for this? : ```
connectPorts='Hi-Res.*playback_F[LR]ā€™>

There may be a command line tool, but I use QjackCtl to get the port name of the connection.

Sorry for necroing an old thread and Iā€™ll create a new one if applicable but Iā€™ve been trying to get JACK w/ Pipewire-Jack working on an Windows 11 VM on a Fedora 36 host but Iā€™ve not been able to without setting SELinux to permissive (and unlike with the looking-glass shim Iā€™ve not been able to do something with audit2allow). I was wondering if anyone here has an idea on what label I could set to get it to comply as all the instructions I can find are for AppArmor (including in this thread).

The relevant section of my libvirt xml is give or take

Libvirt xml
<sound model="ich9">
   <codec type="micro"/>
   <audio id="1"/>
   <address type="pci" domain="0x0000" bus="0x00" slot="0x1b" function="0x0"/>
<audio id="1" type="jack">
   <input clientName="vm-win11" connectPorts="my-input:capture_F[LR]"/>
  <output clientName="vm-win11" connectPorts="my-output:playback_F[LR]"/>
</audio>

Thanks in advance.

Iā€™ve found a solution, but itā€™s neither pretty nor ideal but itā€™s better than setting SELinux to permissive globally - disabling security confinement for QEMU specifically in /etc/libvirt/qemu.conf i.e ā€œsecurity_default_confined = 0ā€. It should be fine enough with a single VM but yeah, not ideal. Either way, it works (at least for me).

If youā€™re using Looking Glass, just upgrade to Bleeding Edge which has native audio support via spice.

Iā€™ve been trying to get Looking Glass working but the host just doesnā€™t seem to work (unless Iā€™m doing something wrong). This is on a Windows 11 VM btw and the passthrough portion works fine outside of audio (I still get crackling even with Pipewire Latency tweaking) so I hope switching to Bleeding Edge would help solve that issue too. Speaking of which, do all I have to do to get the host working is install it and then run it? Cos thatā€™s all Iā€™ve been doing so far and well

[I] 12091927196 main.c:1123 | lg_run | ================================================================================
[I] 12091927208 main.c:1124 | lg_run | The host application seems to not be running
[I] 12091927209 main.c:1125 | lg_run | Waiting for the host application to startā€¦
[I] 12092564049 main.c:1130 | lg_run | ================================================================================
[I] 12092564064 main.c:1131 | lg_run | Please check the host application is running and is the correct version
[I] 12092564068 main.c:1132 | lg_run | Check the host log in your guest at %ProgramData%\Looking Glass (host)\looking-glass-host.txt

I donā€™t even have a log to see there, and itā€™s the correct version for both (B5.0.1).

There should be a shortcut in your start menu for the LG host logs, please check there and provide them if present.

Hello!
Im new to virtual machines.
Iā€™m very interested in running garageband in a vm in my system. Which i have achieved by following this tutorial:
github /foxlet/macOS-Simple-KVM

But it like to be able to connect it to jack.

The thing is i dont know where to enter the arguments you give in your post. Would you give me a hand? thank you.

I created this SELinux policy to get around the issue. It should only allow what is required as I only fed audit2allow the block events that happen when my VM started.

module libvirt-jack-socket 1.0;

require {
        type svirt_t;
        type user_tmp_t;
        type unconfined_t;
        type system_dbusd_t;
        type system_dbusd_var_run_t;
        class sock_file write;
        class unix_stream_socket connectto;
}

#============= svirt_t ==============
allow svirt_t system_dbusd_var_run_t:sock_file write;
allow svirt_t user_tmp_t:sock_file write;
allow svirt_t system_dbusd_t:unix_stream_socket connectto;
allow svirt_t unconfined_t:unix_stream_socket connectto;