User Tools

Site Tools


freebsd:bhyve

This is an old revision of the document!


FreeBSD Bhyve

Initial Setup

loader.conf

/boot/loader.conf
kern.ipc.semmni=40
kern.ipc.semmns=300
vmm_load="YES"
nmdm_load="YES"
if_bridge_load="YES"
if_tap_load="YES"

rc.conf

  • add tap1, tap2, etc for more virtual machines
/etc/rc.conf
loned_interfaces="bridge0 tap0"
ifconfig_bridge0="addm re0 addm tap0"

sysctl.conf

/etc/sysctl.conf
net.link.tap.up_on_open=1

Install grub-bhyve and screen

pkg install grub2-bhyve
pkg install screen

Reboot

  • You should have a ifconfig bridge0 something like this.
  • The important thing is that you have a physical interface and a tapX device as members of the bridge
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 02:b1:2b:2e:66:00
        nd6 options=9<PERFORMNUD,IFDISABLED>
        groups: bridge 
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
        root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
        member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 4 priority 128 path cost 2000000
        member: re0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 1 priority 128 path cost 55
  • Your kldstat should have the following entries. I removed the entries that didn't apply to Bhyve
 1   44 0xffffffff80200000 1fa7c38  kernel
 4    1 0xffffffff824bf000 aaa0     if_tap.ko
 5    1 0xffffffff824ca000 11c38    if_bridge.ko
 6    2 0xffffffff824dc000 8f58     bridgestp.ko
12    1 0xffffffff82681000 3571f0   vmm.ko
13    1 0xffffffff829d9000 5010     nmdm.ko

Running VMs

run.sh

#!/bin/sh
 
CONSOLE="-l com1,stdio"
VMNAME="ubuntu16_04"
DISKIMAGE="-s 3:0,virtio-blk,./ubuntu-16.04.img"
RAM="1024M"
CPUS="4"
NETWORK="-s 2:0,virtio-net,tap0"
 
grub-bhyve -m device.map -r hd0,msdos1 -M ${RAM} ${VMNAME}
bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc ${NETWORK} ${DISKIMAGE} ${CONSOLE} -c ${CPUS} -m ${RAM} ${VMNAME}
bhyvectl --destroy --vm=${VMNAME}
freebsd/bhyve.1481056879.txt.gz · Last modified: 2016/12/06 14:41 by tschulz