qubes_dvm init.d script

We want to set up a default dvm if needed at boot time; for this,
the default netvm must have been already started. Therefore, we
need a qubes_dvm script, that executes after qubes_netvm.
This commit is contained in:
Rafal Wojtczuk 2010-09-21 21:46:11 +02:00
parent c22a6ebb84
commit e13e5027c3
3 changed files with 83 additions and 26 deletions

View File

@ -16,27 +16,6 @@
# 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()
{ {
@ -50,14 +29,10 @@ start()
chgrp qubes /var/run/xenstored/* chgrp qubes /var/run/xenstored/*
chmod 660 /var/run/xenstored/* chmod 660 /var/run/xenstored/*
xm sched-credit -d 0 -w 65535 xm sched-credit -d 0 -w 65535
printf "\x00\x00\x00\x00" > /var/run/qubes/dispVM_seq
chown root:qubes /var/run/qubes/dispVM_seq
chmod 660 /var/run/qubes/dispVM_seq
xm mem-set 0 1600 xm mem-set 0 1600
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
/usr/lib/qubes/qmemman_daemon.py >/var/log/qubes/qmemman.log 2>/var/log/qubes/qmemman.errs &
/usr/lib/qubes/qmemman_daemon.py >/var/log/qubes/qmemman.log 2>/var/log/qubes/qmemman.errs &
MEM_CHANGE_THRESHOLD_KB=30000 MEM_CHANGE_THRESHOLD_KB=30000
MEMINFO_DELAY_USEC=100000 MEMINFO_DELAY_USEC=100000
/usr/lib/qubes/meminfo-writer $MEM_CHANGE_THRESHOLD_KB $MEMINFO_DELAY_USEC & /usr/lib/qubes/meminfo-writer $MEM_CHANGE_THRESHOLD_KB $MEMINFO_DELAY_USEC &

78
dom0/init.d/qubes_dvm Executable file
View File

@ -0,0 +1,78 @@
#!/bin/sh
#
# chkconfig: 2345 99 00
# description: Sets up DVM savefile at Dom0 boot
#
### BEGIN INIT INFO
# Provides: qubes-dvm
# Required-Start: qubes-networking
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Default-Enabled: yes
# Short-Description: Sets up DVM savefile at Dom0 boot
# Description: Sets up DVM savefile at Dom0 boot
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
setup_dvm_files()
{
}
start()
{
echo -n "Setting up DVM savefile at Dom0 boot:"
printf "\x00\x00\x00\x00" > /var/run/qubes/dispVM_seq
chown root:qubes /var/run/qubes/dispVM_seq
chmod 660 /var/run/qubes/dispVM_seq
ROOT=/var/lib/qubes/dvmdata/savefile_root
DEFAULT=/var/lib/qubes/dvmdata/default_savefile
create_neeed=0
if ! [ -f $DEFAULT ] ; then create_neeed=1 ; fi
if ! [ -f $ROOT ] ; then create_neeed=1 ; fi
if [ $ROOT -nt $DEFAULT ] ; then create_neeed=1 ; fi
if [ $create_neeed = 1 ] ; then
echo Creating the default DVM. This may take up to 2 minutes...
qvm-create-default-dvm --default-template --default-script
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
touch /var/lock/subsys/qubes_dvm
success
echo
}
stop()
{
rm -f /var/lock/subsys/qubes_netvm
success
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo $"Usage: $0 {start|stop}"
exit 3
;;
esac
exit $RETVAL

View File

@ -54,6 +54,7 @@ make -C ../common
mkdir -p $RPM_BUILD_ROOT/etc/init.d mkdir -p $RPM_BUILD_ROOT/etc/init.d
cp init.d/qubes_core $RPM_BUILD_ROOT/etc/init.d/ cp init.d/qubes_core $RPM_BUILD_ROOT/etc/init.d/
cp init.d/qubes_netvm $RPM_BUILD_ROOT/etc/init.d/ cp init.d/qubes_netvm $RPM_BUILD_ROOT/etc/init.d/
cp init.d/qubes_dvm $RPM_BUILD_ROOT/etc/init.d/
mkdir -p $RPM_BUILD_ROOT/usr/bin/ mkdir -p $RPM_BUILD_ROOT/usr/bin/
cp qvm-tools/qvm-* $RPM_BUILD_ROOT/usr/bin cp qvm-tools/qvm-* $RPM_BUILD_ROOT/usr/bin
@ -155,9 +156,11 @@ sed 's/^net.ipv4.ip_forward.*/net.ipv4.ip_forward = 1/' -i /etc/sysctl.conf
chkconfig --add qubes_core || echo "WARNING: Cannot add service qubes_core!" chkconfig --add qubes_core || echo "WARNING: Cannot add service qubes_core!"
chkconfig --add qubes_netvm || echo "WARNING: Cannot add service qubes_netvm!" chkconfig --add qubes_netvm || echo "WARNING: Cannot add service qubes_netvm!"
chkconfig --add qubes_dvm || echo "WARNING: Cannot add service qubes_dvm!"
chkconfig qubes_core on || echo "WARNING: Cannot enable service qubes_core!" chkconfig qubes_core on || echo "WARNING: Cannot enable service qubes_core!"
chkconfig qubes_netvm on || echo "WARNING: Cannot enable service qubes_netvm!" chkconfig qubes_netvm on || echo "WARNING: Cannot enable service qubes_netvm!"
chkconfig qubes_dvm on || echo "WARNING: Cannot enable service qubes_dvm!"
if ! [ -e /var/lib/qubes/qubes.xml ]; then if ! [ -e /var/lib/qubes/qubes.xml ]; then
# echo "Initializing Qubes DB..." # echo "Initializing Qubes DB..."
@ -195,6 +198,7 @@ fi
%defattr(-,root,root,-) %defattr(-,root,root,-)
/etc/init.d/qubes_core /etc/init.d/qubes_core
/etc/init.d/qubes_netvm /etc/init.d/qubes_netvm
/etc/init.d/qubes_dvm
/usr/bin/qvm-* /usr/bin/qvm-*
/usr/bin/qclipd /usr/bin/qclipd
/usr/bin/qfilexchgd /usr/bin/qfilexchgd