diff files/fbhyve.in @ 476:c3ad1105c746

Implement a "kill" extra-commant for fbhyve to do an immediate poweroff of a VM
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 27 Aug 2024 22:33:57 +0200
parents 827371176fec
children 3f187ec5c4d9
line wrap: on
line diff
--- a/files/fbhyve.in	Tue Aug 27 21:50:35 2024 +0200
+++ b/files/fbhyve.in	Tue Aug 27 22:33:57 2024 +0200
@@ -34,9 +34,11 @@
 desc="Manage system bhyve virtual machines"
 rcvar="fbhyve_enable"
 
+extra_commands="kill"
 start_precmd="fbhyve_pre_start"
 stop_postcmd="fbhyve_post_stop"
 status_cmd="fbhyve_status"
+kill_cmd="fbhyve_kill"
 
 
 load_rc_config $name
@@ -154,4 +156,15 @@
 }
 
 
+fbhyve_kill()
+{
+    # Just kill without terminating
+    if [ -e "/dev/vmm/${_vm}" ]; then
+        /usr/sbin/bhyvectl --vm="${_vm}" --force-poweroff 2>/dev/null 1>/dev/null
+    fi
+    # and do the normal cleanup
+    fbhyve_post_stop
+}
+
+
 run_rc_command "$1"