 e5df78fe92
			
		
	
	
		e5df78fe92
		
	
	
	
	
		
			
			Detailed changes: - use domain config in separate file (not embeded in savefile) - DispVM domain config generated from dvm.conf (introduced by previous patches) by qubes_restore - use call 'xl restore' to restore domain (instead of command to xend) - additional parameter to qubes_restore - config template - minor changes (xenstore perms, block-detach without /dev/ prefix, etc)
		
			
				
	
	
		
			70 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/sh
 | |
| if [ $# != 1 -a $# != 2 ] ; then
 | |
| 	echo 'Usage: qvm-create-default-dvm templatename|--default-template [script-name|--default-script]'
 | |
| 	exit 1
 | |
| fi
 | |
| if [ "$1" = --default-template ] ; then
 | |
| 	TEMPLATENAME=$(qvm-get-default-template)
 | |
| 	if [ "X"$TEMPLATENAME = "X" ] ; then
 | |
| 		echo No default template ?
 | |
| 		exit 1
 | |
| 	fi
 | |
| else
 | |
| 	TEMPLATENAME=$1
 | |
| fi
 | |
| 
 | |
| if [ "X""$2" = "X""--default-script" ] ; then
 | |
| 	SCRIPTNAME="/var/lib/qubes/vm-templates/$TEMPLATENAME"/dispvm-prerun.sh
 | |
| 	if ! [ -f $SCRIPTNAME ] ; then
 | |
| 		echo $SCRIPTNAME does not exist
 | |
| 		exit 1
 | |
| 	fi
 | |
| else
 | |
| 		SCRIPTNAME=$2
 | |
| fi
 | |
| 
 | |
| if ! [ -d "/var/lib/qubes/vm-templates/$TEMPLATENAME" ] ; then
 | |
| 	echo /var/lib/qubes/vm-templates/$TEMPLATENAME is not a directory
 | |
| 	exit 1
 | |
| fi
 | |
| DVMTMPL="$TEMPLATENAME"-dvm
 | |
| DVMTMPLDIR="/var/lib/qubes/appvms/$DVMTMPL"
 | |
| if ! [ -d "$DVMTMPLDIR" ] ; then
 | |
| 	# unfortunately, currently there are reliability issues with save of a domain
 | |
| 	# with multiple CPUs
 | |
| 	if ! qvm-create --force-root --vcpus=1 --internal -t "$TEMPLATENAME" -l gray "$DVMTMPL" ; then exit 1 ; fi
 | |
| fi
 | |
| if ! /usr/lib/qubes/qubes_prepare_saved_domain.sh \
 | |
| 	"$DVMTMPL" "/var/lib/qubes/appvms/$DVMTMPL/dvm-savefile" $SCRIPTNAME ; then
 | |
| 	exit 1
 | |
| fi
 | |
| ROOT=/var/lib/qubes/dvmdata/savefile_root
 | |
| DEFAULT=/var/lib/qubes/dvmdata/default_savefile
 | |
| DEFAULTCONF=/var/lib/qubes/dvmdata/default_dvm.conf
 | |
| CURRENT=/var/run/qubes/current_savefile
 | |
| CURRENTCONF=/var/run/qubes/current_dvm.conf
 | |
| SHMDIR=/dev/shm/qubes
 | |
| SHMCOPY=$SHMDIR/current_savefile
 | |
| rm -f $ROOT $DEFAULT $CURRENT $DEFAULTCONF $CURRENTCONF
 | |
| ln -s "/var/lib/qubes/appvms/$DVMTMPL/dvm-savefile" $DEFAULT
 | |
| ln -s "/var/lib/qubes/vm-templates/$TEMPLATENAME/root.img" $ROOT
 | |
| ln -s $DVMTMPLDIR/dvm.conf $DEFAULTCONF
 | |
| ln -s $DVMTMPLDIR/dvm.conf $CURRENTCONF
 | |
| if [ -f /var/lib/qubes/dvmdata/dont_use_shm ] ; then
 | |
|             ln -s $DEFAULT $CURRENT
 | |
| else
 | |
| 	mkdir -m 770 $SHMDIR 2>/dev/null
 | |
| 	chgrp qubes $SHMDIR 2>/dev/null
 | |
| 	cp $DEFAULT $SHMCOPY || exit 1
 | |
| 	chgrp qubes $SHMCOPY
 | |
| 	chmod 660 $SHMCOPY
 | |
| 	ln -s $SHMCOPY $CURRENT
 | |
| fi 
 | |
| 
 | |
| if [ $(whoami) = "root" ] ; then
 | |
| 	chgrp qubes "$DVMTMPLDIR" "$DVMTMPLDIR"/*
 | |
| 	chmod 660 "$DVMTMPLDIR"/*
 | |
| 	chmod 770 "$DVMTMPLDIR"
 | |
| fi
 | |
| 
 |