fine-grain & brute force qemu kill (kill_qemus and kill_all_qemus)
[tests.git] / system / qemu_kill.sh
1 #!/bin/sh
2 COMMAND=$(basename $0)
3
4 hostname=$1; shift
5 pids="$(ps $(pgrep qemu) | grep $hostname | awk '{print $1;}')"
6
7 if [ -z "$pids" ] ; then
8     echo $COMMAND: no qemu instance for $hostname found on $(hostname)
9 else
10     echo Killing $pids
11     kill $pids
12     sleep 2
13     if [ -n "$(ps $pids)" ] ; then
14         echo Killing -9 $pids
15         kill -9 $pids
16     fi
17     echo Done
18 fi