On 2018/02/16 17:55, Aaron Bieber wrote:
> 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.

Simpler and less busy-waiting. Do we need a timeout though?

Index: vmd
===================================================================
RCS file: /cvs/src/etc/rc.d/vmd,v
retrieving revision 1.6
diff -u -p -r1.6 vmd
--- vmd 11 Jan 2018 22:44:44 -0000      1.6
+++ vmd 17 Feb 2018 10:09:10 -0000
@@ -11,4 +11,20 @@ rc_pre() {
        ${daemon} -n ${daemon_flags}
 }
 
+list_running() {
+       vmctl status | awk '$2 ~ "[0-9]" {print $NF}'
+}
+
+rc_stop() {
+       for vm in $(list_running); do
+               vmctl stop "$vm"
+       done
+
+       while [[ -n $(list_running) ]]; do
+               sleep .1
+       done
+
+       pkill -T "${daemon_rtable}" -xf "${pexp}"
+}
+
 rc_cmd $1

Reply via email to