prepare-dvm.sh 973 B

123456789101112131415161718192021222324252627282930
  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. sleep 2
  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. ln -sf /home_volatile /home
  15. possibly_run_save_script
  16. touch /etc/this_is_dvm
  17. dmesg -c >/dev/null
  18. free | grep Mem: |
  19. (read a b c d ; xenstore-write device/qubes_used_mem $c)
  20. # we're still running in DispVM template
  21. echo "Waiting for save/restore..."
  22. # ... wait until qubes_restore.c (in Dom0) recreates VM-specific keys
  23. while ! xenstore-read qubes_restore_complete 2>/dev/null ; do
  24. usleep 10
  25. done
  26. echo Back to life.
  27. fi