Hello community, here is the log from the commit of package virt-utils for openSUSE:Factory checked in at Sun Aug 7 19:03:18 CEST 2011. -------- --- virt-utils/virt-utils.changes 2011-02-21 12:10:06.000000000 +0100 +++ /mounts/work_src_done/STABLE/virt-utils/virt-utils.changes 2011-08-05 15:13:10.000000000 +0200 @@ -1,0 +2,12 @@ +Fri Jul 29 22:36:10 UTC 2011 - brogers@novell.com + +- update to qemu version 0.15.0-rc0 + +------------------------------------------------------------------- +Thu Jul 14 21:10:51 UTC 2011 - brogers@novell.com + +- update to latest qemu snapshot (git id: cf973e4) +- update vm-snapshot-disk script to support vhd disks and create + reflink snapshots of any disk image type on an ocfs2 volume. + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- qemu-0.14.0.tar.bz2 New: ---- qemu-0.15.0.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ virt-utils.spec ++++++ --- /var/tmp/diff_new_pack.Ni7mTj/_old 2011-08-07 19:02:50.000000000 +0200 +++ /var/tmp/diff_new_pack.Ni7mTj/_new 2011-08-07 19:02:50.000000000 +0200 @@ -23,12 +23,14 @@ Name: virt-utils BuildRequires: zlib-devel -Version: 1.1.5 +BuildRequires: glib2-devel +Version: 1.1.7 Release: 1 License: GPLv2 Group: System/Kernel Summary: Virtualization Utilities -Source0: qemu-0.14.0.tar.bz2 +# git commit id for following rc0 release: b8095f2 +Source0: qemu-0.15.0.tar.bz2 Source1: vm-snapshot-disk Patch1: qemu-img-vmdk-scsi.patch Url: http://www.qemu.org/ @@ -53,7 +55,7 @@ %prep %if %{?qemu_utils}0 -%setup -q -n qemu-0.14.0 +%setup -q -n qemu-0.15.0 %patch1 -p1 %endif ++++++ qemu-0.14.0.tar.bz2 -> qemu-0.15.0.tar.bz2 ++++++ ++++ 228968 lines of diff (skipped) ++++++ qemu-img-vmdk-scsi.patch ++++++ --- /var/tmp/diff_new_pack.Ni7mTj/_old 2011-08-07 19:02:53.000000000 +0200 +++ /var/tmp/diff_new_pack.Ni7mTj/_new 2011-08-07 19:02:53.000000000 +0200 @@ -13,20 +13,20 @@ qemu-img.c | 8 +++++++- 4 files changed, 18 insertions(+), 4 deletions(-) -Index: qemu-kvm-0.14.0/block.c +Index: qemu-0.15.0/block.c =================================================================== ---- qemu-kvm-0.14.0.orig/block.c -+++ qemu-kvm-0.14.0/block.c -@@ -2792,7 +2792,7 @@ int bdrv_img_create(const char *filename +--- qemu-0.15.0.orig/block.c ++++ qemu-0.15.0/block.c +@@ -2900,7 +2900,7 @@ int bdrv_img_create(const char *filename char *options, uint64_t img_size, int flags) { QEMUOptionParameter *param = NULL, *create_options = NULL; -- QEMUOptionParameter *backing_fmt, *backing_file; -+ QEMUOptionParameter *backing_fmt, *backing_file, *scsi; +- QEMUOptionParameter *backing_fmt, *backing_file, *size; ++ QEMUOptionParameter *backing_fmt, *backing_file, *size, *scsi; BlockDriverState *bs = NULL; BlockDriver *drv, *proto_drv; BlockDriver *backing_drv = NULL; -@@ -2901,6 +2901,9 @@ int bdrv_img_create(const char *filename +@@ -3010,6 +3010,9 @@ int bdrv_img_create(const char *filename printf("Formatting '%s', fmt=%s ", filename, fmt); print_option_parameters(param); @@ -36,41 +36,41 @@ puts(""); ret = bdrv_create(drv, filename, param); -Index: qemu-kvm-0.14.0/block/vmdk.c +Index: qemu-0.15.0/block/vmdk.c =================================================================== ---- qemu-kvm-0.14.0.orig/block/vmdk.c -+++ qemu-kvm-0.14.0/block/vmdk.c -@@ -685,7 +685,7 @@ static int vmdk_create(const char *filen +--- qemu-0.15.0.orig/block/vmdk.c ++++ qemu-0.15.0/block/vmdk.c +@@ -1134,7 +1134,7 @@ static int vmdk_create(const char *filen "ddb.geometry.cylinders = "%" PRId64 ""\n" "ddb.geometry.heads = "16"\n" "ddb.geometry.sectors = "63"\n" - "ddb.adapterType = "ide"\n"; + "ddb.adapterType = "%s"\n"; - char desc[1024]; - const char *real_filename, *temp_str; - int64_t total_size = 0; -@@ -701,6 +701,8 @@ static int vmdk_create(const char *filen - backing_file = options->value.s; - } else if (!strcmp(options->name, BLOCK_OPT_COMPAT6)) { - flags |= options->value.n ? BLOCK_FLAG_COMPAT6: 0; + + if (filename_decompose(filename, path, prefix, postfix, PATH_MAX)) { + return -EINVAL; +@@ -1149,6 +1149,8 @@ static int vmdk_create(const char *filen + flags |= options->value.n ? BLOCK_FLAG_COMPAT6 : 0; + } else if (!strcmp(options->name, BLOCK_OPT_SUBFMT)) { + fmt = options->value.s; + } else if (!strcmp(options->name, BLOCK_OPT_SCSI)) { + flags |= options->value.n ? BLOCK_FLAG_SCSI: 0; } options++; } -@@ -798,7 +800,8 @@ static int vmdk_create(const char *filen - snprintf(desc, sizeof(desc), desc_template, (unsigned int)time(NULL), - total_size, real_filename, - (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), -- total_size / (int64_t)(63 * 16)); -+ total_size / (int64_t)(63 * 16), -+ flags & BLOCK_FLAG_SCSI ? "lsilogic" : "ide"); - - /* write the descriptor */ - lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET); -@@ -844,6 +847,11 @@ static QEMUOptionParameter vmdk_create_o - .type = OPT_FLAG, - .help = "VMDK version 6 image" +@@ -1238,7 +1240,8 @@ static int vmdk_create(const char *filen + parent_desc_line, + ext_desc_lines, + (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), +- total_size / (int64_t)(63 * 16 * 512)); ++ total_size / (int64_t)(63 * 16 * 512), ++ flags & BLOCK_FLAG_SCSI ? "lsilogic" : "ide"); + if (split || flat) { + fd = open( + filename, +@@ -1336,6 +1339,11 @@ static QEMUOptionParameter vmdk_create_o + "VMDK flat extent format, can be one of " + "{monolithicSparse (default) | monolithicFlat | twoGbMaxExtentSparse | twoGbMaxExtentFlat} " }, + { + .name = BLOCK_OPT_SCSI, @@ -80,10 +80,10 @@ { NULL } }; -Index: qemu-kvm-0.14.0/block_int.h +Index: qemu-0.15.0/block_int.h =================================================================== ---- qemu-kvm-0.14.0.orig/block_int.h -+++ qemu-kvm-0.14.0/block_int.h +--- qemu-0.15.0.orig/block_int.h ++++ qemu-0.15.0/block_int.h @@ -30,10 +30,12 @@ #define BLOCK_FLAG_ENCRYPT 1 @@ -97,11 +97,11 @@ #define BLOCK_OPT_BACKING_FILE "backing_file" #define BLOCK_OPT_BACKING_FMT "backing_fmt" #define BLOCK_OPT_CLUSTER_SIZE "cluster_size" -Index: qemu-kvm-0.14.0/qemu-img.c +Index: qemu-0.15.0/qemu-img.c =================================================================== ---- qemu-kvm-0.14.0.orig/qemu-img.c -+++ qemu-kvm-0.14.0/qemu-img.c -@@ -576,7 +576,7 @@ static int img_convert(int argc, char ** +--- qemu-0.15.0.orig/qemu-img.c ++++ qemu-0.15.0/qemu-img.c +@@ -636,7 +636,7 @@ static int img_convert(int argc, char ** const uint8_t *buf1; BlockDriverInfo bdi; QEMUOptionParameter *param = NULL, *create_options = NULL; @@ -109,8 +109,8 @@ + QEMUOptionParameter *out_baseimg_param, *scsi; char *options = NULL; const char *snapshot_name = NULL; - -@@ -731,6 +731,12 @@ static int img_convert(int argc, char ** + float local_progress; +@@ -802,6 +802,12 @@ static int img_convert(int argc, char ** } } ++++++ vm-snapshot-disk ++++++ --- /var/tmp/diff_new_pack.Ni7mTj/_old 2011-08-07 19:02:53.000000000 +0200 +++ /var/tmp/diff_new_pack.Ni7mTj/_new 2011-08-07 19:02:53.000000000 +0200 @@ -2,8 +2,8 @@ #============================================================================ # vm-snapshot-disk # -# Version = 0.4.0 -# Date = 2010-02-12 +# Version = 0.6.0 +# Date = 2011-07-01 # # Copyright - Ron Terry # License - GPL @@ -15,7 +15,8 @@ # http://pronetworkconsulting.com/linux/scripts/virt-tools.html # # Description: -# This script creates and manages snapshots of qcow2 virtual disks. +# This script creates and manages snapshots of qcow2 and vhd virtual disks +# and virtual disks on file systems that support snapshots (i.e. OCFS2) # # Individual snapshots and snapshot trees are supported. The names # of the snapshots in the snapshot tree are stored in the actual @@ -45,9 +46,38 @@ if which qemu-img > /dev/null 2>&1 then QEMU_IMG_CMD=qemu-img + HAVE_QEMU_IMG=true elif which qemu-img-xen > /dev/null 2>&1 then QEMU_IMG_CMD=qemu-img-xen + HAVE_QEMU_IMG=true +else + HAVE_QEMU_IMG=false +fi + +if which reflink > /dev/null 2>&1 +then + REFLINK_CMD=`which reflink` + HAVE_REFLINK=true +else + HAVE_REFLINK=false +fi + +if which vhd-util > /dev/null 2>&1 +then + VHD_UTIL_CMD=`which vhd-util` + HAVE_VHD_UTIL=true +else + HAVE_VHD_UTIL=false +fi + +OCFS2_VOLS=`cat /proc/mounts | grep ocfs2 | cut -d \ -f 2` + +if `uname -r | grep -i xen` +then + HYPERVISOR=xen +else + HYPERVISOR=qemu fi ################################################################################### @@ -59,7 +89,8 @@ echo " ================================================================================ Description: - This script creates and manages snapshots of qcow2 virtual disks + This script creates and manages snapshots of qcow2 and vhd virtual disks + and virtual disks on file systems that support snapshots (i.e. OCFS2) Individual snapshots and snapshot trees are supported. The names of the snapshots in the snapshot tree are stored in the actual @@ -203,10 +234,33 @@ exit 2 fi - if ! ($QEMU_IMG_CMD info $DISK | grep "file format" | cut -d ' ' -f 3 | grep -q qcow2) 2> /dev/null + ON_OCFS2=false + for VOL in ${OCFS2_VOLS} + do + while [ "${ON_OCFS2}" == false ] + do + if echo "${DISK}" | grep -q "${VOL}" + then + ON_OCFS2=true + fi + done + done + + if ($QEMU_IMG_CMD info $DISK | grep "file format" | cut -d ' ' -f 3 | grep -q qcow2) 2> /dev/null + then + IMG_TYPE=qcow2 + elif ($QEMU_IMG_CMD info $DISK | grep "file format" | cut -d ' ' -f 3 | grep -q raw) 2> /dev/null then + IMG_TYPE=raw + elif ($QEMU_IMG_CMD info $DISK | grep "file format" | cut -d ' ' -f 3 | grep -q vmdk) 2> /dev/null + then + IMG_TYPE=vmdk + elif ($QEMU_IMG_CMD info $DISK | grep "file format" | cut -d ' ' -f 3 | grep -q vpc) 2> /dev/null + then + IMG_TYPE=vhd + else echo - echo "ERROR: The specified disk "$DISK" does not appear to be of type qcow2" + echo "ERROR: The specified disk "$DISK" does not appear to be of a supported type" echo " You cannot snpashot this disk!" exit 3 fi @@ -215,7 +269,17 @@ ########## Function: get_backing_disk ##################################### get_backing_disk() { - "$QEMU_IMG_CMD" info "$1" | grep "backing file" | cut -d : -f 3 | sed 's/^ *//g' | sed 's/)//g' + case ${IMG_TYPE} in + qcow2) + "$QEMU_IMG_CMD" info "$1" | grep "backing file" | cut -d : -f 3 | sed 's/^ *//g' | sed 's/)//g' + ;; + vhd) + "$VHD_UTIL_CMD" scan "$1" | cut -d \ -f 5 | cut -d = -f 2 + ;; + *) + echo "none" + ;; + esac } ########## Function: find_unused_snap_name ################################ @@ -226,14 +290,17 @@ if [ -z "$SNAPNAME" ] then - #echo "Finding and unused snap name" SNAMECOUNT=1 SNAPNAME=snap"$SNAMECOUNT" - until ! ls "$DISK".* | grep -q snap"$SNAMECOUNT" - do - ((SNAMECOUNT++)) - SNAPNAME=snap"$SNAMECOUNT" - done + if ls "$DISK".* > /dev/null 2>&1 + then + #echo "Finding and unused snap name" + until ! ls "$DISK".* | grep -q snap"$SNAMECOUNT" + do + ((SNAMECOUNT++)) + SNAPNAME=snap"$SNAMECOUNT" + done + fi fi echo "$SNAPNAME" } @@ -243,24 +310,93 @@ local DISK="$1" local SNAPNAME="$2" local SNAP_DESCR="$3" - local BDISK="$DISK".base - mv "$DISK" "$BDISK" - SNAPNAME=`find_unused_snap_name "$DISK" "$SNAPNAME" "$SNAP_DESCR"` + start_first_snap_process() { + SNAPNAME=`find_unused_snap_name "$DISK" "$SNAPNAME" "$SNAP_DESCR"` - echo " Creating new snapshot: $BDISK.$SNAPNAME" - echo "*****************************************************************" - - ln "$BDISK" "$BDISK"."$SNAPNAME" - chmod a-w "$BDISK" - chmod a-w "$BDISK"."$SNAPNAME" - - "$QEMU_IMG_CMD" create -f qcow2 -b "$BDISK" "$BDISK"."$SNAPNAME"._working - ln -s "$BDISK"."$SNAPNAME"._working "$DISK" + echo " Creating new snapshot: $BDISK.$SNAPNAME" + echo "*****************************************************************" + } - # add snapshot description - echo `echo "$BDISK.$SNAPNAME" | sed 's/./_/g' | sed 's/__working//g'`"='$SNAP_DESCR'" >> ."$DISK".snap_descriptions + rename_orig_disk() { + mv "$DISK" "$BDISK" + } + + link_orig_disk() { + ln "$BDISK" "$BDISK"."$SNAPNAME" + chmod a-w "$BDISK" + chmod a-w "$BDISK"."$SNAPNAME" + } + + do_qemu_image_first_snap() { + "$QEMU_IMG_CMD" create -f qcow2 -b "$BDISK" "$BDISK"."$SNAPNAME"._working + } + + do_reflink_first_snap() { + "${REFLINK_CMD}" "${BDISK}" "${BDISK}"."${SNAPNAME}"._working + } + + do_vhd_util_first_snap() { + "$VHD_UTIL_CMD" snapshot -p "$BDISK" -n "$BDISK"."$SNAPNAME"._working + } + + symlink_new_disk() { + ln -s "$BDISK"."$SNAPNAME"._working "$DISK" + } + + add_snapshot_description() { + echo `echo "$BDISK.$SNAPNAME" | sed 's/./_/g' | sed 's/__working//g'`"='$SNAP_DESCR'" >> ."$DISK".snap_descriptions + } + +# case ${HYPERVISOR} in +# qemu) + case ${IMG_TYPE} in + qcow2) + start_first_snap_process + rename_orig_disk + link_orig_disk + do_qemu_image_first_snap + symlink_new_disk + add_snapshot_description + ;; + vhd) + start_first_snap_process + rename_orig_disk + link_orig_disk + do_vhd_util_first_snap + symlink_new_disk + add_snapshot_description + ;; + *) + case ${ON_OCFS2} in + false) + echo "ERROR: Disk is not of type qcow2 or vhd and not on a file system the supports snapshots!" + echo + echo " Will not create a snapshot" + exit 6 + ;; + true) + start_first_snap_process + rename_orig_disk + link_orig_disk + do_reflink_first_snap + symlink_new_disk + add_snapshot_description + ;; + esac + ;; + esac +# ;; +# xen) +# start_first_snap_process +# rename_orig_disk +# link_orig_disk +# do_reflink_first_snap +# symlink_new_disk +# add_snapshot_description +# ;; +# esac } ########## Function: create_additional_snapshot ########################### @@ -268,23 +404,86 @@ local DISK="$1" local SNAPNAME="$2" local SNAP_DESCR="$3" - local BDISK=`ls -l "$DISK" |cut -d ">" -f 2 | sed 's/^ *//g'` - rm -f "$DISK" - SNAPNAME=`find_unused_snap_name "$DISK" "$SNAPNAME" "$SNAP_DESCR"` - BASE_BDISK="`echo "$BDISK" | sed 's/._working//g'`" + start_additional_snap_process() { + SNAPNAME=`find_unused_snap_name "$DISK" "$SNAPNAME" "$SNAP_DESCR"` + BASE_BDISK="`echo "$BDISK" | sed 's/._working//g'`" + + echo " Creating new snapshot: $BASE_BDISK.$SNAPNAME" + echo "*****************************************************************" + } + + do_qemu_image_additional_snap() { + "$QEMU_IMG_CMD" create -f qcow2 -b "$BASE_BDISK"."$SNAPNAME" "$BASE_BDISK"."$SNAPNAME"._working + } - echo " Creating new snapshot: $BASE_BDISK.$SNAPNAME" - echo "*****************************************************************" - mv "$BDISK" "$BASE_BDISK"."$SNAPNAME" - chmod a-w "$BASE_BDISK"."$SNAPNAME" + do_vhd_util_additional_snap() { + "$VHD_UTIL_CMD" snapshot -p "$BASE_BDISK"."$SNAPNAME" -n "$BASE_BDISK"."$SNAPNAME"._working + } - "$QEMU_IMG_CMD" create -f qcow2 -b "$BASE_BDISK"."$SNAPNAME" "$BASE_BDISK"."$SNAPNAME"._working - ln -s "$BASE_BDISK"."$SNAPNAME"._working "$DISK" + do_reflink_additional_snap() { + "${REFLINK_CMD}" "${BASE_DISK}"."${SNAPNAME}" "${BASE_DISK}"."${SNAPNAME}"._working + } - # add snapshot description - echo `echo "$BDISK.$SNAPNAME" | sed 's/./_/g' | sed 's/__working//g'`"='$SNAP_DESCR'" >> ."$DISK".snap_descriptions + move_working_to_snap() { + rm -f "$DISK" + mv "$BDISK" "$BASE_BDISK"."$SNAPNAME" + chmod a-w "$BASE_BDISK"."$SNAPNAME" + } + + symlink_new_working_snap() { + ln -s "$BASE_BDISK"."$SNAPNAME"._working "$DISK" + } + + add_additional_snapshot_description() { + echo `echo "$BASE_DISK.$SNAPNAME" | sed 's/./_/g' | sed 's/__working//g'`"='$SNAP_DESCR'" >> ."$DISK".snap_descriptions + } + +# case ${HYPERVISOR} in +# qemu) + case ${IMG_TYPE} in + qcow2) + start_additional_snap_process + move_working_to_snap + do_qemu_image_additional_snap + symlink_new_working_snap + add_additional_snapshot_description + ;; + vhd) + start_additional_snap_process + move_working_to_snap + do_vhd_util_additional_snap + symlink_new_working_snap + add_additional_snapshot_description + ;; + *) + case ${ON_OCFS2} in + false) + echo "ERROR: Disk is not of type qcow2 and not on a file system the supports snapshots!" + echo + echo " Will not create a snapshot" + exit 6 + ;; + true) + start_additional_snap_process + move_working_to_snap + do_reflink_additional_snap + symlink_new_working_snap + add_additional_snapshot_description + ;; + esac + ;; + esac +# ;; +# xen) +# start_additional_snap_process +# move_working_to_snap +# do_reflink_additional_snap +# symlink_new_working_snap +# add_additional_snapshot_description +# ;; +# esac } ########## Function: create_snapshot ###################################### @@ -310,6 +509,45 @@ local DISK="$1" local SNAPNAME="$2" local SNAP_DESCR="$3" + local SNAP_POINT=`ls "$DISK".* | grep "$SNAPNAME$"` + + start_branch_process() { + #echo "Finding and unused snap name" + local SNAMECOUNT=1 + until ! ls "$DISK".* | grep -q "$SNAPNAME"-"$SNAMECOUNT"$ + do + ((SNAMECOUNT++)) + done + SUB_SNAPNAME="$SNAPNAME"-"$SNAMECOUNT" + echo "*****************************************************************" + echo " Branching from snapshot: $SNAP_POINT" + } + + remove_current_working() { + rm -f "$DISK" + rm -f "$DISK".*._working + } + + do_qemu_img_branch_snap() { + "$QEMU_IMG_CMD" create -f qcow2 -b "$SNAP_POINT" "$SNAP_POINT"."$SUB_SNAPNAME"._working + } + + do_vhd_util_branch_snap() { + "$VHD_UITL_CMD" snapshot -p "$SNAP_POINT" -n "$SNAP_POINT"."$SUB_SNAPNAME"._working + } + + do_reflink_branch_snap() { + "${REFLINK_CMD}" "${SNAP_POINT}" "${SNAP_POINT}"."${SUB_SNAPNAME}"._working + } + + symlink_new_branch_snap() { + ln -s "$SNAP_POINT"."$SUB_SNAPNAME"._working "$DISK" + chmod a-w "$SNAP_POINT" + } + + add_branch_snapshot_description() { + echo `echo "${SNAP_POINT}.${SUB_SNAPNAME}" | sed 's/./_/g' | sed 's/__working//g'`"='$SNAP_DESCR'" >> ."$DISK".snap_descriptions + } if [ -z "$SNAPNAME" ] then @@ -327,28 +565,43 @@ exit 5 fi - local SNAP_POINT=`ls "$DISK".* | grep "$SNAPNAME$"` - - #echo "Finding and unused snap name" - local SNAMECOUNT=1 - until ! ls "$DISK".* | grep -q "$SNAPNAME"-"$SNAMECOUNT"$ - do - ((SNAMECOUNT++)) - done - SUB_SNAPNAME="$SNAPNAME"-"$SNAMECOUNT" - echo "*****************************************************************" - echo " Branching from snapshot: $SNAP_POINT" - - rm -f "$DISK" - rm -f "$DISK".*._working - #ln -s "$SNAP_POINT" "$DISK" - #create_snapshot "$DISK" "$SUB_SNAPNAME" "$SNAP_DESCR" - - "$QEMU_IMG_CMD" create -f qcow2 -b "$SNAP_POINT" "$SNAP_POINT"."$SUB_SNAPNAME"._working - - ln -s "$SNAP_POINT"."$SUB_SNAPNAME"._working "$DISK" - chmod a-w "$SNAP_POINT" - +# case ${HYPERVISOR} in +# qemu) + case ${IMG_TYPE} in + qcow2) + start_branch_process + remove_current_working + do_qemu_img_branch_snap + symlink_new_branch_snap + add_branch_snapshot_description + ;; + *) + case ${ON_OCFS2} in + false) + echo "ERROR: Disk is not of type qcow2 and not on a file system the supports snapshots!" + echo + echo " Will not create a snapshot" + exit 6 + ;; + true) + start_branch_process + remove_current_working + do_reflink_branch_snap + symlink_new_branch_snap + add_branch_snapshot_description + ;; + esac + ;; + esac +# ;; +# xen) +# start_branch_process +# remove_current_working +# do_reflink_branch_snap +# symlink_new_branch_snap +# add_branch_snapshot_description +# ;; +# esac } ########## Function: revert_to_snapshot ##################################### @@ -356,6 +609,40 @@ local DISK="$1" local SNAPNAME="$2" local SNAP_DESCR="$3" + local SNAP_POINT=`ls "$DISK".* | grep "$SNAPNAME$"` + + start_revert_process() { + echo "*****************************************************************" + echo " Reverting to snapshot: $SNAP_POINT" + echo "*****************************************************************" + } + + remove_current_working_and_snap_point() { + rm -f "$DISK" + rm -f "$DISK".*._working + rm -f "$SNAP_POINT".* + } + + do_new_qemu_img_working_snap() { + "$QEMU_IMG_CMD" create -f qcow2 -b "$SNAP_POINT" "$SNAP_POINT"._working + } + + do_new_vhd_util_working_snap() { + "$VHD_UTIL_CMD" snapshot -p "$SNAP_POINT" -n "$SNAP_POINT"._working + } + + do_new_reflink_working_snap() { + "${REFLINK_CMD}" "${SNAP_POINT}" "${SNAP_POINT}"._working + } + + symlink_to_reverted_snap() { + ln -s "$SNAP_POINT"._working "$DISK" + chmod a-w "$SNAP_POINT" + } + + remove_reverted_snapshot_description() { + sed -i "/$SNAP_POINT..*/d" ."$DISK".snap_descriptions + } if [ -z "$SNAPNAME" ] then @@ -373,23 +660,43 @@ exit 5 fi - local SNAP_POINT=`ls "$DISK".* | grep "$SNAPNAME$"` - - echo "*****************************************************************" - echo " Reverting to snapshot: $SNAP_POINT" - echo "*****************************************************************" - - rm -f "$DISK" - rm -f "$DISK".*._working - rm -f "$SNAP_POINT".* - - "$QEMU_IMG_CMD" create -f qcow2 -b "$SNAP_POINT" "$SNAP_POINT"._working - - ln -s "$SNAP_POINT"._working "$DISK" - chmod a-w "$SNAP_POINT" - - # remove snapshot description - sed -i "/$SNAP_POINT..*/d" ."$DISK".snap_descriptions +# case ${HYPERVISOR} in +# qemu) + case ${IMG_TYPE} in + qcow2) + start_revert_process + remove_current_working_and_snap_point + do_new_qemu_img_working_snap + symlink_to_reverted_snap + remove_reverted_snapshot_description + ;; + *) + case ${ON_OCFS2} in + false) + echo "ERROR: Disk is not of type qcow2 and not on a file system the supports snapshots!" + echo + echo " Will not create a snapshot" + exit 6 + ;; + true) + start_revert_process + remove_current_working_and_snap_point + do_new_reflink_working_snap + symlink_to_reverted_snap + remove_reverted_snapshot_description + ;; + esac + ;; + esac +# ;; +# xen) +# start_revert_process +# remove_current_working_and_snap_point +# do_new_reflink_working_snap +# symlink_to_reverted_snap +# remove_reverted_snapshot_description +# ;; +# esac } ########## Function: remove_snapshot ##################################### @@ -429,8 +736,6 @@ else for SNAP in `ls "$DISK".base.*` do -#echo "SNAP=$SNAP";read - if ! echo "$SNAP" | grep -q "_working" then local DOT_COUNT=`echo $SNAP | grep -o \. | wc -l` ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org