Menu="CPUset:1"
Title="CPU Pinning VM"
Tag="icon-cpu"
---
$libvirtd = pgrep('libvirtd')!==false;
$dockerd = pgrep('dockerd')!==false;
$cpus = cpu_list();
$total = count($cpus);
$spinner = "
|
";
$cpuset = implode(';',$cpus);
$is_intel_cpu = is_intel_cpu();
$core_types = $is_intel_cpu ? get_intel_core_types() : [];
function create($type = "") {
// create the table header. Make multiple rows when CPU cores are many ;)
global $total, $cpus, $is_intel_cpu, $core_types;
$loop = floor(($total-1)/32) + 1;
$text = [];
for ($c = 0; $c < $loop; $c++) {
$max = ($c == $loop-1 ? ($total % 32 ?: 32) : 32);
for ($n = 0; $n < $max; $n++) {
[$cpu1, $cpu2] = my_preg_split('/[,-]/', $cpus[$c * 32 + $n]);
if (empty($text[$n])) $text[$n] = '';
$text[$n] .= "$cpu1
";
if ($cpu2) $text[$n] .= "$cpu2
";
}
}
$label = implode('
', array_fill(0, $loop, 'CORES:' . ($cpu2 ? '
CORES:' : '')));
if ($type == "vm") echo "VCPUS | ";
echo "$label | " . implode(array_map(function($t) {
global $is_intel_cpu, $core_types;
[$cpu1, $cpu2] = my_preg_split('/[,
]/',$t);
if ($is_intel_cpu && count($core_types) > 0) $core_type = "$core_types[$cpu1]"; else $core_type = "";
return "$t | ";
}, $text));
}
?>
_(No CPU pinning available. VM service must be started)_
:cpu_vms_help: