Signed-off-by: Daniel Bowder <[email protected]>
---
The second patch adds a utility function to obtain the pid of the VM, then
calls taskset on that pid with the cpuset in the qm conf. This execution of
taskset pins the VMs process to the defined cpu cores. This utility function
acts similarly to the exec_hookscript utility function. In fact, in the third
patch this utility function will be called just after the "post-start" call to
hookscript.
src/PVE/GuestHelpers.pm | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/PVE/GuestHelpers.pm b/src/PVE/GuestHelpers.pm
index 0fe3fd6..a8f54fa 100644
--- a/src/PVE/GuestHelpers.pm
+++ b/src/PVE/GuestHelpers.pm
@@ -82,6 +82,30 @@ sub guest_migration_lock {
return $res;
}
+sub exec_taskset {
+ my ($conf, $vmid) = @_;
+
+ return if !$conf->{cpuset};
+
+ eval {
+ # Obtain the vm PID from /run/qemu-server/$vmid.pid
+ PVE::Tools::run_command(
+ [ "cat", "/run/qemu-server/$vmid.pid" ],
+ outfunc => sub {
+ my $line = shift;
+ if ($line =~ m/^([0-9]+)$/) {
+ # Pin the PID to the cpuset
+ PVE::Tools::run_command(
+ [ "taskset", "--cpu-list",
"--all-tasks", "--pid", $conf->{cpuset}, $1 ]
+ );
+ } else {
+ warn "cpuset error: failed to obtain vm
process id.\n";
+ }
+ }
+ );
+ };
+}
+
sub check_hookscript {
my ($volid, $storecfg) = @_;
--
2.30.2
_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel