diff --git a/pkgs/build-support/vm/windows/bootstrap.nix b/pkgs/build-support/vm/windows/bootstrap.nix index 47afce5b5a37..e3b44d1b6ab7 100644 --- a/pkgs/build-support/vm/windows/bootstrap.nix +++ b/pkgs/build-support/vm/windows/bootstrap.nix @@ -1,6 +1,6 @@ { stdenv, fetchurl, vmTools, writeScript, writeText, runCommand, makeInitrd , python, perl, coreutils, dosfstools, gzip, mtools, netcat, openssh, qemu -, samba, socat, vde2, cdrkit, pathsFromGraph +, samba, socat, vde2, cdrkit, pathsFromGraph, gnugrep }: { isoFile, productKey, arch ? null }: @@ -10,7 +10,7 @@ with stdenv.lib; let controller = import ./controller { inherit stdenv writeScript vmTools makeInitrd; - inherit samba vde2 openssh socat netcat coreutils gzip; + inherit samba vde2 openssh socat netcat coreutils gzip gnugrep; }; mkCygwinImage = import ./cygwin-iso { diff --git a/pkgs/build-support/vm/windows/controller/default.nix b/pkgs/build-support/vm/windows/controller/default.nix index ee9bf0286943..0beaf401758a 100644 --- a/pkgs/build-support/vm/windows/controller/default.nix +++ b/pkgs/build-support/vm/windows/controller/default.nix @@ -1,5 +1,5 @@ { stdenv, writeScript, vmTools, makeInitrd -, samba, vde2, openssh, socat, netcat, coreutils, gzip +, samba, vde2, openssh, socat, netcat, coreutils, gnugrep, gzip }: { sshKey @@ -217,17 +217,26 @@ let fi ''; + toMonitor = "${socat}/bin/socat - UNIX-CONNECT:$MONITOR_SOCKET"; + postVM = if suspendTo != null then '' while ! test -e "$XCHG_DIR/suspend_now"; do ${checkDropOut} ${coreutils}/bin/sleep 1 done - ${socat}/bin/socat - UNIX-CONNECT:$MONITOR_SOCKET < '${suspendTo}'" - quit CMD + echo -n "Waiting for memory dump to finish..." + while ! echo info migrate | ${toMonitor} | \ + ${gnugrep}/bin/grep -qi '^migration *status: *complete'; do + ${coreutils}/bin/sleep 1 + echo -n . + done + echo " done." + echo quit | ${toMonitor} wait $(< "$WINVM_PIDFILE") eval "$postVM" exit 0 diff --git a/pkgs/build-support/vm/windows/default.nix b/pkgs/build-support/vm/windows/default.nix index f9b44d450d99..f9f1d75c70d6 100644 --- a/pkgs/build-support/vm/windows/default.nix +++ b/pkgs/build-support/vm/windows/default.nix @@ -5,6 +5,7 @@ let inherit (pkgs) stdenv vmTools writeScript writeText runCommand makeInitrd; inherit (pkgs) coreutils dosfstools gzip mtools netcat openssh qemu samba; inherit (pkgs) socat vde2 fetchurl python perl cdrkit pathsFromGraph; + inherit (pkgs) gnugrep; }; builder = ''