2012-01-10 12:10:16 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
possibly_run_save_script()
|
|
|
|
{
|
2013-03-14 04:23:32 +01:00
|
|
|
ENCODED_SCRIPT=$(xenstore-read qubes-save-script)
|
2012-01-10 12:10:16 +01:00
|
|
|
if [ -z "$ENCODED_SCRIPT" ] ; then return ; fi
|
2013-03-14 04:30:22 +01:00
|
|
|
echo $ENCODED_SCRIPT|perl -e 'use MIME::Base64 qw(decode_base64); local($/) = undef;print decode_base64(<STDIN>)' >/tmp/qubes-save-script
|
|
|
|
chmod 755 /tmp/qubes-save-script
|
2012-01-10 12:10:16 +01:00
|
|
|
Xorg -config /etc/X11/xorg-preload-apps.conf :0 &
|
2012-07-22 01:21:43 +02:00
|
|
|
while ! [ -S /tmp/.X11-unix/X0 ]; do sleep 0.5; done
|
2013-03-14 04:30:22 +01:00
|
|
|
DISPLAY=:0 su - user -c /tmp/qubes-save-script
|
2012-01-10 12:10:16 +01:00
|
|
|
killall Xorg
|
|
|
|
}
|
|
|
|
|
2013-03-14 04:23:32 +01:00
|
|
|
if xenstore-read qubes-save-request 2>/dev/null ; then
|
2012-11-16 14:03:36 +01:00
|
|
|
if [ -L /home ]; then
|
|
|
|
rm /home
|
|
|
|
mkdir /home
|
|
|
|
fi
|
|
|
|
mount --bind /home_volatile /home
|
2013-03-13 02:26:40 +01:00
|
|
|
touch /etc/this-is-dvm
|
2012-11-12 13:44:10 +01:00
|
|
|
mount /rw
|
|
|
|
possibly_run_save_script
|
|
|
|
umount /rw
|
2012-01-10 12:10:16 +01:00
|
|
|
dmesg -c >/dev/null
|
|
|
|
free | grep Mem: |
|
2013-03-14 04:23:32 +01:00
|
|
|
(read a b c d ; xenstore-write device/qubes-used-mem $c)
|
2012-01-10 12:10:16 +01:00
|
|
|
# we're still running in DispVM template
|
|
|
|
echo "Waiting for save/restore..."
|
2013-03-14 04:23:32 +01:00
|
|
|
# ... wait until qubes-restore.c (in Dom0) recreates VM-specific keys
|
|
|
|
while ! xenstore-read qubes-restore-complete 2>/dev/null ; do
|
2014-08-02 23:44:48 +02:00
|
|
|
usleep 10000
|
2012-01-10 12:10:16 +01:00
|
|
|
done
|
|
|
|
echo Back to life.
|
|
|
|
fi
|
|
|
|
|