Merge branch 'master' of git://git.qubes-os.org/marmarek/core
This commit is contained in:
		
						commit
						6ec0a4a2f4
					
				
							
								
								
									
										36
									
								
								dom0/aux-tools/prepare_volatile_img.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										36
									
								
								dom0/aux-tools/prepare_volatile_img.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,36 @@ | |||||||
|  | #!/bin/sh | ||||||
|  | 
 | ||||||
|  | if [ "`id -u`" != "0" ]; then | ||||||
|  | 	exec sudo $0 $* | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | set -e | ||||||
|  | 
 | ||||||
|  | FILENAME=$1 | ||||||
|  | ROOT_SIZE=$2 | ||||||
|  | SWAP_SIZE=$[ 1024 ] | ||||||
|  | 
 | ||||||
|  | if [ -z "$ROOT_SIZE" -o -z "$FILENAME" ]; then | ||||||
|  | 	echo "Usage: $0 <filename> <root.img size in MB>" | ||||||
|  | 	exit 1 | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | if [ -e "$FILENAME" ]; then | ||||||
|  | 	echo "$FILENAME already exists, not overriding" | ||||||
|  | 	exit 1 | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | TOTAL_SIZE=$[ $ROOT_SIZE + $SWAP_SIZE + 512 ] | ||||||
|  | truncate -s ${TOTAL_SIZE}M "$FILENAME" | ||||||
|  | sfdisk --no-reread -u M "$FILENAME" > /dev/null 2> /dev/null <<EOF | ||||||
|  | 0,${SWAP_SIZE},S | ||||||
|  | ,${ROOT_SIZE},L | ||||||
|  | EOF | ||||||
|  | 
 | ||||||
|  | kpartx -s -a "$FILENAME" | ||||||
|  | loopdev=`losetup -j "$FILENAME"|tail -n 1 |cut -d: -f1` | ||||||
|  | looppart=`echo $loopdev|sed 's:dev:dev/mapper:'` | ||||||
|  | mkswap -f ${looppart}p1 > /dev/null | ||||||
|  | kpartx -s -d ${loopdev} | ||||||
|  | losetup -d ${loopdev} || : | ||||||
|  | chown --reference `dirname "$FILENAME"` "$FILENAME" | ||||||
| @ -106,6 +106,7 @@ dom0_vm = None | |||||||
| qubes_appmenu_create_cmd = "/usr/lib/qubes/create_apps_for_appvm.sh" | qubes_appmenu_create_cmd = "/usr/lib/qubes/create_apps_for_appvm.sh" | ||||||
| qubes_appmenu_remove_cmd = "/usr/lib/qubes/remove_appvm_appmenus.sh" | qubes_appmenu_remove_cmd = "/usr/lib/qubes/remove_appvm_appmenus.sh" | ||||||
| qubes_pciback_cmd = '/usr/lib/qubes/unbind_pci_device.sh' | qubes_pciback_cmd = '/usr/lib/qubes/unbind_pci_device.sh' | ||||||
|  | prepare_volatile_img_cmd = '/usr/lib/qubes/prepare_volatile_img.sh' | ||||||
| 
 | 
 | ||||||
| yum_proxy_ip = '10.137.255.254' | yum_proxy_ip = '10.137.255.254' | ||||||
| yum_proxy_port = '8082' | yum_proxy_port = '8082' | ||||||
| @ -1238,6 +1239,15 @@ class QubesVm(object): | |||||||
| 
 | 
 | ||||||
|         # Only makes sense on template based VM |         # Only makes sense on template based VM | ||||||
|         if source_template is None: |         if source_template is None: | ||||||
|  |             # For StandaloneVM create it only if not already exists (eg after backup-restore) | ||||||
|  |             if not os.path.exists(self.volatile_img): | ||||||
|  |                 if verbose: | ||||||
|  |                     print >> sys.stderr, "--> Creating volatile image: {0}...".format (self.volatile_img) | ||||||
|  |                 f_root = open (self.root_img, "r") | ||||||
|  |                 f_root.seek(0, os.SEEK_END) | ||||||
|  |                 root_size = f_root.tell() | ||||||
|  |                 f_root.close() | ||||||
|  |                 subprocess.check_call([prepare_volatile_img_cmd, self.volatile_img, str(root_size / 1024 / 1024)]) | ||||||
|             return |             return | ||||||
| 
 | 
 | ||||||
|         if verbose: |         if verbose: | ||||||
| @ -1400,7 +1410,7 @@ class QubesVm(object): | |||||||
|                     notify_function ("info", "Starting the '{0}' VM...".format(self.name)) |                     notify_function ("info", "Starting the '{0}' VM...".format(self.name)) | ||||||
|                 elif verbose: |                 elif verbose: | ||||||
|                     print >> sys.stderr, "Starting the VM '{0}'...".format(self.name) |                     print >> sys.stderr, "Starting the VM '{0}'...".format(self.name) | ||||||
|                 xid = self.start(verbose=verbose, notify_function=notify_function) |                 xid = self.start(verbose=verbose, start_guid = gui, notify_function=notify_function) | ||||||
| 
 | 
 | ||||||
|             except (IOError, OSError, QubesException) as err: |             except (IOError, OSError, QubesException) as err: | ||||||
|                 raise QubesException("Error while starting the '{0}' VM: {1}".format(self.name, err)) |                 raise QubesException("Error while starting the '{0}' VM: {1}".format(self.name, err)) | ||||||
|  | |||||||
| @ -1364,5 +1364,8 @@ def backup_restore_do(backup_dir, restore_info, host_collection = None, print_ca | |||||||
|             retcode = subprocess.call (["cp", "-nrp", backup_dom0_home_dir + '/' + f, home_file]) |             retcode = subprocess.call (["cp", "-nrp", backup_dom0_home_dir + '/' + f, home_file]) | ||||||
|             if retcode != 0: |             if retcode != 0: | ||||||
|                 error_callback("*** Error while copying file {0} to {1}".format(backup_dom0_home_dir + '/' + f, home_file)) |                 error_callback("*** Error while copying file {0} to {1}".format(backup_dom0_home_dir + '/' + f, home_file)) | ||||||
|  |         retcode = subprocess.call(['sudo', 'chown', '-R', local_user, home_dir]) | ||||||
|  |         if retcode != 0: | ||||||
|  |             error_callback("*** Error while setting home directory owner") | ||||||
| 
 | 
 | ||||||
| # vim:sw=4:et: | # vim:sw=4:et: | ||||||
|  | |||||||
| @ -26,6 +26,7 @@ YUM_OPTS= | |||||||
| GUI= | GUI= | ||||||
| CHECK_ONLY= | CHECK_ONLY= | ||||||
| ALL_OPTS=$* | ALL_OPTS=$* | ||||||
|  | QVMRUN_OPTS= | ||||||
| # Filter out some yum options and collect packages list | # Filter out some yum options and collect packages list | ||||||
| while [ $# -gt 0 ]; do | while [ $# -gt 0 ]; do | ||||||
|     case "$1" in |     case "$1" in | ||||||
| @ -60,6 +61,10 @@ if [ "$GUI" == "1" -a -n "$PKGS" ]; then | |||||||
|     exit 1 |     exit 1 | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
|  | if [ "$GUI" != "1" ]; then | ||||||
|  |     QVMRUN_OPTS=--nogui | ||||||
|  | fi | ||||||
|  | 
 | ||||||
| # Do not start VM automaticaly when running from cron (only checking for updates) | # Do not start VM automaticaly when running from cron (only checking for updates) | ||||||
| if [ "$CHECK_ONLY" == "1" ] && ! xl domid $UPDATEVM > /dev/null 2>&1; then | if [ "$CHECK_ONLY" == "1" ] && ! xl domid $UPDATEVM > /dev/null 2>&1; then | ||||||
|     echo "ERROR: UpdateVM not running, not starting it in non-interactive mode" >&2 |     echo "ERROR: UpdateVM not running, not starting it in non-interactive mode" >&2 | ||||||
| @ -73,11 +78,11 @@ qvm-sync-clock | |||||||
| echo "Checking for dom0 updates" >&2 | echo "Checking for dom0 updates" >&2 | ||||||
| 
 | 
 | ||||||
| # Start VM if not running already | # Start VM if not running already | ||||||
| qvm-run -a $UPDATEVM true || exit 1 | qvm-run $QVMRUN_OPTS -a $UPDATEVM true || exit 1 | ||||||
| 
 | 
 | ||||||
| /usr/lib/qubes/qrexec_client -d "$UPDATEVM" -l 'tar c /var/lib/rpm /etc/yum.repos.d /etc/yum.conf 2>/dev/null' 'user:tar x -C /var/lib/qubes/dom0-updates' 2> /dev/null | /usr/lib/qubes/qrexec_client -d "$UPDATEVM" -l 'tar c /var/lib/rpm /etc/yum.repos.d /etc/yum.conf 2>/dev/null' 'user:tar x -C /var/lib/qubes/dom0-updates' 2> /dev/null | ||||||
| 
 | 
 | ||||||
| qvm-run --pass-io $UPDATEVM "/usr/lib/qubes/qubes_download_dom0_updates.sh --doit --nogui $ALL_OPTS" | qvm-run $QVMRUN_OPTS --pass-io $UPDATEVM "/usr/lib/qubes/qubes_download_dom0_updates.sh --doit --nogui $ALL_OPTS" | ||||||
| RETCODE=$? | RETCODE=$? | ||||||
| if [ "$CHECK_ONLY" == "1" ]; then | if [ "$CHECK_ONLY" == "1" ]; then | ||||||
|     exit $RETCODE |     exit $RETCODE | ||||||
|  | |||||||
| @ -145,6 +145,7 @@ cp aux-tools/remove_appvm_appmenus.sh $RPM_BUILD_ROOT/usr/lib/qubes | |||||||
| cp aux-tools/cleanup_dispvms $RPM_BUILD_ROOT/usr/lib/qubes | cp aux-tools/cleanup_dispvms $RPM_BUILD_ROOT/usr/lib/qubes | ||||||
| cp aux-tools/startup-dvm.sh $RPM_BUILD_ROOT/usr/lib/qubes | cp aux-tools/startup-dvm.sh $RPM_BUILD_ROOT/usr/lib/qubes | ||||||
| cp aux-tools/startup-misc.sh $RPM_BUILD_ROOT/usr/lib/qubes | cp aux-tools/startup-misc.sh $RPM_BUILD_ROOT/usr/lib/qubes | ||||||
|  | cp aux-tools/prepare_volatile_img.sh $RPM_BUILD_ROOT/usr/lib/qubes | ||||||
| cp qmemman/server.py $RPM_BUILD_ROOT/usr/lib/qubes/qmemman_daemon.py | cp qmemman/server.py $RPM_BUILD_ROOT/usr/lib/qubes/qmemman_daemon.py | ||||||
| cp ../misc/meminfo-writer $RPM_BUILD_ROOT/usr/lib/qubes/ | cp ../misc/meminfo-writer $RPM_BUILD_ROOT/usr/lib/qubes/ | ||||||
| cp ../qrexec/qrexec_daemon $RPM_BUILD_ROOT/usr/lib/qubes/ | cp ../qrexec/qrexec_daemon $RPM_BUILD_ROOT/usr/lib/qubes/ | ||||||
| @ -440,6 +441,7 @@ fi | |||||||
| /usr/lib/qubes/fix_dir_perms.sh | /usr/lib/qubes/fix_dir_perms.sh | ||||||
| /usr/lib/qubes/startup-dvm.sh | /usr/lib/qubes/startup-dvm.sh | ||||||
| /usr/lib/qubes/startup-misc.sh | /usr/lib/qubes/startup-misc.sh | ||||||
|  | /usr/lib/qubes/prepare_volatile_img.sh | ||||||
| %attr(4750,root,qubes) /usr/lib/qubes/qfile-dom0-unpacker | %attr(4750,root,qubes) /usr/lib/qubes/qfile-dom0-unpacker | ||||||
| %if %{use_systemd} | %if %{use_systemd} | ||||||
| %{_unitdir}/qubes-block-cleaner.service | %{_unitdir}/qubes-block-cleaner.service | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Joanna Rutkowska
						Joanna Rutkowska