Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 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 |
| files | docs/man/man8/fbhyve.rst files/fbhyve.in |
| diffstat | 2 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/man/man8/fbhyve.rst Tue Aug 27 21:50:35 2024 +0200 +++ b/docs/man/man8/fbhyve.rst Tue Aug 27 22:33:57 2024 +0200 @@ -6,7 +6,7 @@ Synopsis -------- -**service fbhyve** [ **start** | **stop** | **restart** | **poll** | **status** ] [**name**]... +**service fbhyve** [ **start** | **stop** | **restart** | **kill** | **poll** | **status** ] [**name**]... Description @@ -19,6 +19,15 @@ the name of the corresponding VM. +Extra Commands +~~~~~~~~~~~~~~ + +The extra command ``kill`` is like switching the power off immediately. + +The ``stop`` command initiates a clean shutdown by properly terminating +:manpage:`bhyve(8)` with `SIGTERM`. + + Configuration Variables ~~~~~~~~~~~~~~~~~~~~~~~
--- 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"
