[Bug 262113] bhyve fails every other attempt to run

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 22 Feb 2022 00:31:13 UTC

            Bug ID: 262113
           Summary: bhyve fails every other attempt to run
           Product: Base System
           Version: 13.0-STABLE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bhyve
          Assignee: virtualization@FreeBSD.org
          Reporter: risner@stdio.com

using an UEFI OS and the commands executed below, you may start bhyve.
Regardless of the way you exit (ctrl-c, halt or reboot from inside the vm);
when you retry you will get an invalid argument error. Retrying immediately
after, it works. The cycle then repeats.

bhyvectl --destroy --vm=test0
bhyve -AHP -c 1 -m 1024M -S -s 0,hostbridge -s 1,lpc -l
bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd -s 3,ahci-hd,efiboot.img
-s 29,fbuf,tcp=,w=800,h=600 test0

From testing modifications to bhyve, the libvmmapi, and the kernel module I
found that line 1006 of bhyverun.c calls vm_create and returns with EEXIST
despite there being no entry in /dev/vmm and having ran bhyvectl --destroy
immediately before bhyve.

I could not conclusively prove what exactly is going on inside the kernel

It fails on FreeBSD-13 p4 and p7. It failed on two different Cisco amd64
systems I had.

If you don't have a testing OS with uefi, you can make a temporary one with
dd if=/dev/zero of=efiboot.img bs=300m count=1
mdconfig -a -t vnode -f efiboot.img
gpart create -s gpt md0
gpart add -t efi -s 256m md0
newfs_msdos -F 32 -c 1 -m 0xf8 /dev/md0p1 # format efi
mount -t msdosfs /dev/md0p1 /mnt
mkdir -p /mnt/EFI/BOOT
wget -O /mnt/EFI/BOOT/BOOTX64.efi
umount /mnt
mdconfig -d -u 0

You are receiving this mail because:
You are the assignee for the bug.