qemu: use a pidfile to avoid killing all and thus enabling parallel runs

When killing QEMU, we defaulted to either killall or find the first
qemu process. This intefered with parallel builds, as we might kill
some other build's qemu process.

This makes QEMU write a pidfile in the local outdir directory and kill
only that when done.

Change-Id: I498b1e0833fcda9a7bd50111616dfba015e566bd
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
This commit is contained in:
Inaky Perez-Gonzalez 2015-04-17 16:09:19 -07:00 committed by Anas Nashif
commit 9343cc7ca0
3 changed files with 8 additions and 7 deletions

View file

@ -46,5 +46,8 @@ sinclude ${vMAKE}/target/run/arch/defs.qemu.x86-linux2.${vARCH}
# stop QEMU simulation
define Qemu_stop
@-killall -q ${vQEMU_NAME};${HOS_true}
@-if [ -r ${vOUT_DIR}/qemu.pid ]; then \
kill -9 $$(<${vOUT_DIR}/qemu.pid); \
rm -f ${vOUT_DIR}/qemu.pid; \
fi
endef

View file

@ -41,7 +41,7 @@ include ${vMAKE}/target/run/rules.qemu.${vHOST}
$q${HOS_Echo} [rules.qemu] Booting $<
$q${HOS_Echo} [${vQEMU_BIN} ${vQEMU_FLAGS}]
$q${HOS_Echo} ${iQEMU_BANNER}
$q${vQEMU_BIN} ${vQEMU_FLAGS} -kernel $< -serial ${iQEMU_CONSOLE} ${QEMU_EXTRA_FLAGS}
$q${vQEMU_BIN} ${vQEMU_FLAGS} -pidfile ${vOUT_DIR}/qemu.pid -kernel $< -serial ${iQEMU_CONSOLE} ${QEMU_EXTRA_FLAGS}
.PHONY: help_qemu
iQEMU_RUN_STR = $(foreach exec,${iHELP_EXEC_NAMES},${exec}.qemu): run

View file

@ -403,15 +403,13 @@ qemu_project() {
# get QEMU's pid
# (wait for QEMU process to be spawned by examining list of tasks
# associated with this script's terminal, then grab the pid)
while [ 1 ]
while ! [ -f outdir/qemu.pid ]
do
qemu_pid=$( ${PS} -T | ${AWK} '/qemu/ {print $1}' )
if [ x"${qemu_pid}" != x ] ; then
break
fi
${SLEEP} 1
done
qemu_pid=$(<outdir/qemu.pid)
# assume execution will fail
let RESULT=1