What is the current status of audio emulation in bhyve ?

usdmatt

Daemon

Reaction score: 534
Messages: 1,440

I don't know why it's not mentioned anywhere in the bhyve man page, but according to the source, hda support was imported 8 months ago.


The only place that has any information on how to use it is the summer of code page mentioned in the commit message.

https://wiki.freebsd.org/SummerOfCode2016/HDAudioEmulationForBhyve

I can't really provide any help on actually using it as I have never used audio on FreeBSD.
 

aragats

Daemon

Reaction score: 575
Messages: 1,424

Are there audio devices which can be emulated ?
hda support was imported 8 months ago
We discussed this in other threads. The audio emulation (hda) works with:
Code:
bhyve ... -s 9,hda,play=/dev/dsp,rec=/dev/dsp ...
but sound quality is significantly worse compared to xfreerdp()'s way for a Windows guest:
Code:
xfreerdp ... /sound:sys:oss,dev:3 /microphone:sys:oss,format:1 ...
 

usdmatt

Daemon

Reaction score: 534
Messages: 1,440

but sound quality is significantly worse compared to xfreerdp()'s way for a Windows guest:
Well that's a shame. As mentioned I don't have anything to do with audio on FreeBSD, but I would of hoped that the "hda" device would of effectively provided high definition channels direct between the host and guest. (There is mention that a sysctl needs to change with a Windows guest, as Windows tries to reduce latency by accessing the device far more often that stock FreeBSD is set up for)

I'm not sure who is working on bhyve these days (Peter & Neel still seem to be around but don't think they are anywhere near as involved as they used to be). It's worrying that numerous parts (e.g sound, efi nv-vars, improved disk format support) seem to be fairly stagnant. The only real changes I see in the logs are usually just minor fixes or simply keeping the code inline with improvements elsewhere in the kernel.
 
OP
OP
Alain De Vos

Alain De Vos

Well-Known Member

Reaction score: 55
Messages: 301

It would we nice to know when the page was created and last updated.

Do I need to patch something ? I run FreeBSD 12.1-RELEASE-p3 r359179 amd64
As at this moment hda seems not to be found
[PS : I tried patch -d bhyve/ ./bhyve_hda.patch in /usr/src/usr.sbin but this only hangs]

PS :As workaround I'll try pulseaudio over the network.
 
OP
OP
Alain De Vos

Alain De Vos

Well-Known Member

Reaction score: 55
Messages: 301

Tunneling pulseaudio with source and sink from guest to host works sometimes ... grrrr...
 

Phishfry

Son of Beastie

Reaction score: 1,641
Messages: 4,706

What I do is pass thru a GT710/GT730 NVidia card to each desktop bhyve VM. On this card is HDMI jack and Audio is passed thru on that interface.
Code:
ppt6@pci0:134:0:0:    class=0x030000 card=0x8c931462 chip=0x128b10de rev=0xa1 hdr=0x00
    vendor     = 'NVIDIA Corporation'
    device     = 'GK208B [GeForce GT 710]'
    class      = display
    subclass   = VGA
ppt7@pci0:134:0:1:    class=0x040300 card=0x8c931462 chip=0x0e0f10de rev=0xa1 hdr=0x00
    vendor     = 'NVIDIA Corporation'
    device     = 'GK208 HDMI/DP Audio Controller'
    class      = multimedia
    subclass   = HDA
 
OP
OP
Alain De Vos

Alain De Vos

Well-Known Member

Reaction score: 55
Messages: 301

This pci passthrough is a very interesting concept.
If i'm correct it allows to use hardware recognised by the guest even when there is no driver for the host.
 

Lamia

Well-Known Member

Reaction score: 72
Messages: 419

This pci passthrough is a very interesting concept.
If i'm correct it allows to use hardware recognised by the guest even when there is no driver for the host.
Did you mean the reverse - use hardware recognised by the host even when there is no driver for the guest?
 

Phishfry

Son of Beastie

Reaction score: 1,641
Messages: 4,706

No he had it right. Suppose you wanted to use an Atheros Module that is 802.11ac.
We have no support for that module. So you could pass it through and use it with Linux VM where it is supported. Even run it on a OpenWRT VM perhaps.
 

alx82

Member

Reaction score: 20
Messages: 36

HD sound works perfectly fine in bhyve and sound quality is as good as the host in my case.

You need commit 349335 and 350255 from FreeBSD head, you can get them at the following links: patch1 and patch2.

Alternatively, you can get them by using svn

Code:
$ cd $HOME
$ svn co https://svn.FreeBSD.org/base/head freebsd-head
$ cd  freebsd-head
$ svn diff -c 349335 > patch1.diff
$ svn diff -c 350255 > patch2.diff
Then apply those patches to /usr/src/usr.sbin/bhyve.

Code:
# cd /usr/src/usr.sbin/bhyve
# patch -Np2 -i $HOME/freebsd-head/patch1.diff
# patch -Np2 -i $HOME/freebsd-head/patch2.diff
# make
# make install
Then choose which dsp you want to use for play and rec
Code:
-s 6,hda,play=/dev/dsp0,rec=/dev/dsp0
I'm even using it at dsp2 (HDMI output) and it works perfectly fine. I use it mostly for my Linux guest for running google chrome in order to be able to use
a proprietary web conferecing used by my company.
 
OP
OP
Alain De Vos

Alain De Vos

Well-Known Member

Reaction score: 55
Messages: 301

I was able to play sound from the linux guest to my usb dac scarlett 8i6 focusrite which does not work with freesd.
However after stopping bhyve no usb devices our found so i guess the software is a bit buggy and does not release all resources, a reboot is needed.
 

aragats

Daemon

Reaction score: 575
Messages: 1,424

the software is a bit buggy and does not release all resources, a reboot is needed
Yes, I filed a bug report 2 years or so ago regarding similar resource non-releasing, not sure about its status, will try to find.
 
OP
OP
Alain De Vos

Alain De Vos

Well-Known Member

Reaction score: 55
Messages: 301

Another minor issue is that you cannot boot the host through grub/kfreebsd as pptdevs="2/0/0" is nor a kernel tunable parameter nor a loadable module.
 
Last edited:

Phishfry

Son of Beastie

Reaction score: 1,641
Messages: 4,706

Could you expand on your issue here?
grub does not need any settings. It is only a bootloader. The settings go in your bhyve arguments.
My bhyve host machine has pptdevs="132/0/1" setting in its /boot/loader.conf
I am running grub-bhyve for a Devuan VM with the networking passed-thru.
Here is my example for setup of new VM:
grub-bhyve -S -r cd0 -m /vm/device.map -M 2048 devuan1
Then hit "Install" from the grub menu. It will drop you back to a command prompt. Then start bhyve:
bhyve -S -c 4 -m 8G -A -H -P -u -s 0:0,hostbridge -s 3:0,ahci-hd,/vm/devuan1.img -s 4:0,ahci-cd,/vm/devuan_ascii_2.1_amd64_netinst.iso -s 5:0,passthru,132/0/1 -s 30:0,xhci,tablet -s 31:0,lpc -l com1,/dev/nmdm4A devuan1

My device map:
(hd0) /vm/devuan1.img
(cd0) /vm/devuan_ascii_2.1_amd64_netinst.iso

For running the devuan1 VM:
grub-bhyve -m /vm/device.map -r hd0,msdos1 -M 2048M -S devuan1 -d /boot/grub/
sleep 6 ### I need this for my bhyve startup script as the grub menu has to complete before I can load bhyve ###
bhyve -S -c 4 -m 2G -A -H -P -u -s 0:0,hostbridge -s 3:0,ahci-hd,/vm/devuan1.img -s 5:0,passthru,132/0/1 -s 30:0,xhci,tablet -s 31:0,lpc -l com1,/dev/nmdm4A devuan1 & ### the ampersand(&) is needed for my startup script.###

So as you can see I am passing thru 132/0/1 for my networking. A quad port Intel NIC. One port is 132/0/1.
Please notice that you need the "-S" switch for both grub-bhyve and bhyve to use pass-thru.
I access this vm locally with cu:
cu -l /dev/nmdm4B
lspci | egrep -i 'network|ethernet'
00:00.0 Host bridge: Network Appliance Corporation Device 1275
00:05.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (Copper) (rev 06)
 
Top