]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
if after freezing the container the snapshot/rsync fails, unfreeze before exiting
authorInformatiQ <rhanna@informatiq.org>
Tue, 30 Aug 2011 22:20:09 +0000 (00:20 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 30 Aug 2011 22:20:09 +0000 (00:20 +0200)
Signed-off-by: InformatiQ <rhanna@informatiq.org>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
src/lxc/lxc-clone.in

index e52082d4dab2e8baf776d5129ae4fff1b399781a..657486dea51c0e938b995b70d482842f0c9eb95a 100644 (file)
@@ -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