diff options
author | Riku Voipio <riku.voipio@linaro.org> | 2017-05-11 13:47:23 +0300 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2017-05-12 15:47:09 +0000 |
commit | 2b26706ffe60224ea87b7c9c5fa9561350e32dcb (patch) | |
tree | 4d84c74a52c38422e9999d9f0b1e296deda5cb9c | |
parent | daec34dad7e701c5f92c7fb19b73f07ae68c7028 (diff) |
kvm-cloud: de-race shutdown
- move to automated dir
- start qemu with pidfile
- call shutdown with 1m timeout in guest for clean poweroff
- wait for qemu process recorded in pidfile to exit to
avoid primary lava connection to poweroff the machine before
guest has finished
Change-Id: I105ec3bbe3246a05552b3d13123ef4a3c7ea4c82
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
-rw-r--r-- | automated/linux/kvm/cloudinit.txt (renamed from common/scripts/kvm-cloud/cloudinit.txt) | 0 | ||||
-rwxr-xr-x | automated/linux/kvm/start-kvm.sh (renamed from common/scripts/kvm-cloud/start-kvm.sh) | 18 | ||||
-rw-r--r-- | automated/linux/kvm/start-kvm.yaml (renamed from ubuntu/start-kvm.yaml) | 10 | ||||
-rw-r--r-- | automated/linux/kvm/stop-guest.yaml (renamed from ubuntu/stop-guest.yaml) | 3 | ||||
-rwxr-xr-x | automated/linux/kvm/wait-ip.py (renamed from common/scripts/kvm-cloud/wait-ip.py) | 0 | ||||
-rwxr-xr-x | automated/linux/kvm/wait-kvm.sh | 8 |
6 files changed, 27 insertions, 12 deletions
diff --git a/common/scripts/kvm-cloud/cloudinit.txt b/automated/linux/kvm/cloudinit.txt index d9363f1..d9363f1 100644 --- a/common/scripts/kvm-cloud/cloudinit.txt +++ b/automated/linux/kvm/cloudinit.txt diff --git a/common/scripts/kvm-cloud/start-kvm.sh b/automated/linux/kvm/start-kvm.sh index d166771..6ed3a67 100755 --- a/common/scripts/kvm-cloud/start-kvm.sh +++ b/automated/linux/kvm/start-kvm.sh @@ -23,7 +23,7 @@ configure_guest() { IP=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'` SSH_KEY=`head -1 /root/.ssh/authorized_keys||head -1 $HOME/.ssh/authorized_keys` - sed -e "s,LAVA_KEY,$SSH_KEY,g" -e "s,LOCALIP,$IP,g" common/scripts/kvm-cloud/cloudinit.txt > cloudinit.tmp + sed -e "s,LAVA_KEY,$SSH_KEY,g" -e "s,LOCALIP,$IP,g" cloudinit.txt > cloudinit.tmp cat cloudinit.tmp cloud-localds cloud.img cloudinit.tmp } @@ -64,7 +64,8 @@ start_qemu_x86_64_aarch64() -drive if=none,id=cloud,file=cloud.img \ -device virtio-net-device,netdev=tap0 -netdev tap,id=tap0,script=no,downscript=no,ifname=tap0 \ -daemonize -display vnc=none \ - -serial file:qemu_aarch64.txt + -pidfile /run/qemu.pid \ + -serial file:qemu_aarch64.log } start_qemu_aarch64_aarch64() @@ -81,7 +82,8 @@ start_qemu_aarch64_aarch64() -drive if=none,id=cloud,file=cloud.img \ -device virtio-net-device,netdev=tap0 -netdev tap,id=tap0,script=no,downscript=no,ifname=tap0 \ -daemonize -enable-kvm -display vnc=none \ - -serial file:kvm-aarch64_aarch64.txt + -pidfile /run/qemu.pid \ + -serial file:kvm-aarch64_aarch64.log } start_qemu_x86_64_armv7l() @@ -99,7 +101,7 @@ start_qemu_x86_64_armv7l() -drive if=none,id=cloud,file=cloud.img \ -device virtio-net-device,netdev=tap0 -netdev tap,id=tap0,script=no,downscript=no,ifname=tap0 \ -daemonize -display vnc=none \ - -serial file:qemu_armv7l.txt + -serial file:qemu_armv7l.log } start_qemu_aarch64_armv7l() @@ -117,7 +119,8 @@ start_qemu_aarch64_armv7l() -drive if=none,id=cloud,file=cloud.img \ -device virtio-net-device,netdev=tap0 -netdev tap,id=tap0,script=no,downscript=no,ifname=tap0 \ -daemonize -enable-kvm -display vnc=none \ - -serial file:kvm-aarch64_armv7l.txt + -pidfile /run/qemu.pid \ + -serial file:kvm-aarch64_armv7l.log } start_qemu_armv7l_armv7l() @@ -135,7 +138,8 @@ start_qemu_armv7l_armv7l() -drive if=none,id=cloud,file=cloud.img \ -device virtio-net-device,netdev=tap0 -netdev tap,id=tap0,script=no,downscript=no,ifname=tap0 \ -daemonize -enable-kvm -display vnc=none \ - -serial file:kvm-armv7l_armv7l.txt + -pidfile /run/qemu.pid \ + -serial file:kvm-armv7l_armv7l.log } # This testcase expects a predefined br0 to connect to @@ -162,4 +166,4 @@ fi start_qemu_${ARCH}_${GUEST_ARCH} ${IMAGE} sleep 10 -tail *.txt +tail *.log diff --git a/ubuntu/start-kvm.yaml b/automated/linux/kvm/start-kvm.yaml index 992ce4b..567c57c 100644 --- a/ubuntu/start-kvm.yaml +++ b/automated/linux/kvm/start-kvm.yaml @@ -43,10 +43,12 @@ install: run: steps: - - 'lava-test-case kvm-init --shell [ -c /dev/kvm ]' - - 'sudo ./common/scripts/kvm-cloud/start-kvm.sh $GUEST_ARCH $GUEST_IMAGE $GUEST_FIRMWARE $GUEST_KERNEL $GUEST_CORES $GUEST_RAM' - - 'lava-send ipv4 ipaddr=$(./common/scripts/kvm-cloud/wait-ip.py)' + - cd ./automated/linux/kvm + - "lava-test-case kvm-init --shell [ -c /dev/kvm ]" + - sudo ./start-kvm.sh $GUEST_ARCH $GUEST_IMAGE $GUEST_FIRMWARE $GUEST_KERNEL $GUEST_CORES $GUEST_RAM + - lava-send ipv4 ipaddr=$(./wait-ip.py) - lava-send lava_start - lava-sync clients - - 'cat *.txt' + - sudo ./wait-kvm.sh /run/qemu.pid + - cat *.log diff --git a/ubuntu/stop-guest.yaml b/automated/linux/kvm/stop-guest.yaml index a2d9405..f04bf42 100644 --- a/ubuntu/stop-guest.yaml +++ b/automated/linux/kvm/stop-guest.yaml @@ -1,7 +1,7 @@ metadata: name: guest-complete format: "Lava-Test-Shell Test Definition 1.0" - description: "Signal tests inside guest complete" + description: "Signal tests inside guest complete and power off" maintainer: - riku.voipio@linaro.org scope: @@ -19,4 +19,5 @@ metadata: run: steps: - lava-sync clients + - shutdown -h +1 diff --git a/common/scripts/kvm-cloud/wait-ip.py b/automated/linux/kvm/wait-ip.py index 392fc8c..392fc8c 100755 --- a/common/scripts/kvm-cloud/wait-ip.py +++ b/automated/linux/kvm/wait-ip.py diff --git a/automated/linux/kvm/wait-kvm.sh b/automated/linux/kvm/wait-kvm.sh new file mode 100755 index 0000000..1ba1d07 --- /dev/null +++ b/automated/linux/kvm/wait-kvm.sh @@ -0,0 +1,8 @@ +#!/bin/sh -e + +[ -r "$1" ]||exit 0 + +while [ -d "/proc/$(cat $1)/" ] +do + sleep 10 +done |