Solved Video driver for FreeBSD on bhyve

I set up a FreeBSD 14.2 bhyve guest on 14.2 host that uses amdgpu. I can attach to the guest with vncviewer. However, I can't get startx to work. I have a working .xinitrc that calls openbox which is installed. I've installed various video drivers, and when none worked (I tried amdgpu as that's what the host runs, vesa, sfcb, vmware, and probably a few others) I installed on the guest drm-kmod. I've seen vermaden's excellent web page about running a FreeBSD guest on bhyve, but though he goes over booting it with uefi, he doesn't mention running X on it anywhere that I can find. https://vermaden.wordpress.com/2023/08/18/freebsd-bhyve-virtualization/

I thought this would be easy to find, but it hasn't been, at least for me. Most things I see assume you're accessing the guest though console. I even tried chatgpt which said that if using VNC the system should fall back to a vesa driver, but I still get No screens found.
 
There's not much detail in your original post so you're likely to only receive really vague, generic advice like:

"If X in your guest VM is not finding any screens - have you detached and passed through a PCI video device from the host for X to use?"

For better advice then at the very least post some detail on the components involved, like:

Host-side
Infrastructure: CPU model, RAM size, motherboard / chipset, maybe additional installed equipment like video cards as appropriate. e.g. i7-9700T, 32GB, Intel Q370 chipset, AMD Radeon 6800XT
Have you disabled "CSM", enabled VT-d, etc. in UEFI settings?
FreeBSD details: run freebsd-version -kru, show installed port versions for related ports like sysutils/vm-bhyve if you're using that, sysutils/edk2-bhyve, sysutils/bhyve-firmware (not sure this is a thing any more?): pkg info -I vm-bhyve edk2-bhyve bhyve-firmware
If you use sysutils/vm-bhyve then post the VM's config file, otherwise post the actual full bhyve command you run.
Do you start your VM on boot? Maybe post /boot/loader.conf, /etc/rc.conf, etc.
As we're potentially talking about PCI pass-through, as include the output of pciconf -lv from the host side.
Paste vm-bhyve.log if you have one?

Guest side
As X is involved, post your .xinitrc if that's what you're using.
Again, as PCI pass-through might be needed, post the guest's view of pciconf -lv

In general terms, mentally walk through the involved components from boot through to trying to run X in the guest and post any relevant details.
The more info the better!

Maybe a moderator could create a sticky post with a nicely formatted checklist for this sub-forum?
 
redmog, you're right, I am vaguer than I should be, but in various Linux guests, it's always been straight forward. It's on a Beelink SER5. vmconfig (which works with RH and Arch Linux
loader="uefi" graphics="yes" xhci_mouse="yes" memory="4096" network0_type="virtio-net" network0_switch="public" disk0_type="virtio-blk" bhyve_options="-s 8,hda,play=/dev/dsp,rec=/dev/dsp
I left off uuid, network mac and some other things.

VT-d is enabled.
I've done nothing with a PCI device, it's never been necessary (Linux and Windows VMs)

FreeBSD version is 14.2-RELEASE-P1

I start the vm with a simple sudo vm start then use vncviewer localhost:0

bhyve-firmware is 1.0_2
vm-bhyve is 1.6.0


Its .xinitrc (of the guest) just reads exec openbox-session.
It does give the error cannot run in framebuffer mode
please specify busIDs for all framebuffer devices.

I've not had that error before, and don't know how I would get the busIDs, though I'm writing this in quick response to your post and haven't done any searching on how to do that.




Emrion, thanks, if you have any useful info, I'd be grateful
 
scottro I've only really tried to use PCI pass-through for video output in Windows VMs - with very limited success - but my understanding is that the vm-bhyve config entry graphics="yes" creates a virtual/mock frame-buffer/video-device in the VM guest via actual bhyve command args like -s 6:0,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080. Totally unrelated to any GPU that might be present via CPU or PCI card, so no PCI pass-through applies.

So I'm guessing you'd need a simple X driver, rather than an AMD or Intel one?
You mention it works for Linux VMs so it's a bit strange that whatever X config you use for Linux guests doesn't "just work" for your FreeBSD guest.

Regarding "please specify busIDs for all framebuffer devices" - try running pciconf -lv in your FreeBSD guest and look for vgapci devices.
Alternatively, look at your vm-bhyve.log file for the -s 6:0,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080 bhyve arg. The 6:0 is busID in the guest.

Example pciconf -lv output from FreeBSD VM with graphics="yes"
Code:
# pciconf -lv
vgapci0@pci0:0:6:0:     class=0x030000 rev=0x00 hdr=0x00 vendor=0xfb5d device=0x40fb subvendor=0x0000 subdevice=0x0000
    class      = display
    subclass   = VGA
 
I've installed various video drivers, and when none worked (I tried amdgpu as that's what the host runs, vesa, sfcb, vmware, and probably a few others)
Its .xinitrc (of the guest) just reads exec openbox-session.
It does give the error cannot run in framebuffer mode
please specify busIDs for all framebuffer devices.
You need to set up a xorg "Device" driver configuration, i.e.:

/usr/local/etc/X11/xorg.conf.d/scfb.conf
Code:
Section "Device"
    Identifier    "card0"
    Driver        "scfb"
EndSection


Side note, I've noticed
bhyve_options="-s 8,hda,play=/dev/dsp,rec=/dev/dsp
Do you use bhyve_options for sound intentional, because vm(8)-bhyve has
Code:
     sound              Set this option to yes in order to provide HD Audio
                        Emulation to the guest. Please see bhyve(8) for
                        details.

     sound_play         Set this to the desired audio output device of the
                        host to the guest. Defaults to '/dev/dsp0'

     sound_rec          Set this to the desired audio input device of the host
                        to the guest. If empty no audio input device is
                        configured. Defaults to '' (empty)
 
I've seen vermaden's excellent web page about running a FreeBSD guest on bhyve, but though he goes over booting it with uefi, he doesn't mention running X on it anywhere that I can find. https://vermaden.wordpress.com/2023/08/18/freebsd-bhyve-virtualization/
You are right - I need to update that.

If you boot in BIOS mode - with bhyveload - then you will use 'vesa' driver in X11 - probably limited to 1024x768 resolution maximum.

If you boot in UEFI mode - with uefi - then you will use 'scfb' driver in X11 - and You can have up to 1920x1080 resolution.

Both are 'software' modes - you can also pass a GPU into the FreeBSD VM - but that is another story.
 
Emrion on, and T-Daemon thanks much!! That did it, putting in busID from pciconf in a /usr/local/X11/xorg.conf.d or putting in the scfb. Either one enabled me to get X up and running. Thanks to both of you, I can mark this one solved.
I did find that I had to comment out the xhci. Also T-Daemon as for the sound entries, I just copied that from vermaden's pages, figuring it wouldn't work, as I'd had no luck. And when it did work, I lazily didn't investigate further.
And redmog thanks for your hints too. As you guys can see, the pciconf did get me the busIDs. and they work too.
 
Back
Top