run lxc-enter-namespace with --noseclabel
[tests.git] / system / template-qemu / qemu-kill-node
index 5d591f9..2d84607 100755 (executable)
@@ -1,17 +1,23 @@
 #!/bin/sh
-# $Id$
+#
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 COMMAND=$(basename $0)
 cd $(dirname $0)
+THISNODE=$(basename $(pwd -P) | sed -e s,qemu-,,)
 cd ..
 
 # somehow qemu-system-x86_64 show up in pgrep as qemu-system-x86
-COMMANDS_TO_KILL="qemu qemu-system-x86_64 qemu-system-x86"
+COMMANDS_TO_KILL="qemu qemu-system-x86_64 qemu-system-x86 qemu-kvm"
 
 function usage () {
     echo "Usage: $COMMAND -l"
     echo "  lists current qemu processes"
     echo "usage: $COMMAND hostname"
     echo "  kill qemu instance for that node"
+    echo "usage: $COMMAND this"
+    echo "  kill qemu instance that was started in this directory"
     echo "usage: $COMMAND"
     echo "  kill all instances of [$COMMANDS_TO_KILL]"
     exit 1
@@ -21,6 +27,7 @@ function list_pids () {
     hostnames="$@"
     if [[ -n "$hostnames" ]] ; then
        for hostname in $hostnames; do
+           [ $hostname == this ] && hostname=$THISNODE
            nodedir=qemu-$hostname
            cat $nodedir/qemu.pid 2> /dev/null
        done
@@ -47,6 +54,7 @@ function kill_pids () {
     hostnames="$@"
     if [[ -n "$hostnames" ]] ; then
        for hostname in $hostnames; do
+           [ $hostname == this ] && hostname=$THISNODE
            nodedir=qemu-$hostname
            kill_from_file $nodedir/qemu.pid
        done
@@ -77,7 +85,6 @@ function main () {
     while getopts "lk" opt; do
        case $opt in
            l) OPT_LIST=true ;;
-           k) OPT_GREP=true ;;
            *) usage ;;
        esac
     done