Spdk/scripts/vagrant/create_nvme_img.sh
Michal Berger ea71df4f48 scripts/vagrant: Drop OCSSD awareness from functional tests
This also translates into switching fully to upstream QEMU for the
vagrant setup.

This is done in order to move away from OCSSD and SPDK's qemu fork
and align with what upstream QEMU supports. Main changes touch the
way how nvme namespaces are configured. With >= 5.2.0 it's possible
now to configure multiple namespace under single nvme device. Each
namespace requires a separate disk image to work with. This:

-b foo.img,nvme,1...
-b foo.img
-b foo.img,,..

Will still configure nvme controller with a single namespace attached
to foo.img.

This:

-b foo.img,,foo-ns1.img:foo-ns2.img

Will configure nvme controller with three namespaces.

Configuring nvme controller with no namespaces is possible via:

-b none ...

Note that this still allows to define other options specific to nvme
controller, like CMB and PMR. E.g:

-b none,nvme,,true

This will create nvme controller with no namespaces but with CMB
enabled.

It's possible now to also request for given controller to be zoned.
Currently if requsted, all namespaces under the target controller
will be zoned with no limit set as to max open|active zones.

All nvme devices have block size fixed to 4KB to imititate behavior
of the SPDK's qemu fork.

Compatibility with spdk-5.0.0 fork is preserved in context of setting
up namespaces so this:

-b foo.img,nvme,2

is valid as long as the emulator is set to that of spdk-5.0.0's.

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: Ib5d53cb5c330c1f84b57e0bf877ea0e2d0312ddd
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8421
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2021-12-06 08:34:46 +00:00

66 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
SYSTEM=$(uname -s)
size="1024M"
nvme_disk="/var/lib/libvirt/images/nvme_disk.img"
function usage() {
echo "Usage: ${0##*/} [-s <disk_size>] [-n <backing file name>]"
echo "-s <disk_size> with postfix e.g. 2G default: 1024M"
echo " for OCSSD default: 9G"
echo "-n <backing file name> backing file path with name"
echo " default: /var/lib/libvirt/images/nvme_disk.img"
}
while getopts "s:n:t:h-:" opt; do
case "${opt}" in
-)
echo " Invalid argument: $OPTARG"
usage
exit 1
;;
s)
size=$OPTARG
;;
n)
nvme_disk=$OPTARG
;;
h)
usage
exit 0
;;
*)
echo " Invalid argument: $OPTARG"
usage
exit 1
;;
esac
done
if [ "${SYSTEM}" != "Linux" ]; then
echo "This script supports only Linux OS" >&2
exit 2
fi
WHICH_OS=$(lsb_release -i | awk '{print $3}')
qemu-img create -f raw "$nvme_disk" $size
case $WHICH_OS in
"Fedora")
qemu_user_group="qemu:qemu"
# Change SE Policy
sudo chcon -t svirt_image_t "$nvme_disk"
;;
"Ubuntu")
qemu_user_group="libvirt-qemu:kvm"
;;
*)
# That's just a wild guess for now
# TODO: needs improvement for other distros
qemu_user_group="libvirt-qemu:kvm"
;;
esac
chmod 777 "$nvme_disk"
chown $qemu_user_group "$nvme_disk"