prepare-dvm.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. possibly_run_save_script()
  3. {
  4. ENCODED_SCRIPT=$(xenstore-read qubes-save-script)
  5. if [ -z "$ENCODED_SCRIPT" ] ; then return ; fi
  6. echo $ENCODED_SCRIPT|perl -e 'use MIME::Base64 qw(decode_base64); local($/) = undef;print decode_base64(<STDIN>)' >/tmp/qubes-save-script
  7. chmod 755 /tmp/qubes-save-script
  8. Xorg -config /etc/X11/xorg-preload-apps.conf :0 &
  9. while ! [ -S /tmp/.X11-unix/X0 ]; do sleep 0.5; done
  10. DISPLAY=:0 su - user -c /tmp/qubes-save-script
  11. killall Xorg
  12. }
  13. if xenstore-read qubes-save-request 2>/dev/null ; then
  14. if [ -L /home ]; then
  15. rm /home
  16. mkdir /home
  17. fi
  18. mount --bind /home_volatile /home
  19. touch /etc/this-is-dvm
  20. mount /rw
  21. possibly_run_save_script
  22. umount /rw
  23. dmesg -c >/dev/null
  24. free | grep Mem: |
  25. (read a b c d ; xenstore-write device/qubes-used-mem $c)
  26. # we're still running in DispVM template
  27. echo "Waiting for save/restore..."
  28. # ... wait until qubes-restore.c (in Dom0) recreates VM-specific keys
  29. while ! xenstore-read qubes-restore-complete 2>/dev/null ; do
  30. usleep 10
  31. done
  32. echo Back to life.
  33. fi