numam-spdk/scripts/vagrant/create_nvme_img.sh
Seth Howell b15ecfad85 scripts/vagrant: add the ability to specify the nvme file.
This is necessary to enable multiple VMs to run in the same physical
system since they each need a unique backing nvme drive.

Change-Id: Ie2d3aa9604533b4d39932e1f68cb977bafdb7ab4
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/432202
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-11-15 17:09:04 +00:00

50 lines
906 B
Bash
Executable File

#!/usr/bin/env bash
SYSTEM=`uname -s`
size="1024M"
name="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 "-n <backing file name> default: nvme_disk.img"
}
while getopts "s:n:h-:" opt; do
case "${opt}" in
-)
echo " Invalid argument: $OPTARG"
usage
exit 1
;;
s)
size=$OPTARG
;;
n)
name=$OPTARG
;;
h)
usage
exit 0
;;
*)
echo " Invalid argument: $OPTARG"
usage
exit 1
;;
esac
done
if [ ! "${SYSTEM}" = "FreeBSD" ]; then
WHICH_OS=`lsb_release -i | awk '{print $3}'`
nvme_disk="/var/lib/libvirt/images/$name"
qemu-img create -f raw $nvme_disk ${size}
#Change SE Policy on Fedora
if [ $WHICH_OS == "Fedora" ]; then
sudo chcon -t svirt_image_t $nvme_disk
fi
chmod 777 $nvme_disk
chown qemu:qemu $nvme_disk
fi