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: Tomasz 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: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Tomasz Zawadzki 2022-01-25 11:53:49 +01:00 committed by Jim Harris
parent 057fdedbff
commit 7d97822f17

View File

@ -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")