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);
function create() {
// create the table header. Make multiple rows when CPU cores are many ;)
global $total,$cpus;
$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,'CPU:'.($cpu2 ? '
HT:':'')));
echo "$label | ".implode(array_map(function($t){return "$t | ";},$text));
}
?>
_(No CPU pinning available. VM service must be started)_
:cpu_vms_help: