machyve / xhyve

xhyve, a lightweight OS X virtualization solution
Other
6.44k stars 354 forks source link

crash with virtio-net + UEFI #164

Open adaugherity opened 5 years ago

adaugherity commented 5 years ago

I tried to see if I could use UEFI to load GRUB 2 from within the guest, to avoid having to copy the kernel/initrd from the guest to host after every kernel patch. Unfortunately, xhyve immediately crashes:

Assertion failed: (v.vm_pkt_size >= vms->max_packet_size), function vmn_read, file src/pci_virtio_net_vmnet.c, line 337.

./xhyverun-suse.sh: line 68: 11365 Abort trap: 6 sudo xhyve -AHP -U $UUID -m 1G -c 2 -s 0:0,hostbridge -s 2:0,ahci-cd,$ISO -s 2:1,virtio-blk,"$IMG" -s 4,virtio-net -s 31,lpc -l com1,stdio -l bootrom,$FIRMWARE

(FIRMWARE=BHYVE_UEFI.fd copied from FreeBSD, of course; I was previously using -f kexec,$KERNEL,$INITRD,"$CMDLINE" instead of -l bootrom,$FIRMWARE.)

If I change virtio-net to e1000, then everything works properly, at least with a serial console. I'm having issues with VNC but that's unrelated to vmnet.

labrnth commented 5 years ago

I'm getting the same issue when running OpenBSD 6.5 using UEFI and the virtio-net interface.

Assertion failed: (v.vm_pkt_size >= vms->max_packet_size), function vmn_read, file src/pci_virtio_net_vmnet.c, line 337.

./xhyve-openbsd-32667A64-67E6-4C32-A045-B7E2B2413A6E.sh: line 20: 237 Abort trap: 6 xhyve $ACPI $MEM $SMP -w -u -H $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD $UEFI

Like @adaugherity if I use the e1000 interface it works. Oddly, I can occasionally get it to work but only if I have another xhyve VM running using the e1000 interface. So I have successfully been able to run the VM with the virtio-net interface but I can't consistently reproduce it.

Here is the script I used for OpenBSD 6.5 xhyve VM.

#!/bin/sh

UUID="-U 32667A64-67E6-4C32-A045-B7E2B2413A6E"

#MEDIA="../../media/install65.fs"
IMG="hdd-32667A64-67E6-4C32-A045-B7E2B2413A6E.img"
FIRMWARE="../firmware/BHYVE_UEFI.fd"

MEM="-m 2G"
#SMP="-c 2"
#IMG_CD="-s 3,ahci-hd,$MEDIA"
IMG_HDD="-s 3,ahci-hd,$IMG"
NET="-s 5,virtio-net"
#NET="-s 5,e1000"
PCI_DEV="-s 0,amd_hostbridge"
LPC_DEV="-s 31,lpc -l com1,stdio"
ACPI="-A"
UEFI="-l bootrom,$FIRMWARE"

xhyve $ACPI $MEM $SMP -w -u -H $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD $UEFI

Here are the boot messages of one of the successful times it booted.

https://pastebin.com/raw/uS78AWjt

mike-pt commented 4 years ago

same here:

Assertion failed: (v.vm_pkt_size >= vms->max_packet_size), function vmn_read, file src/pci_virtio_net_vmnet.c, line 337.
 ./xhyverun-windows.sh: line 19:  2066 Abort trap: 6   
mike-pt commented 4 years ago

hum maybe related to #define BLOCKIF_IOV_MAX 33 /* not practical to be IOV_MAX */

this was raised upstream a while ago: https://reviews.freebsd.org/D10581

mike-pt commented 4 years ago
 git diff include/
diff --git a/include/xhyve/block_if.h b/include/xhyve/block_if.h
index fecfdbc..8937787 100644
--- a/include/xhyve/block_if.h
+++ b/include/xhyve/block_if.h
@@ -38,7 +38,7 @@
 #include <sys/uio.h>
 #include <sys/unistd.h>

-#define BLOCKIF_IOV_MAX 33 /* not practical to be IOV_MAX */
+#define BLOCKIF_IOV_MAX 128 /* not practical to be IOV_MAX */

 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wpadded"

This seems to fix the crash while loading the driver on install at least :)

EDIT: Actually I was confusing this with a "similar" issue get with the block driver but the GHI is originaly for virtio-net

adaugherity commented 4 years ago

I can confirm @autonomic's report that virtio-net+UEFI works if another VM is already running using e1000. Tested with both openSUSE Leap 15.1 and OpenBSD 6.6.

However... that only applies to booting from disk or cd. If the UEFI attempts to boot from the network, it crashes in the same way!

I discovered this by trying to figure out why my openSUSE VM would only boot from CD, not its hard disk, when using EFI. Turns out it was installed in BIOS mode and lacks an EFI System Partition, so that explains it. If I remove the CD from the VM config, it attempts to boot the hard disk (which fails), and then falls back to network booting... which crashes xhyve.