summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2015-11-16 18:54:18 +0100
committerDominique Martinet <asmadeus@codewreck.org>2015-12-04 11:46:01 +0100
commit3f68561ae79cdcbbcb04abb3f50009a0aeafbe04 (patch)
tree2f291a69fcccfd1189a48567f770b02dbeaf92ef
parentab235c5b47fdd04d8248893d32758e4b3a7ea733 (diff)
sriov: mlx5 forge guid (similar to mac)
-rw-r--r--kvm-wrapper.conf.default4
-rwxr-xr-xkvm-wrapper.sh8
2 files changed, 10 insertions, 2 deletions
diff --git a/kvm-wrapper.conf.default b/kvm-wrapper.conf.default
index ff95211..034d0af 100644
--- a/kvm-wrapper.conf.default
+++ b/kvm-wrapper.conf.default
@@ -72,6 +72,10 @@ KVM_DISK_OPT[0]=",cache=none,aio=native"
#KVM_VFIO_DOMAIN[0] # 01:00.0
#KVM_VFIO_ID[0] # "fooidname" (id string, no comma/whitespace/equalsign)
+#KVM_SRIOV_DEV # which master device you want e.g. mlx5_0 - picks any if unset
+#KVM_SRIOV_PKEYS # space-separated list of pkeys you want to feed to your VM (mlx4 only)
+#KVM_SRIOV_GUID # guid you want inside VM (mlx5 only, this defines the pkeys you'll get through opensm config)
+
#KVM_NUMACTL_OPT # numactl opts, e.g. --membind=pci:01:00.0 --cpunodebind=pci:01:00.0
# Setting user requires access to: /dev/kvm, /dev/net/tun,
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index 24ca1c9..34c7b40 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -409,6 +409,7 @@ function ib_sriov()
{
local PKEYS="$1"
local IB_DEV="$2"
+ local CHILD_GUID="$3"
# pick one compatible card at random
@@ -457,7 +458,9 @@ function ib_sriov()
local VIRTFN_IDX=${VIRTFN#*virtfn}
echo Follow > /sys/class/infiniband/$IB_DEV/device/sriov/$VIRTFN_IDX/policy
echo $GUID > /sys/class/infiniband/$IB_DEV/device/sriov/$VIRTFN_IDX/node
- printf "%s:%x\n" "${GUID%:*}" $((0x${GUID##*:}+$VIRTFN_IDX+1)) > /sys/class/infiniband/$IB_DEV/device/sriov/$VIRTFN_IDX/port
+ [[ -n "$CHILD_GUID" ]] && \
+ echo "$CHILD_GUID" > /sys/class/infiniband/$IB_DEV/device/sriov/$VIRTFN_IDX/port || \
+ printf "%s:%x\n" "${GUID%:*}" $((0x${GUID##*:}+$VIRTFN_IDX+1)) > /sys/class/infiniband/$IB_DEV/device/sriov/$VIRTFN_IDX/port
fi
KVM_VFIO_DOMAIN+=("$PCIDOMAIN")
@@ -695,7 +698,8 @@ function kvm_start_vm ()
done
# IB sriov
- [[ -n "$KVM_SRIOV_PKEYS$KVM_SRIOV_DEV" ]] && ib_sriov "$KVM_SRIOV_PKEYS" "$KVM_SRIOV_DEV" && \
+ [[ -n "$KVM_SRIOV_PKEYS$KVM_SRIOV_DEV$KVM_SRIOV_GUID" ]] && \
+ ib_sriov "$KVM_SRIOV_PKEYS" "$KVM_SRIOV_DEV" "$KVM_SRIOV_GUID" && \
CLEANUP+=("ib_unsriov")
# vfio assignement