]> xenbits.xensource.com Git - people/aperard/xen-arm.git/commitdiff
xencommons: Stop QEMU in do_stop()
authorWei Liu <wei.liu2@citrix.com>
Fri, 11 Jan 2013 12:22:28 +0000 (12:22 +0000)
committerWei Liu <wei.liu2@citrix.com>
Fri, 11 Jan 2013 12:22:28 +0000 (12:22 +0000)
do_stop() is invoked by "restart" action. We can get multiple QEMUs started up
for Dom0 if we don't kill previous ones.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/hotplug/Linux/init.d/xencommons

index cc8177e6ea558d72a5b516747ac13057f2c76310..cc5e45c5bfd90446960f6600c0807db27baf003e 100644 (file)
@@ -27,6 +27,7 @@ fi
 test -f $xencommons_config/xencommons && . $xencommons_config/xencommons
 
 XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
+QEMU_PIDFILE=/var/run/qemu-dom0.pid
 shopt -s extglob
 
 # not running in Xen dom0 or domU
@@ -116,7 +117,7 @@ do_start () {
        test "`uname`" != "NetBSD" || xenbackendd $XENBACKENDD_ARGS
        echo Starting QEMU as disk backend for dom0
        test -z "$QEMU_XEN" && QEMU_XEN=/usr/lib/xen/bin/qemu-system-i386
-       $QEMU_XEN -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv -daemonize -monitor /dev/null
+       $QEMU_XEN -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv -daemonize -monitor /dev/null -pidfile $QEMU_PIDFILE
 }
 do_stop () {
         echo Stopping xenconsoled
@@ -126,6 +127,13 @@ do_stop () {
                rm -f $XENCONSOLED_PIDFILE
        fi
 
+       echo Stopping QEMU
+       if read 2>/dev/null <$QEMU_PIDFILE pid; then
+               kill $pid
+               while kill -9 $pid >/dev/null 2>&1; do sleep 0.1; done
+               rm -f $QEMU_PIDFILE
+       fi
+
        echo WARNING: Not stopping xenstored, as it cannot be restarted.
 }