Quick VM restore support

This commit is contained in:
Rafal Wojtczuk 2010-06-02 15:50:22 +02:00 committed by Joanna Rutkowska
parent b9e815120d
commit 0a11679afb
4 changed files with 52 additions and 24 deletions

View File

@ -8,7 +8,7 @@
#
/dev/mapper/dmroot / ext4 defaults,noatime 1 1
/dev/mapper/dmswap swap swap defaults 0 0
/dev/xvdb /rw ext4 defaults 0 0
/dev/xvdb /rw ext4 noauto,defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0

View File

@ -14,6 +14,20 @@ start()
echo "ERROR: /usr/bin/xenstore-read not found!"
exit 1
fi
if xenstore-read qubes_save_request ; then
dmesg -c >/dev/null
# echo 1 >/proc/sys/vm/drop_caches
# free | grep buffers/cache |
# (read a b c d ; xenstore-write device/qubes_used_mem $c)
free | grep Mem: |
(read a b c d ; xenstore-write device/qubes_used_mem $c)
echo "Waiting for restore"
while ! dmesg -c | grep "using vcpu" ; do usleep 10 ; done
while ! xenstore-read qubes_vm_type 2>/dev/null ; do
usleep 10
done
echo Back to life.
fi
name=$(/usr/bin/xenstore-read name)
hostname $name
@ -29,6 +43,9 @@ start()
echo "nameserver $secondary_dns" >> /etc/resolv.conf
fi
if [ -e /dev/xvdb ] ; then
mount /rw
if ! [ -d /rw/home ] ; then
echo
echo "--> Virgin boot of the VM: Linking /home to /rw/home"
@ -54,6 +71,9 @@ start()
if ! [ -d /rw/usrlocal ] ; then
cp -a /usr/local.orig /rw/usrlocal
fi
else
ln -sf /home_volatile /home
fi
[ -x /rw/config/rc.local ] && /rw/config/rc.local
success

2
appvm/qubes_timestamp Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exec xenstore-write device/qubes_timestamp $(date +%s.%N)

View File

@ -60,7 +60,7 @@ mkdir -p $RPM_BUILD_ROOT/etc/init.d
cp qubes_core $RPM_BUILD_ROOT/etc/init.d/
mkdir -p $RPM_BUILD_ROOT/var/lib/qubes
mkdir -p $RPM_BUILD_ROOT/usr/bin
cp qubes_add_pendrive_script qubes_penctl qvm-copy-to-vm qvm-copy-to-vm.kde $RPM_BUILD_ROOT/usr/bin
cp qubes_timestamp qubes_add_pendrive_script qubes_penctl qvm-copy-to-vm qvm-copy-to-vm.kde $RPM_BUILD_ROOT/usr/bin
mkdir -p $RPM_BUILD_ROOT/%{kde_service_dir}
cp qvm-copy.desktop $RPM_BUILD_ROOT/%{kde_service_dir}
mkdir -p $RPM_BUILD_ROOT/etc/udev/rules.d
@ -77,6 +77,9 @@ cp ../common/qubes_serial_login $RPM_BUILD_ROOT/sbin
mkdir -p $RPM_BUILD_ROOT/etc
cp ../common/serial.conf $RPM_BUILD_ROOT/var/lib/qubes/
mkdir -p $RPM_BUILD_ROOT/home_volatile/user
chown 500:500 $RPM_BUILD_ROOT/home_volatile/user
%triggerin -- initscripts
cp /var/lib/qubes/serial.conf /etc/init/serial.conf
@ -186,3 +189,6 @@ rm -rf $RPM_BUILD_ROOT
%dir /mnt/removable
/etc/yum.repos.d/qubes.repo
/sbin/qubes_serial_login
/usr/bin/qubes_timestamp
%dir /home_volatile
%attr(700,user,user) /home_volatile/user