DVM: manage savefiles
Instead of hardcoded savefile name, use a symlink in /var/run/qubes. Tools should set this symlink to a correct savefile. Also, test whether the savefile is older than the template root.img.
This commit is contained in:
parent
6ee594f972
commit
0c0f34ba9b
@ -16,7 +16,27 @@
|
|||||||
# Source function library.
|
# Source function library.
|
||||||
. /etc/rc.d/init.d/functions
|
. /etc/rc.d/init.d/functions
|
||||||
|
|
||||||
|
setup_dvm_files()
|
||||||
|
{
|
||||||
|
ROOT=/var/lib/qubes/dvmdata/savefile_root
|
||||||
|
DEFAULT=/var/lib/qubes/dvmdata/default_savefile
|
||||||
|
if ! [ -f $DEFAULT ] ; then return ; fi
|
||||||
|
if ! [ -f $ROOT ] ; then return ; fi
|
||||||
|
if [ $ROOT -nt $DEFAULT ] ; then
|
||||||
|
echo DVM require reconfiguration
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [ -f /var/lib/qubes/dvmdata/dont_use_shm ] ; then
|
||||||
|
ln -s $DEFAULT /var/run/qubes/current_savefile
|
||||||
|
else
|
||||||
|
mkdir -m 770 /dev/shm/qubes
|
||||||
|
chown root.qubes /dev/shm/qubes
|
||||||
|
cp $DEFAULT /dev/shm/qubes/current_savefile
|
||||||
|
chown root.qubes /dev/shm/qubes/current_savefile
|
||||||
|
chmod 660 /dev/shm/qubes/current_savefile
|
||||||
|
ln -s /dev/shm/qubes/current_savefile /var/run/qubes/current_savefile
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
@ -35,6 +55,7 @@ start()
|
|||||||
chmod 660 /var/run/qubes/dispVM_seq
|
chmod 660 /var/run/qubes/dispVM_seq
|
||||||
xm mem-set 0 800
|
xm mem-set 0 800
|
||||||
cp /var/lib/qubes/qubes.xml /var/lib/qubes/backup/qubes-$(date +%F-%T).xml
|
cp /var/lib/qubes/qubes.xml /var/lib/qubes/backup/qubes-$(date +%F-%T).xml
|
||||||
|
setup_dvm_files
|
||||||
touch /var/lock/subsys/qubes_core
|
touch /var/lock/subsys/qubes_core
|
||||||
success
|
success
|
||||||
echo
|
echo
|
||||||
|
@ -34,6 +34,7 @@ from qubes.qubes import QubesDaemonPidfile
|
|||||||
filename_seq = 50
|
filename_seq = 50
|
||||||
pen_cmd = '/usr/lib/qubes/qubes_pencmd'
|
pen_cmd = '/usr/lib/qubes/qubes_pencmd'
|
||||||
disposable_domains_dict = {}
|
disposable_domains_dict = {}
|
||||||
|
current_savefile = '/var/run/qubes/current_savefile'
|
||||||
|
|
||||||
def get_next_filename_seq():
|
def get_next_filename_seq():
|
||||||
global filename_seq
|
global filename_seq
|
||||||
@ -196,7 +197,7 @@ class DomainState:
|
|||||||
qvm_collection.unlock_db()
|
qvm_collection.unlock_db()
|
||||||
return False
|
return False
|
||||||
retcode = subprocess.call(['/usr/bin/qubes_restore',
|
retcode = subprocess.call(['/usr/bin/qubes_restore',
|
||||||
'/dev/shm/qubes/disposable_savefile',
|
current_savefile,
|
||||||
'-c', vm.label.color,
|
'-c', vm.label.color,
|
||||||
'-i', vm.label.icon,
|
'-i', vm.label.icon,
|
||||||
'-l', str(vm.label.index)])
|
'-l', str(vm.label.index)])
|
||||||
@ -230,8 +231,20 @@ class DomainState:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def handle_transfer(self, vmname, transaction_seq):
|
def handle_transfer(self, vmname, transaction_seq):
|
||||||
|
dvmdata_dir = '/var/lib/qubes/dvmdata/'
|
||||||
if vmname != 'disposable':
|
if vmname != 'disposable':
|
||||||
return self.handle_transfer_regular(vmname, transaction_seq)
|
return self.handle_transfer_regular(vmname, transaction_seq)
|
||||||
|
if not os.path.isfile(current_savefile):
|
||||||
|
subprocess.call(['/usr/bin/kdialog', '--sorry', 'There is no current savefile defined; run Qubes Manager'])
|
||||||
|
return False
|
||||||
|
if not os.path.isfile(dvmdata_dir+'default_savefile') or not os.path.isfile(dvmdata_dir+'savefile_root'):
|
||||||
|
subprocess.call(['/usr/bin/kdialog', '--sorry', 'Default savefile misconfiguration; run Qubes Manager'])
|
||||||
|
return False
|
||||||
|
dvm_mtime = os.stat(current_savefile).st_mtime
|
||||||
|
root_mtime = os.stat(dvmdata_dir+'savefile_root').st_mtime
|
||||||
|
if dvm_mtime < root_mtime:
|
||||||
|
subprocess.call(['/usr/bin/kdialog', '--sorry', 'Your current savefile is outdated, as you have updated the template VM. Run Qubes Manager and recreate the savefile'])
|
||||||
|
return False
|
||||||
return self.handle_transfer_disposable(transaction_seq)
|
return self.handle_transfer_disposable(transaction_seq)
|
||||||
|
|
||||||
class XS_Watcher:
|
class XS_Watcher:
|
||||||
|
@ -86,6 +86,7 @@ mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/vm-templates
|
|||||||
mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/appvms
|
mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/appvms
|
||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/backup
|
mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/backup
|
||||||
|
mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/dvmdata
|
||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT/usr/share/qubes/icons
|
mkdir -p $RPM_BUILD_ROOT/usr/share/qubes/icons
|
||||||
cp icons/*.png $RPM_BUILD_ROOT/usr/share/qubes/icons
|
cp icons/*.png $RPM_BUILD_ROOT/usr/share/qubes/icons
|
||||||
@ -205,6 +206,7 @@ fi
|
|||||||
%attr(770,root,qubes) %dir /var/lib/qubes/vm-templates
|
%attr(770,root,qubes) %dir /var/lib/qubes/vm-templates
|
||||||
%attr(770,root,qubes) %dir /var/lib/qubes/appvms
|
%attr(770,root,qubes) %dir /var/lib/qubes/appvms
|
||||||
%attr(770,root,qubes) %dir /var/lib/qubes/backup
|
%attr(770,root,qubes) %dir /var/lib/qubes/backup
|
||||||
|
%attr(770,root,qubes) %dir /var/lib/qubes/dvmdata
|
||||||
%dir /usr/share/qubes/icons/*.png
|
%dir /usr/share/qubes/icons/*.png
|
||||||
/etc/yum.repos.d/qubes.repo
|
/etc/yum.repos.d/qubes.repo
|
||||||
/usr/bin/qubes_setup_dnat_to_ns
|
/usr/bin/qubes_setup_dnat_to_ns
|
||||||
|
Loading…
Reference in New Issue
Block a user