DVM: execute user script before save
qubes_prepare_saved_domain.sh now takes optional second argument, the filename. The content of the file will be copied (via xenstore) to DVM and executed just before save. This makes it possible to preload memory with useful apps.
This commit is contained in:
parent
0c0f34ba9b
commit
11b8a0409f
@ -6,6 +6,18 @@
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
possibly_run_save_script()
|
||||
{
|
||||
ENCODED_SCRIPT=$(xenstore-read qubes_save_script)
|
||||
if [ -z "$ENCODED_SCRIPT" ] ; then return ; fi
|
||||
echo $ENCODED_SCRIPT|perl -e 'use MIME::Base64 qw(decode_base64); local($/) = undef;print decode_base64(<STDIN>)' >/tmp/qubes_save_script
|
||||
chmod 755 /tmp/qubes_save_script
|
||||
Xorg -config /etc/X11/xorg-preload-apps.conf :0 &
|
||||
sleep 2
|
||||
DISPLAY=:0 su - user -c /tmp/qubes_save_script
|
||||
killall Xorg
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
echo -n $"Executing Qubes Core scripts:"
|
||||
@ -14,7 +26,8 @@ start()
|
||||
echo "ERROR: /usr/bin/xenstore-read not found!"
|
||||
exit 1
|
||||
fi
|
||||
if xenstore-read qubes_save_request ; then
|
||||
if xenstore-read qubes_save_request 2>/dev/null ; then
|
||||
possibly_run_save_script
|
||||
touch /etc/this_is_dvm
|
||||
dmesg -c >/dev/null
|
||||
# echo 1 >/proc/sys/vm/drop_caches
|
||||
|
@ -1,9 +1,21 @@
|
||||
#!/bin/sh
|
||||
if ! [ $# = 2 ] ; then
|
||||
echo usage: $0 domainname savefile_to_be_created
|
||||
get_encoded_script()
|
||||
{
|
||||
if ! [ -f "$1" ] ; then
|
||||
echo $1 is not a file ?
|
||||
exit 1
|
||||
fi
|
||||
ENCODED_SCRIPT=`cat "$1" | perl -e 'use MIME::Base64 qw(encode_base64); local($/) = undef;print encode_base64(<STDIN>)'|tr -d "\n"`
|
||||
}
|
||||
|
||||
if [ $# != 2 -a $# != 3 ] ; then
|
||||
echo usage: $0 domainname savefile_to_be_created [preload script]
|
||||
exit 1
|
||||
fi
|
||||
export PATH=$PATH:/sbin:/usr/sbin
|
||||
if [ $# = 3 ] ; then
|
||||
get_encoded_script $3
|
||||
fi
|
||||
VMDIR=/var/lib/qubes/appvms/$1
|
||||
if ! [ -d $VMDIR ] ; then
|
||||
echo $VMDIR does not exist ?
|
||||
@ -20,12 +32,15 @@ for i in $(xenstore-list /local/domain) ; do
|
||||
ID=$i
|
||||
fi
|
||||
done
|
||||
set -x
|
||||
if [ $ID = none ] ; then
|
||||
echo cannot get domain id
|
||||
exit 1
|
||||
fi
|
||||
echo domainid=$ID
|
||||
if [ -n "$ENCODED_SCRIPT" ] ; then
|
||||
xenstore-write /local/domain/$ID/qubes_save_script "$ENCODED_SCRIPT"
|
||||
fi
|
||||
set -x
|
||||
xenstore-write /local/domain/$ID/qubes_save_request 1
|
||||
xenstore-watch /local/domain/$ID/device/qubes_used_mem
|
||||
xenstore-read /local/domain/$ID/qubes_gateway | \
|
||||
|
@ -81,6 +81,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/etc/X11
|
||||
cp xorg-preload-apps.conf $RPM_BUILD_ROOT/etc/X11
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/home_volatile/user
|
||||
chown 500:500 $RPM_BUILD_ROOT/home_volatile/user
|
||||
|
||||
@ -199,3 +202,4 @@ rm -rf $RPM_BUILD_ROOT
|
||||
/usr/bin/qubes_timestamp
|
||||
%dir /home_volatile
|
||||
%attr(700,user,user) /home_volatile/user
|
||||
/etc/X11/xorg-preload-apps.conf
|
||||
|
Loading…
Reference in New Issue
Block a user