summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2015-12-04 11:45:04 +0100
committerDominique Martinet <asmadeus@codewreck.org>2015-12-04 12:52:11 +0100
commit99cc58ab0fe9744aa5e9fc64ce82f60db8f715f2 (patch)
treef7c0f8c2d1c9090d6e78cfdbe5f02c978a6b45e9
parent3f68561ae79cdcbbcb04abb3f50009a0aeafbe04 (diff)
add support for memory-backend-ram, and some more subtle numactl pinning
-rw-r--r--kvm-wrapper.conf.default4
-rwxr-xr-xkvm-wrapper.sh19
2 files changed, 22 insertions, 1 deletions
diff --git a/kvm-wrapper.conf.default b/kvm-wrapper.conf.default
index 034d0af..df08674 100644
--- a/kvm-wrapper.conf.default
+++ b/kvm-wrapper.conf.default
@@ -76,8 +76,12 @@ KVM_DISK_OPT[0]=",cache=none,aio=native"
#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_PIN_PCI # will resolve to /sys/bus/pci/devices/*${KVM_PIN_PCI}/numa_node
+#KVM_PIN_NODE # 0-1 (must be accepted by both numactl -N and qemu host-nodes)
#KVM_NUMACTL_OPT # numactl opts, e.g. --membind=pci:01:00.0 --cpunodebind=pci:01:00.0
+#KVM_MEM_POLICY # for memory-backend-ram, e.g. preferred -- will use KVM_MEM for size.
+
# Setting user requires access to: /dev/kvm, /dev/net/tun,
# /dev/vhost-net, /dev/vfio/vfio and ulimit -l big
#KVM_USER="qemu"
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index 34c7b40..f07e709 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -711,17 +711,34 @@ function kvm_start_vm ()
done
local KVM_PINNING=""
+ [[ -n "$KVM_PIN_PCI" ]] && {
+ KVM_PIN_NODE=$(cat /sys/bus/pci/devices/*${KVM_PIN_PCI}/numa_node)
+ [[ "$KVM_PIN_NODE" == "-1" || "$KVM_PIN_NODE" == *$'\n'* ]] && \
+ fail_exit "$KVM_PIN_PCI does not look like a valid PCI to pin to (cat /sys/bus/pci/devices/*${KVM_PIN_PCI}/numa_node)"
+ }
+
+ [[ -n "$KVM_PIN_NODE" && -z "$KVM_NUMACTL_OPT" ]] && \
+ KVM_NUMACTL_OPT="-N $KVM_PIN_NODE"
+
[[ -n "$KVM_NUMACTL_OPT" ]] && {
require_exec "$KVM_NUMACTL_BIN"
KVM_PINNING="$KVM_NUMACTL_BIN $KVM_NUMACTL_OPT --"
}
+ local KVM_MEMORY=""
+ [[ -n "$KVM_MEM_POLICY" ]] && {
+ KVM_MEMORY="-m $KVM_MEM -object memory-backend-ram,size=${KVM_MEM},policy=$KVM_MEM_POLICY,id=ram-0"
+ [[ -n "$KVM_PIN_NODE" ]] && KVM_MEMORY+=",host-nodes=$KVM_PIN_NODE"
+ } || {
+ KVM_MEMORY="-m $KVM_MEM"
+ }
+
# Monitor/serial devices
KVM_MONITORDEV="-monitor unix:$MONITOR_FILE,server,nowait"
KVM_SERIALDEV="-serial unix:$SERIAL_FILE,server,nowait"
# Build kvm exec string
- local EXEC_STRING="$KVM_PINNING $KVM_BIN -name $VM_NAME,process=\"kvm-$VM_NAME\" -m $KVM_MEM -smp $KVM_CPU_NUM $KVM_PREPEND_PARAMS $KVM_PCIASSIGN $KVM_VFIO $KVM_NET $KVM_DRIVES $KVM_BOOTDEVICE $KVM_KEYMAP $KVM_OUTPUT $LINUXBOOT $KVM_MONITORDEV $KVM_SERIALDEV -pidfile $PID_FILE $KVM_ADDITIONNAL_PARAMS"
+ local EXEC_STRING="$KVM_PINNING $KVM_BIN -name $VM_NAME,process=\"kvm-$VM_NAME\" $KVM_MEMORY -smp $KVM_CPU_NUM $KVM_PREPEND_PARAMS $KVM_PCIASSIGN $KVM_VFIO $KVM_NET $KVM_DRIVES $KVM_BOOTDEVICE $KVM_KEYMAP $KVM_OUTPUT $LINUXBOOT $KVM_MONITORDEV $KVM_SERIALDEV -pidfile $PID_FILE $KVM_ADDITIONNAL_PARAMS"
CLEANUP+=("rm -f \"$PID_FILE\" \"$MONITOR_FILE\" \"$SERIAL_FILE\"")