From e43fa0eab38e414f8a9184792e23610f16ece662 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 26 Apr 2023 18:17:35 -0400 Subject: [PATCH] Destroy the bhyve vm after exit. --- ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash b/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash index ca90800..7741002 100644 --- a/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash +++ b/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash @@ -52,7 +52,9 @@ function start_vm { # -s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080,wait \ while true; do set -x + set +e bhyve \ + -D \ -c $CPU_CORES \ -m $MEMORY \ -H \ @@ -65,6 +67,7 @@ function start_vm { -l "bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd,${mount_path}/BHYVE_UEFI_VARS.fd" \ "$name" exit_code=$? + set -e set +x if [ $exit_code -eq 0 ]; then echo "Rebooting." @@ -82,6 +85,9 @@ function start_vm { break fi done + + bhyvectl "--vm=$name" --destroy + echo "Destroyed bhyve vm." } function detect_available_link {