From 0f94acd8fb2486b67fc5931653bd8ed88c5be214 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Mon, 10 Feb 2020 04:35:23 -0600 Subject: [PATCH] VMs: enable cpu cache passthrough; AMD + multithreaded --- plugins/dynamix.vm.manager/include/libvirt.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/dynamix.vm.manager/include/libvirt.php b/plugins/dynamix.vm.manager/include/libvirt.php index 80233d5be..e8c07c32b 100644 --- a/plugins/dynamix.vm.manager/include/libvirt.php +++ b/plugins/dynamix.vm.manager/include/libvirt.php @@ -321,11 +321,22 @@ $intCPUThreadsPerCore = 1; $cpumode = ''; + $cpucache = ''; + $cpufeatures = ''; if (!empty($domain['cpumode']) && $domain['cpumode'] == 'host-passthrough') { $cpumode .= "mode='host-passthrough'"; + $cpucache = ""; // detect if the processor is hyperthreaded: $intCPUThreadsPerCore = max(intval(shell_exec('/usr/bin/lscpu | grep \'Thread(s) per core\' | awk \'{print $4}\'')), 1); + + // detect if the processor is AMD + multithreaded, and if so, enable topoext cpu feature + if ($intCPUThreadsPerCore > 1) { + $strCPUInfo = file_get_contents('/proc/cpuinfo'); + if (strpos($strCPUInfo, 'AuthenticAMD') !== false) { + $cpufeatures .= ""; + } + } // even amount of cores assigned and cpu is hyperthreaded: pass that info along to the cpu section below if ($intCPUThreadsPerCore > 1 && ($vcpus % $intCPUThreadsPerCore == 0)) { @@ -336,6 +347,8 @@ $cpustr = " + $cpucache + $cpufeatures {$vcpus}