7 # somehow qemu-system-x86_64 show up in pgrep as qemu-system-x86
8 COMMANDS_TO_KILL="qemu qemu-system-x86_64 qemu-system-x86"
11 echo "Usage: $COMMAND -l"
12 echo " lists current qemu processes"
13 echo "usage: $COMMAND hostname"
14 echo " kill qemu instance for that node"
15 echo "usage: $COMMAND"
16 echo " kill all instances of [$COMMANDS_TO_KILL]"
20 function list_pids () {
22 if [[ -n "$hostnames" ]] ; then
23 for hostname in $hostnames; do
24 nodedir=qemu-$hostname
25 cat $nodedir/qemu.pid 2> /dev/null
28 for command in $COMMANDS_TO_KILL; do
34 function kill_from_file () {
36 if [ -f $file ] ; then
42 echo "Could not find file $file - that qemu was killed already"
46 function kill_pids () {
48 if [[ -n "$hostnames" ]] ; then
49 for hostname in $hostnames; do
50 nodedir=qemu-$hostname
51 kill_from_file $nodedir/qemu.pid
55 if [ -n "$pids" ] ; then
56 echo "Killing all processes matching $COMMANDS_TO_KILL"
62 echo "No process found that match $COMMANDS_TO_KILL"
67 function show_pids () {
68 pids=$(list_pids "$@")
69 if [ -n "$pids" ] ; then
70 ps $pids | grep -v $COMMAND || echo Nothing to show
77 while getopts "lk" opt; do
87 if [ -n "$OPT_LIST" ] ; then