vm/windows: Exit if VM has dropped out.
This ensures that the builder isn't waiting forever if the Windows VM drops dead while we're waiting for the controller VM to signal that a particular command has been executed on the Windows VM. It won't ever happen in such cases so it doesn't make sense to wait for the timeout. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
535de5e45a
commit
bd78e674c5
|
@ -86,6 +86,7 @@ let
|
||||||
# Print a dot every 10 seconds only to shorten line length.
|
# Print a dot every 10 seconds only to shorten line length.
|
||||||
${coreutils}/bin/sleep 10
|
${coreutils}/bin/sleep 10
|
||||||
done
|
done
|
||||||
|
${coreutils}/bin/touch /xchg/waiting_done
|
||||||
echo " success."
|
echo " success."
|
||||||
# Loop forever, because this VM is going to be killed.
|
# Loop forever, because this VM is going to be killed.
|
||||||
${loopForever}
|
${loopForever}
|
||||||
|
@ -123,6 +124,7 @@ let
|
||||||
echo -n .
|
echo -n .
|
||||||
${coreutils}/bin/sleep 1
|
${coreutils}/bin/sleep 1
|
||||||
done
|
done
|
||||||
|
${coreutils}/bin/touch /xchg/waiting_done
|
||||||
echo " success."
|
echo " success."
|
||||||
|
|
||||||
${openssh}/bin/ssh \
|
${openssh}/bin/ssh \
|
||||||
|
@ -145,6 +147,7 @@ let
|
||||||
];
|
];
|
||||||
|
|
||||||
controllerQemuArgs = concatStringsSep " " (maybeKvm64 ++ [
|
controllerQemuArgs = concatStringsSep " " (maybeKvm64 ++ [
|
||||||
|
"-pidfile $CTRLVM_PIDFILE"
|
||||||
"-nographic"
|
"-nographic"
|
||||||
"-no-reboot"
|
"-no-reboot"
|
||||||
"-virtfs local,path=/nix/store,security_model=none,mount_tag=store"
|
"-virtfs local,path=/nix/store,security_model=none,mount_tag=store"
|
||||||
|
@ -160,6 +163,7 @@ let
|
||||||
|
|
||||||
cygwinQemuArgs = concatStringsSep " " (maybeKvm64 ++ [
|
cygwinQemuArgs = concatStringsSep " " (maybeKvm64 ++ [
|
||||||
"-monitor unix:$MONITOR_SOCKET,server,nowait"
|
"-monitor unix:$MONITOR_SOCKET,server,nowait"
|
||||||
|
"-pidfile $WINVM_PIDFILE"
|
||||||
"-nographic"
|
"-nographic"
|
||||||
"-net nic,vlan=0,macaddr=52:54:00:12:01:01"
|
"-net nic,vlan=0,macaddr=52:54:00:12:01:01"
|
||||||
"-net vde,vlan=0,sock=$QEMU_VDE_SOCKET"
|
"-net vde,vlan=0,sock=$QEMU_VDE_SOCKET"
|
||||||
|
@ -181,42 +185,64 @@ let
|
||||||
|
|
||||||
QEMU_VDE_SOCKET="$(pwd)/vde.ctl"
|
QEMU_VDE_SOCKET="$(pwd)/vde.ctl"
|
||||||
MONITOR_SOCKET="$(pwd)/monitor"
|
MONITOR_SOCKET="$(pwd)/monitor"
|
||||||
|
WINVM_PIDFILE="$(pwd)/winvm.pid"
|
||||||
|
CTRLVM_PIDFILE="$(pwd)/ctrlvm.pid"
|
||||||
${vde2}/bin/vde_switch -s "$QEMU_VDE_SOCKET" &
|
${vde2}/bin/vde_switch -s "$QEMU_VDE_SOCKET" &
|
||||||
echo 'alive?' | ${socat}/bin/socat - \
|
echo 'alive?' | ${socat}/bin/socat - \
|
||||||
UNIX-CONNECT:$QEMU_VDE_SOCKET/ctl,retry=20
|
UNIX-CONNECT:$QEMU_VDE_SOCKET/ctl,retry=20
|
||||||
'';
|
'';
|
||||||
|
|
||||||
bgBoth = optionalString (suspendTo != null) " &";
|
vmExec = ''
|
||||||
|
|
||||||
vmExec = if installMode then ''
|
|
||||||
${vmTools.qemuProg} ${controllerQemuArgs} &
|
${vmTools.qemuProg} ${controllerQemuArgs} &
|
||||||
${vmTools.qemuProg} ${cygwinQemuArgs}${bgBoth}
|
|
||||||
'' else ''
|
|
||||||
${vmTools.qemuProg} ${cygwinQemuArgs} &
|
${vmTools.qemuProg} ${cygwinQemuArgs} &
|
||||||
${vmTools.qemuProg} ${controllerQemuArgs}${bgBoth}
|
echo -n "Waiting for VMs to start up..."
|
||||||
|
timeout=60
|
||||||
|
while ! test -e "$WINVM_PIDFILE" -a -e "$CTRLVM_PIDFILE"; do
|
||||||
|
timeout=$(($timeout - 1))
|
||||||
|
echo -n .
|
||||||
|
if test $timeout -le 0; then
|
||||||
|
echo " timed out."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
${coreutils}/bin/sleep 1
|
||||||
|
done
|
||||||
|
echo " done."
|
||||||
|
'';
|
||||||
|
|
||||||
|
checkDropOut = ''
|
||||||
|
if ! test -e "$XCHG_DIR/waiting_done" &&
|
||||||
|
! kill -0 $(< "$WINVM_PIDFILE"); then
|
||||||
|
echo "Windows VM has dropped out early, bailing out!" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postVM = if suspendTo != null then ''
|
postVM = if suspendTo != null then ''
|
||||||
while ! test -e "$XCHG_DIR/suspend_now"; do sleep 1; done
|
while ! test -e "$XCHG_DIR/suspend_now"; do
|
||||||
|
${checkDropOut}
|
||||||
|
${coreutils}/bin/sleep 1
|
||||||
|
done
|
||||||
${socat}/bin/socat - UNIX-CONNECT:$MONITOR_SOCKET <<CMD
|
${socat}/bin/socat - UNIX-CONNECT:$MONITOR_SOCKET <<CMD
|
||||||
stop
|
stop
|
||||||
migrate_set_speed 4095m
|
migrate_set_speed 4095m
|
||||||
migrate "exec:${gzip}/bin/gzip -c > '${suspendTo}'"
|
migrate "exec:${gzip}/bin/gzip -c > '${suspendTo}'"
|
||||||
quit
|
quit
|
||||||
CMD
|
CMD
|
||||||
wait %-
|
wait $(< "$WINVM_PIDFILE")
|
||||||
|
|
||||||
eval "$postVM"
|
eval "$postVM"
|
||||||
exit 0
|
exit 0
|
||||||
'' else if installMode then ''
|
'' else if installMode then ''
|
||||||
|
wait $(< "$WINVM_PIDFILE")
|
||||||
eval "$postVM"
|
eval "$postVM"
|
||||||
exit 0
|
exit 0
|
||||||
'' else ''
|
'' else ''
|
||||||
|
while kill -0 $(< "$CTRLVM_PIDFILE"); do
|
||||||
|
${checkDropOut}
|
||||||
|
done
|
||||||
if ! test -e "$XCHG_DIR/in-vm-exit"; then
|
if ! test -e "$XCHG_DIR/in-vm-exit"; then
|
||||||
echo "Virtual machine didn't produce an exit code."
|
echo "Virtual machine didn't produce an exit code."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eval "$postVM"
|
eval "$postVM"
|
||||||
exit $(< "$XCHG_DIR/in-vm-exit")
|
exit $(< "$XCHG_DIR/in-vm-exit")
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in New Issue