aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInformatiQ <rhanna@informatiq.org>2011-08-31 00:20:09 +0200
committerDaniel Lezcano <dlezcano@fr.ibm.com>2011-08-31 00:20:09 +0200
commitac70c6cf97c5d52d4ec4c6bfe9552c1550307966 (patch)
tree69c762ef19815ddbc6931692bca5bf6057e3dbc7
parent*add the new opts to help() *set container_running=false (diff)
downloadlxc-ac70c6cf97c5d52d4ec4c6bfe9552c1550307966.tar.gz
lxc-ac70c6cf97c5d52d4ec4c6bfe9552c1550307966.tar.bz2
lxc-ac70c6cf97c5d52d4ec4c6bfe9552c1550307966.zip
if after freezing the container the snapshot/rsync fails, unfreeze before exiting
Signed-off-by: InformatiQ <rhanna@informatiq.org> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
-rw-r--r--src/lxc/lxc-clone.in14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lxc/lxc-clone.in b/src/lxc/lxc-clone.in
index e52082d..657486d 100644
--- a/src/lxc/lxc-clone.in
+++ b/src/lxc/lxc-clone.in
@@ -198,10 +198,15 @@ if [ -b $oldroot ]; then
if [ $container_running == "True" ]; then
lxc-freeze -n $lxc_orig
fi
- lvcreate -s -L $lxc_size -n ${lxc_lv_prefix}${lxc_new}_snapshot $oldroot || exit 1
+ lvcreate -s -L $lxc_size -n ${lxc_lv_prefix}${lxc_new}_snapshot $oldroot
+ RETVAL=$?
if [ $container_running == "True" ]; then
lxc-unfreeze -n $lxc_orig
fi
+ if [ $RETVAL -ne 0 ]; then
+ echo "snapshot creation failed"
+ exit 1
+ fi
if [ $snapshot == "no" ]; then
#mount snapshot
mkdir -p ${rootfs}_snapshot
@@ -231,10 +236,15 @@ else
if [ $container_running == True ];then
lxc-freeze -n $lxc_orig
fi
- rsync -ax $lxc_path/$lxc_orig/rootfs $lxc_path/$lxc_new/rootfs || return 1
+ rsync -ax $lxc_path/$lxc_orig/rootfs $lxc_path/$lxc_new/rootfs
+ RETVAL=$?
if [ $container_running == True ];then
lxc-unfreeze -n $lxc_orig
fi
+ if [ RETVAL -ne 0 ]; then
+ echo "copying rootfs failed"
+ exit 1
+ fi
echo "lxc.rootfs = $rootfs" >> $lxc_path/$lxc_new/config
fi