From e40f41e50562873fcdb78bec891a8f19141d4b42 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 17 Feb 2014 00:34:19 +0100 Subject: [PATCH] vm/windows: Collect exit code from xchg. This is the last item that was missing to get a fully working runInWindowsVM function. Apart from checking exit codes, we also now have preVM/postVM hooks which we can use to write arbitrary constructs around this architecture, without the need to worry about specific details. Signed-off-by: aszlig --- .../vm/windows/controller/default.nix | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/vm/windows/controller/default.nix b/pkgs/build-support/vm/windows/controller/default.nix index 4a3e88a22c69..621729eaabb2 100644 --- a/pkgs/build-support/vm/windows/controller/default.nix +++ b/pkgs/build-support/vm/windows/controller/default.nix @@ -128,12 +128,10 @@ let -i /ssh.key \ -l Administrator \ 192.168.0.1 -- ${shellEscape command} - - ${lib.optionalString (suspendTo != null) '' + '') + lib.optionalString (suspendTo != null) '' ${coreutils}/bin/touch /xchg/suspend_now ${loopForever} - ''} - '')); + ''); kernelAppend = lib.concatStringsSep " " [ "panic=1" @@ -175,6 +173,9 @@ let (set; declare -p) > saved-env XCHG_DIR="$(${coreutils}/bin/mktemp -d nix-vm.XXXXXXXXXX --tmpdir)" ${coreutils}/bin/mv saved-env "$XCHG_DIR/" + + eval "$preVM" + QEMU_VDE_SOCKET="$(pwd)/vde.ctl" MONITOR_SOCKET="$(pwd)/monitor" ${vde2}/bin/vde_switch -s "$QEMU_VDE_SOCKET" & @@ -190,7 +191,9 @@ let '' else '' ${vmTools.qemuProg} ${cygwinQemuArgs} & ${vmTools.qemuProg} ${controllerQemuArgs}${bgBoth} - '' + lib.optionalString (suspendTo != null) '' + ''; + + postVM = if suspendTo != null then '' while ! test -e "$XCHG_DIR/suspend_now"; do sleep 1; done ${socat}/bin/socat - UNIX-CONNECT:$MONITOR_SOCKET <