Commit 7d97822f authored by Tomasz Zawadzki's avatar Tomasz Zawadzki Committed by Jim Harris
Browse files

vagrant: preallocate nvme images by default



Added preallocation option for raw NVMe disk images.
It matches qemu-img option for raw images.

By default raw images are created with "off" option,
resulting in increased size of the disk image as it is used.

Using "falloc" option preallocates the full size of the disk,
but does not write zeroes to it, compared to "full" option.

This will make sure that in CI, a device used during test
is never exhaused due to lack of host space.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ie1c30909dc87552a6d6c385d0ad80905ce68ff9d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11243


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 057fdedb
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
SYSTEM=$(uname -s)
size="1024M"
nvme_disk="/var/lib/libvirt/images/nvme_disk.img"
preallocation="falloc"

function usage() {
	echo "Usage: ${0##*/} [-s <disk_size>] [-n <backing file name>]"
@@ -9,9 +10,11 @@ function usage() {
	echo "                                    for OCSSD default: 9G"
	echo "-n <backing file name>        backing file path with name"
	echo "           default: /var/lib/libvirt/images/nvme_disk.img"
	echo "-p <mode>              allowed values:[off, falloc, full]"
	echo "                                          default: falloc"
}

while getopts "s:n:t:h-:" opt; do
while getopts "s:n:p:t:h-:" opt; do
	case "${opt}" in
		-)
			echo "  Invalid argument: $OPTARG"
@@ -24,6 +27,9 @@ while getopts "s:n:t:h-:" opt; do
		n)
			nvme_disk=$OPTARG
			;;
		p)
			preallocation=$OPTARG
			;;
		h)
			usage
			exit 0
@@ -42,7 +48,7 @@ if [ "${SYSTEM}" != "Linux" ]; then
fi

WHICH_OS=$(lsb_release -i | awk '{print $3}')
qemu-img create -f raw "$nvme_disk" $size
qemu-img create -f raw "$nvme_disk" -o preallocation="$preallocation" $size

case $WHICH_OS in
	"Fedora")