cvmts: Only target QEMU vCPU threads by default

Previous behaviour was to limit the whole QEMU process; this only limits the vCPU threads. A bit (very) hacky how I did this but it does work.
This commit is contained in:
modeco80
2024-11-02 07:46:59 -04:00
parent 4344b233bc
commit 86f1345a2d
4 changed files with 47 additions and 9 deletions

View File

@@ -29,6 +29,7 @@ export class CGroup {
// Configure this "root" cgroup to provide cpu and cpuset controllers to the leaf
// QEMU cgroups. A bit iffy but whatever.
writeFileSync(path.join(this.path, 'cgroup.subtree_control'), '+cpu +cpuset');
//writeFileSync(path.join(this.path, 'cgroup.subtree_control'), '+cpu');
}
GetController(controller: string) {
@@ -63,6 +64,11 @@ export class CGroup {
appendFileSync(path.join(this.path, 'cgroup.procs'), pid.toString());
}
// Attaches a thread to this cgroup. (The CGroup is a threaded one. See above)
AttachThread(tid: number) {
appendFileSync(path.join(this.path, 'cgroup.threads'), tid.toString());
}
// Returns a CGroup instance for the process' current cgroup, prepared for subgroup usage.
// This will only fail if you are not using systemd or elogind,
// since even logind user sessions are run inside of a user@[UID] slice.