2017-11-28 14:04:51 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-07-03 15:12:39 +00:00
|
|
|
SYSTEM=$(uname -s)
|
2018-09-19 09:31:00 +00:00
|
|
|
size="1024M"
|
2019-11-19 10:38:23 +00:00
|
|
|
nvme_disk="/var/lib/libvirt/images/nvme_disk.img"
|
2018-09-19 09:31:00 +00:00
|
|
|
|
2018-11-06 18:05:10 +00:00
|
|
|
function usage() {
|
|
|
|
echo "Usage: ${0##*/} [-s <disk_size>] [-n <backing file name>]"
|
|
|
|
echo "-s <disk_size> with postfix e.g. 2G default: 1024M"
|
2019-11-19 10:38:23 +00:00
|
|
|
echo " for OCSSD default: 9G"
|
|
|
|
echo "-n <backing file name> backing file path with name"
|
|
|
|
echo " default: /var/lib/libvirt/images/nvme_disk.img"
|
2018-11-06 18:05:10 +00:00
|
|
|
}
|
|
|
|
|
2019-08-28 14:08:21 +00:00
|
|
|
while getopts "s:n:t:h-:" opt; do
|
2018-11-06 18:05:10 +00:00
|
|
|
case "${opt}" in
|
|
|
|
-)
|
|
|
|
echo " Invalid argument: $OPTARG"
|
|
|
|
usage
|
|
|
|
exit 1
|
2020-05-07 11:27:06 +00:00
|
|
|
;;
|
2018-11-06 18:05:10 +00:00
|
|
|
s)
|
|
|
|
size=$OPTARG
|
2020-05-07 11:27:06 +00:00
|
|
|
;;
|
2018-11-06 18:05:10 +00:00
|
|
|
n)
|
2019-11-19 10:38:23 +00:00
|
|
|
nvme_disk=$OPTARG
|
2020-05-07 11:27:06 +00:00
|
|
|
;;
|
2018-11-06 18:05:10 +00:00
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 0
|
2020-05-07 11:27:06 +00:00
|
|
|
;;
|
2018-11-06 18:05:10 +00:00
|
|
|
*)
|
|
|
|
echo " Invalid argument: $OPTARG"
|
|
|
|
usage
|
|
|
|
exit 1
|
2020-05-07 11:27:06 +00:00
|
|
|
;;
|
2018-11-06 18:05:10 +00:00
|
|
|
esac
|
|
|
|
done
|
2017-11-28 14:04:51 +00:00
|
|
|
|
2021-01-29 10:22:18 +00:00
|
|
|
if [ "${SYSTEM}" != "Linux" ]; then
|
|
|
|
echo "This script supports only Linux OS" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
WHICH_OS=$(lsb_release -i | awk '{print $3}')
|
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-06-17 16:44:43 +00:00
|
|
|
qemu-img create -f raw "$nvme_disk" $size
|
2021-01-29 10:22:18 +00:00
|
|
|
|
|
|
|
case $WHICH_OS in
|
|
|
|
"Fedora")
|
|
|
|
qemu_user_group="qemu:qemu"
|
2017-11-28 14:04:51 +00:00
|
|
|
|
2021-01-29 10:22:18 +00:00
|
|
|
# Change SE Policy
|
|
|
|
sudo chcon -t svirt_image_t "$nvme_disk"
|
|
|
|
;;
|
|
|
|
"Ubuntu")
|
|
|
|
qemu_user_group="libvirt-qemu:kvm"
|
|
|
|
;;
|
|
|
|
*)
|
2020-03-30 10:09:50 +00:00
|
|
|
# That's just a wild guess for now
|
|
|
|
# TODO: needs improvement for other distros
|
2021-01-29 10:22:18 +00:00
|
|
|
qemu_user_group="libvirt-qemu:kvm"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
chmod 777 "$nvme_disk"
|
|
|
|
chown $qemu_user_group "$nvme_disk"
|