From 4aab477f384c67424bdef25d0ec25d46bacd0471 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Thu, 12 Jul 2012 14:21:59 +0200 Subject: [PATCH] dom0/dispvm: by default use prerun script from inside of VM (#620) --- dom0/qvm-core/qubes.py | 6 ------ dom0/restore/qubes_prepare_saved_domain.sh | 8 ++++++-- dom0/restore/qvm-create-default-dvm | 8 ++------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 7e0fffd1..ba7b9747 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -1634,12 +1634,6 @@ class QubesTemplateVm(QubesVm): raise IOError ("Error while copying {0} to {1}".\ format(self.clean_img, self.volatile_img)) - if verbose: - print >> sys.stderr, "--> Copying the template's DispVM prerun script..." - retcode = subprocess.call (["cp", src_vm.dir_path + '/dispvm-prerun.sh', self.dir_path + '/dispvm-prerun.sh']) - if retcode != 0: - raise IOError ("Error while copying DispVM prerun script") - # Create root-cow.img self.commit_changes(verbose=verbose) diff --git a/dom0/restore/qubes_prepare_saved_domain.sh b/dom0/restore/qubes_prepare_saved_domain.sh index 0d89932d..f06bf998 100755 --- a/dom0/restore/qubes_prepare_saved_domain.sh +++ b/dom0/restore/qubes_prepare_saved_domain.sh @@ -1,11 +1,15 @@ #!/bin/bash get_encoded_script() { - if ! [ -f "$1" ] ; then + if [ "$1" == "vm-default" ]; then + SCRIPT_CMD="echo /usr/lib/qubes/dispvm-prerun.sh" + elif ! [ -f "$1" ] ; then echo $1 is not a file ? exit 1 + else + SCRIPT_CMD="cat $1" fi - ENCODED_SCRIPT=`cat "$1" | perl -e 'use MIME::Base64 qw(encode_base64); local($/) = undef;print encode_base64()'|tr -d "\n"` + ENCODED_SCRIPT=`$SCRIPT_CMD | perl -e 'use MIME::Base64 qw(encode_base64); local($/) = undef;print encode_base64()'|tr -d "\n"` } if [ $# != 2 -a $# != 3 ] ; then diff --git a/dom0/restore/qvm-create-default-dvm b/dom0/restore/qvm-create-default-dvm index 3240ebd1..d8c93821 100755 --- a/dom0/restore/qvm-create-default-dvm +++ b/dom0/restore/qvm-create-default-dvm @@ -21,13 +21,9 @@ if [ "$TEMPLATENAME" = --default-template ] ; then 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 + SCRIPTNAME="vm-default" else - SCRIPTNAME=$2 + SCRIPTNAME=$2 fi if ! [ -d "/var/lib/qubes/vm-templates/$TEMPLATENAME" ] ; then