FDD-book/examples/part-04/ch18-writing-pci-driver/labs/launch_bhyve_guest.sh
Edson Brandi 6e6dac94fe Add book companion files under examples/
Organize companion code and materials by book part:

  part-01/      Foundations
  part-02/      Kernel & driver fundamentals
  part-03/      Character & block devices
  part-04/      Networking & storage
  part-05/      Buses & advanced topics
  part-06/      Debugging & performance
  part-07/      Real-world drivers
  appendices/   Supplementary material
  README.md     Overview and build instructions
2026-04-25 16:51:00 +00:00

31 lines
879 B
Bash
Executable file

#!/bin/sh
#
# Example bhyve command to launch a FreeBSD 14.3 guest with a
# virtio-rnd device exposed on PCI slot 4. Adapt paths and device
# names to your environment.
#
# Prerequisites (on the host):
# - A FreeBSD guest image (zfs zvol or a raw disk file).
# - bhyve's kernel modules loaded: vmm, nmdm, if_bridge, if_tap.
# - A bridged tap network interface if the guest needs networking.
# - BHYVE_UEFI.fd available (from the uefi-edk2-bhyve package).
set -eu
GUEST="fbsd-14.3-lab"
DISK="/dev/zvol/zroot/vm/${GUEST}/disk0"
TAP="tap0"
UEFI="/usr/local/share/uefi-firmware/BHYVE_UEFI.fd"
NMDM="/dev/nmdm${GUEST}A"
kldload -n vmm nmdm if_bridge if_tap
bhyve -c 2 -m 2048 -H -w \
-s 0:0,hostbridge \
-s 1:0,lpc \
-s 2:0,virtio-net,"$TAP" \
-s 3:0,virtio-blk,"$DISK" \
-s 4:0,virtio-rnd \
-l com1,"$NMDM" \
-l bootrom,"$UEFI" \
"$GUEST"