freebsd/bhyve - windows guest recieves no input

Software environment

  • Operating system: FreeBSD 14.1-RELEASE-p5
  • Architecture: x86_64
  • kernel version: generic
  • libvirt version: 10.8.0
  • Guest OS: Windows Server 2022 x86_64

Description of problem

When creating a virtual machine with libvirt using the bhyve driver, during the efi menu mouse and keyboard inputs via VNC work correctly. However, once the windows installer loads, the mouse and keyboard via VNC do not work and no input is possible.

Steps to reproduce

  1. Create a virtual machine on freebsd/bhyve for windows
  2. Attempt to install
  3. No input :(

Additional information

This is the bhyve command line as emitted by virsh -c "bhyve:///system" domxml-to-native --format bhyve-argv --xml win22k2.xml

/usr/sbin/bhyve -c 4 -m 4096 -H -P -s 0:0,hostbridge -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
  -s 1:0,lpc -s 2:0,ahci,hd:/var/lib/libvirt/images/win2k22.img,cd:/var/lib/libvirt/images/en-us_windows_server_2022_updated_june_2024_x64_dvd_8c5a802d.iso \
  -s 3:0,e1000,tap0,mac=00:16:3e:fe:c2:35 -s 4:0,fbuf,tcp=0.0.0.0:5901,password=password \
  -l com1,/dev/nmdma058ad85-1ec9-4889-a6f8-5d8885c34af9A win2k22

I ran this command directly and noted the error messages:

fbuf frame buffer base: 0x3a3edd600000 [sz 16777216]
atkbd data buffer full
atkbd data buffer full
atkbd data buffer full
atkbd data buffer full

While researching this issue I found the following reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213734

The important part here is that libvirt configures the lpc with -s 1:0,lpc however this issue states that windows expects it to be -s 31,lpc. When running this with the changed lpc slot address, windows does correctly begin to process input. ( https://gitlab.com/libvirt/libvirt/-/blob/master/src/bhyve/bhyve_device.c#L86 )

The following page makes the same observation: https://wiki.freebsd.org/bhyve/Windows

" - AHCI devices must be in slots 3/4/5/6 - The PCI-ISA bus aka lpc must be in slot 31 - virtio-net devices can be in any slot "

I expect the fix here is for the bhyve driver to use the above slot assignment rules by default.