Starting to write my own script to manage bhyve VMs.
vm-bhyve isn't going to allow me enough control to detect open netgraph hooks on bridges so I will manage the virtual machines myself.
This commit is contained in:
parent
0939203377
commit
9fcc955d13
@ -19,7 +19,7 @@ disk0_dev="sparse-zvol"
|
|||||||
virt_random="yes" # virtio-rnd
|
virt_random="yes" # virtio-rnd
|
||||||
|
|
||||||
# Creates a link to host_bridge1's link3 hook to the vmlink hook on a type socket
|
# Creates a link to host_bridge1's link3 hook to the vmlink hook on a type socket
|
||||||
bhyve_options="-s 2:0,virtio-net,netgraph,path=host_bridge1:,peerhook=link3"
|
bhyve_options="-s 2:0,virtio-net,netgraph,path=bridge_jail_nat:,peerhook=link90"
|
||||||
|
|
||||||
# Share a host directory to the guest via 9pfs.
|
# Share a host directory to the guest via 9pfs.
|
||||||
#
|
#
|
||||||
|
47
ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash
Normal file
47
ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/local/bin/bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
function main {
|
||||||
|
if [ "$1" = "create-disk" ]; then
|
||||||
|
shift 1
|
||||||
|
create_disk "${@}"
|
||||||
|
elif [ "$1" = "start" ]; then
|
||||||
|
shift 1
|
||||||
|
start_vm "${@}"
|
||||||
|
else
|
||||||
|
>&2 echo "Unrecognized command"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_disk {
|
||||||
|
zfs_path="$1"
|
||||||
|
gigabytes="$2"
|
||||||
|
zfs create "-V${gigabytes}G" -o volmode=dev "$zfs_path"
|
||||||
|
}
|
||||||
|
|
||||||
|
function start_vm {
|
||||||
|
name="$1"
|
||||||
|
zfs_path="$2"
|
||||||
|
CPU_CORES=1
|
||||||
|
MEMORY=1G
|
||||||
|
# -H release the CPU when guest issues HLT instruction. Otherwise 100% of core will be consumed.
|
||||||
|
bhyve \
|
||||||
|
-c $CPU_CORES \
|
||||||
|
-m $MEMORY \
|
||||||
|
-H \
|
||||||
|
-s 0,hostbridge \
|
||||||
|
-s 3,ahci-cd,/vm/.iso/archlinux-2023.04.01-x86_64.iso \
|
||||||
|
-s 4,virtio-blk,/dev/zvol/${zfs_path} \
|
||||||
|
-s 2:0,virtio-net,netgraph,path=bridge_jail_nat:,peerhook=link90 \
|
||||||
|
-s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080,wait \
|
||||||
|
-s 30,xhci,tablet \
|
||||||
|
-s 31,lpc -l com1,stdio \
|
||||||
|
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
|
||||||
|
"$name"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "${@}"
|
Loading…
x
Reference in New Issue
Block a user