diff --git a/share/etc/oned.conf b/share/etc/oned.conf index be02d646a89..946eb76be8a 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -12,7 +12,7 @@ # MONITORING_INTERVAL_DATASTORE: Time in seconds between image monitorization. # monitoring information. -1 to disable DB updating and 0 to write every update # -# DS_MONITOR_VM_DISK: Number of MONIROTING_INTERVAL_DATASTORE intervals to monitor +# DS_MONITOR_VM_DISK: Number of MONITORING_INTERVAL_DATASTORE intervals to monitor # VM disks. 0 to disable. Only applies to fs and fs_lvm datastores # # SCRIPTS_REMOTE_DIR: Remote path to store the monitoring and VM management diff --git a/src/tm_mad/common/resize b/src/tm_mad/common/resize index d078dbdc871..b91be802e1f 100755 --- a/src/tm_mad/common/resize +++ b/src/tm_mad/common/resize @@ -32,6 +32,8 @@ fi . $TMCOMMON +DRIVER_PATH=$(dirname $0) + SRC_PATH=$(arg_path $SRC) SRC_HOST=$(arg_host $SRC) @@ -41,5 +43,26 @@ if [ `lcm_state $VMID` -eq 62 ]; then exit 0 fi -ssh_exec_and_log "${SRC_HOST}" "qemu-img resize ${SRC_PATH} ${SIZE}M" \ +#------------------------------------------------------------------------------- +# Get Image information +#------------------------------------------------------------------------------- + +DISK_ID=$(basename ${SRC_PATH} | cut -d. -f2) + +XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin" +unset i j XPATH_ELEMENTS +while IFS= read -r -d '' element; do + XPATH_ELEMENTS[i++]="$element" +done < <(onevm show -x $VMID| $XPATH \ + /VM/TEMPLATE/DISK\[DISK_ID=$DISK_ID\]/SPARSE) +SPARSE="${XPATH_ELEMENTS[j++]}" + + +if [[ "${SPARSE}" =~ ^(no|NO)$ ]]; then + RESIZE_CMD="qemu-img resize --preallocation=falloc ${SRC_PATH} ${SIZE}M" +else + RESIZE_CMD="qemu-img resize ${SRC_PATH} ${SIZE}M" +fi + +ssh_exec_and_log "${SRC_HOST}" "$RESIZE_CMD" \ "Error resizing image ${SRC_PATH}" diff --git a/src/tm_mad/qcow2/clone b/src/tm_mad/qcow2/clone index be71313ba6a..95c77b5c480 100755 --- a/src/tm_mad/qcow2/clone +++ b/src/tm_mad/qcow2/clone @@ -85,8 +85,11 @@ disable_local_monitoring $DST_HOST $DST_DIR #------------------------------------------------------------------------------- if [ -n "$ORIGINAL_SIZE" ] && [ "$SIZE" -gt "$ORIGINAL_SIZE" ]; then - RESIZE_CMD="qemu-img resize ${DST_PATH} ${SIZE}M" - [[ "${SPARSE}" =~ ^(no|NO)$ ]] && RESIZE_CMD="qemu-img resize --preallocation=falloc ${DST_PATH} ${SIZE}M" + if [[ "${SPARSE}" =~ ^(no|NO)$ ]]; then + RESIZE_CMD="qemu-img resize --preallocation=falloc ${DST_PATH} ${SIZE}M" + else + RESIZE_CMD="qemu-img resize ${DST_PATH} ${SIZE}M" + fi fi if [ "$FORMAT" = "qcow2" ] && is_yes "${QCOW2_STANDALONE}"; then