From aa894b5700938f499b77b325e968a83ae01d1aee Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Fri, 16 Jul 2010 11:19:03 +0200 Subject: [PATCH] qvm-create-default-dvm script --- dom0/restore/qvm-create-default-dvm | 35 +++++++++++++++++++++++++++++ rpm_spec/core-dom0.spec | 3 ++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100755 dom0/restore/qvm-create-default-dvm diff --git a/dom0/restore/qvm-create-default-dvm b/dom0/restore/qvm-create-default-dvm new file mode 100755 index 00000000..5750b63f --- /dev/null +++ b/dom0/restore/qvm-create-default-dvm @@ -0,0 +1,35 @@ +#!/bin/sh +if [ $# != 1 -a $# != 2 ] ; then + echo Usage: qvm-create-default-dvm templatename [script-name] + exit 1 +fi +if ! [ -d "/var/lib/qubes/vm-templates/$1" ] ; then + echo /var/lib/qubes/vm-templates/$1 is not a directory + exit 1 +fi +DVMTMPL="$1"-dvm +if ! [ -d "/var/lib/qubes/appvms/$DVMTMPL" ] ; then + if ! qvm-create -t "$1" -l red "$DVMTMPL" ; then exit 1 ; fi +fi +if ! /usr/lib/qubes/qubes_prepare_saved_domain.sh \ + "$DVMTMPL" "/var/lib/qubes/appvms/$DVMTMPL/dvm-savefile" $2 ; then + exit 1 +fi +ROOT=/var/lib/qubes/dvmdata/savefile_root +DEFAULT=/var/lib/qubes/dvmdata/default_savefile +CURRENT=/var/run/qubes/current_savefile +SHMDIR=/dev/shm/qubes +SHMCOPY=$SHMDIR/current_savefile +rm -f $ROOT $DEFAULT $CURRENT +ln -s "/var/lib/qubes/appvms/$DVMTMPL/dvm-savefile" $DEFAULT +ln -s "/var/lib/qubes/vm-templates/$1/root.img" $ROOT +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 diff --git a/rpm_spec/core-dom0.spec b/rpm_spec/core-dom0.spec index 8d0068ad..ef2d1ed5 100644 --- a/rpm_spec/core-dom0.spec +++ b/rpm_spec/core-dom0.spec @@ -78,7 +78,7 @@ cp aux-tools/create_apps_for_appvm.sh $RPM_BUILD_ROOT/usr/lib/qubes cp aux-tools/remove_appvm_appmenus.sh $RPM_BUILD_ROOT/usr/lib/qubes cp pendrive_swapper/qubes_pencmd $RPM_BUILD_ROOT/usr/lib/qubes -cp restore/xenstore-watch $RPM_BUILD_ROOT/usr/bin +cp restore/xenstore-watch restore/qvm-create-default-dvm $RPM_BUILD_ROOT/usr/bin cp restore/qubes_restore $RPM_BUILD_ROOT/usr/lib/qubes cp restore/qubes_prepare_saved_domain.sh $RPM_BUILD_ROOT/usr/lib/qubes @@ -217,6 +217,7 @@ fi /usr/lib64/pm-utils/sleep.d/01qubes-sync-vms-clock /usr/lib64/pm-utils/sleep.d/02qubes-pause-vms /usr/bin/xenstore-watch +/usr/bin/qvm-create-default-dvm /usr/lib/qubes/qubes_restore /usr/lib/qubes/qubes_prepare_saved_domain.sh /etc/xen/scripts/block.qubes