vm/windows: Wait for migration to finish.

This ensures that the intermediate machine is shut down only after the
migration has finished writing the memory dump to disk, to ensure we
don't end up with empty state files depending on how fast the migration
finished before we actually shut down the VM.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2014-05-07 06:48:53 +02:00
parent bd78e674c5
commit 97dc8a88e5
No known key found for this signature in database
GPG key ID: D0EBD0EC8C2DC961
3 changed files with 15 additions and 5 deletions

View file

@ -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 {

View file

@ -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 <<CMD
${toMonitor} <<CMD
stop
migrate_set_speed 4095m
migrate "exec:${gzip}/bin/gzip -c > '${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

View file

@ -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 = ''