Hola,

Here is a stab at telling /etc/rc.d/vmd to wait for vms to shutdown
before killing vmd.

Since there is no linux vmmci layer - linux machines still get killed.

#!/bin/ksh
#
# $OpenBSD: vmd,v 1.6 2018/01/11 22:44:44 rpe Exp $

daemon="/usr/sbin/vmd"

. /etc/rc.d/rc.subr

# Child will not return a config parsing error to the parent.
rc_pre() {
        ${daemon} -n ${daemon_flags}
}

list_running() {
        echo $(vmctl status | awk '$2 ~ "[0-9]" {print $NF}')
}

rc_stop() {
        num_running=0
        for vm in $(list_running); do
                vmctl stop "$vm"
                ((num_running=num_running+1))
        done

        while [ $num_running -gt 0 ]; do
                c=0
                for vm in $(list_running); do
                        ((c=c+1))
                done

                if [ $c = 0 ]; then
                        num_running=0
                fi
        done

        pkill -T "${daemon_rtable}" -xf "${pexp}"
}

rc_cmd $1

--
PGP: 0x1F81112D62A9ADCE / 3586 3350 BFEA C101 DB1A  4AF0 1F81 112D 62A9 ADCE

Reply via email to