summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2018-02-20 10:12:15 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2018-02-20 10:12:15 +0000
commitd03e62a7b62303ef650eed58e033ff97a977e3b9 (patch)
tree77346d13586cb646a2b72fe9ea80aae4ce9e2b8e /etc
parent4711b7eb280a4bed53c981a7f384ab42762f5e9d (diff)
Call "vmctl stop" on each VM at shutdown, for OpenBSD guests this means they
are signalled to shutdown cleanly. Wait for each to finish to avoid too much busy work at once; this may need revising if it turns out to be too slow with a larger number of VMs (e.g. signal/delay/signal/delay/... then wait for shutdowns), but let's avoid making it more complex unless we know it's needed. Based on a diff from abieber@, discussed with mlarkin@ aja@ rpe@, ok rpe
Diffstat (limited to 'etc')
-rw-r--r--etc/rc.d/vmd17
1 files changed, 16 insertions, 1 deletions
diff --git a/etc/rc.d/vmd b/etc/rc.d/vmd
index 43d043164e1..f023ff34954 100644
--- a/etc/rc.d/vmd
+++ b/etc/rc.d/vmd
@@ -1,6 +1,6 @@
#!/bin/ksh
#
-# $OpenBSD: vmd,v 1.6 2018/01/11 22:44:44 rpe Exp $
+# $OpenBSD: vmd,v 1.7 2018/02/20 10:12:14 sthen Exp $
daemon="/usr/sbin/vmd"
@@ -11,4 +11,19 @@ rc_pre() {
${daemon} -n ${daemon_flags}
}
+list_running() {
+ vmctl status | awk '$2 ~ "[0-9]" {print $8}'
+}
+
+rc_stop() {
+ for vm in $(list_running); do
+ _rc_do vmctl stop "$vm"
+ while list_running | fgrep -wq "$vm"; do
+ sleep .1
+ done
+ done
+
+ pkill -T "${daemon_rtable}" -xf "${pexp}"
+}
+
rc_cmd $1