Skip to content

Instantly share code, notes, and snippets.

@jmelis
Created December 3, 2013 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmelis/7768171 to your computer and use it in GitHub Desktop.
Save jmelis/7768171 to your computer and use it in GitHub Desktop.
diff --git a/src/datastore_mad/remotes/fs/mkfs b/src/datastore_mad/remotes/fs/mkfs
index afdd851..7f7842f 100755
--- a/src/datastore_mad/remotes/fs/mkfs
+++ b/src/datastore_mad/remotes/fs/mkfs
@@ -49,7 +49,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
/DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
- /DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
+ /DS_DRIVER_ACTION_DATA/IMAGE/SIZE \
+ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/QCOW_PREALLOC)
BASE_PATH="${XPATH_ELEMENTS[0]}"
@@ -57,6 +58,7 @@ RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
SAFE_DIRS="${XPATH_ELEMENTS[2]}"
FSTYPE="${XPATH_ELEMENTS[3]}"
SIZE="${XPATH_ELEMENTS[4]}"
+QCOW_PREALLOC="${XPATH_ELEMENTS[5]}"
mkdir -p "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS"
@@ -72,11 +74,12 @@ fi
# ------------ Create the image to the repository ------------
-MKFS_CMD=`mkfs_command $DST $FSTYPE $SIZE`
-
-exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
- "Could not create image $DST"
-exec_and_log "$MKFS_CMD" \
- "Unable to create filesystem $FSTYPE in $DST"
+if [ "$QCOW_PREALLOC" = "YES" ]; then
+ exec_and_log "... the qemu command ..." \
+ "Could not create image $DST"
+else
+ exec_and_log "$MKFS_CMD" \
+ "Unable to create filesystem $FSTYPE in $DST"
+fi
echo "$DST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment