summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu/data
diff options
context:
space:
mode:
authorSimon Rettberg2023-07-26 16:22:15 +0200
committerSimon Rettberg2023-07-26 16:22:15 +0200
commitdbfa29bce1e206eb049504312b8eadf6fa92c61f (patch)
treeb0f0beba90f0268198c630b802f3a56d69bf0c21 /core/modules/qemu/data
parent[qemu] Tweak Alderlake stuff again (diff)
downloadmltk-dbfa29bce1e206eb049504312b8eadf6fa92c61f.tar.gz
mltk-dbfa29bce1e206eb049504312b8eadf6fa92c61f.tar.xz
mltk-dbfa29bce1e206eb049504312b8eadf6fa92c61f.zip
[libvirt] Add support for CPU pinning, honor host's SMT topology
Read the system's SMT topology, and apply it to the guest via CPU pinning. In qemu, sibling threads on the same CPU core are adjacent regarding the vCPU IDs, so make sure we assign them in ascending order.
Diffstat (limited to 'core/modules/qemu/data')
-rw-r--r--core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include
index ecf68e0c..b15015ee 100644
--- a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include
+++ b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include
@@ -74,7 +74,13 @@ run_plugin() {
fi
# set device passthrough debug mode
- debug_pth="false"
+ local debug_pth="false"
+
+ # Use cat here instead of redirect because of globbing
+ local cputhreads
+ cputhreads="$( cat /sys/devices/system/cpu/cpu*/topology/core_cpus_list | awk '!a[$1]{if(b)printf";";printf $1;a[$1]=1;b=1}' )"
+ # Try legacy name
+ [ -z "$cputhreads" ] && cputhreads="$( cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | awk '!a[$1]{if(b)printf";";printf $1;a[$1]=1;b=1}' )"
# call the Libvirt Java tool to finalize configuration and start VM
declare -rg VIRTCMD="java"
@@ -89,7 +95,11 @@ run_plugin() {
notempty TMPCONFIG && VIRTCMDOPTS+=( "-vmcfginp" "${TMPCONFIG}" )
notempty vm_final_config && VIRTCMDOPTS+=( "-vmcfgout" "${vm_final_config}" )
notempty IMGUUID && VIRTCMDOPTS+=( "-vmuuid" "${IMGUUID}" )
- notempty HW_CORES && VIRTCMDOPTS+=( "-vmncpus" "${HW_CORES}" )
+ if notempty cputhreads; then
+ VIRTCMDOPTS+=( "-cputopo" "${cputhreads}" )
+ elif notempty HW_THREADS; then
+ VIRTCMDOPTS+=( "-vmncpus" "${HW_THREADS}" )
+ fi
notempty VM_MEM && VIRTCMDOPTS+=( "-vmmem" "${VM_MEM}" )
notempty VM_MAC_ADDR && VIRTCMDOPTS+=( "-vmmac0" "${VM_MAC_ADDR}" )
notempty vm_diskfile && VIRTCMDOPTS+=( "-vmhdd0" "${vm_diskfile}" )