cvmts: Delete cgroup on VM stop

Makes clean shutdown with systemd actually work.

I've also made superqemu version a SemVer thing so that we don't need to bump it as often, only on a major or minor bump.
This commit is contained in:
modeco80
2024-11-02 11:58:35 -04:00
parent a3581854d2
commit e7a06b7141
4 changed files with 27 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
// Cgroup management code
// this sucks, ill mess with it later
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { appendFileSync, existsSync, mkdirSync, readFileSync, rmdirSync, writeFileSync } from 'node:fs';
import path from 'node:path';
export class CGroupController {
@@ -46,6 +46,16 @@ export class CGroup {
return false;
}
DeleteSubgroup(name: string): void {
let subgroup_root = path.join(this.path, name);
if (!this.HasSubgroup(name)) {
throw new Error(`Subgroup ${name} does not exist`);
}
//console.log("Deleting subgroup", name);
rmdirSync(subgroup_root);
}
// Gets a CGroup inside of this cgroup.
GetSubgroup(name: string): CGroup {
// make the subgroup if it doesn't already exist