vminitd: Rename CgroupManager -> Cgroup2Manager (#266)

To be more explicit.
This commit is contained in:
Danny Canter
2025-08-13 20:16:03 -04:00
committed by GitHub
parent 79e07b43ce
commit 531ccd6205
3 changed files with 9 additions and 9 deletions
+5 -5
View File
@@ -19,7 +19,7 @@ import Foundation
import Logging
import Musl
enum CgroupController: String {
enum Cgroup2Controller: String {
case pids
case memory
case cpuset
@@ -30,7 +30,7 @@ enum CgroupController: String {
// Extremely simple cgroup manager. Our needs are simple for now, and this is
// reflected in the type.
internal struct CgroupManager {
internal struct Cgroup2Manager {
static let defaultMountPoint = URL(filePath: "/sys/fs/cgroup")
static let killFile = "cgroup.kill"
@@ -71,7 +71,7 @@ internal struct CgroupManager {
if fd == -1 {
throw Error.errno(errno: errno, message: "failed to open \(file.path)")
}
defer { Musl.close(fd) }
defer { close(fd) }
let bytes = Array(value.utf8)
let res = Syscall.retrying {
@@ -82,7 +82,7 @@ internal struct CgroupManager {
}
}
func toggleSubtreeControllers(controllers: [CgroupController], enable: Bool) throws {
func toggleSubtreeControllers(controllers: [Cgroup2Controller], enable: Bool) throws {
let value = controllers.map { (enable ? "+" : "-") + $0.rawValue }.joined(separator: " ")
let mountComponents = self.mountPoint.pathComponents
let pathComponents = self.path.pathComponents
@@ -134,7 +134,7 @@ internal struct CgroupManager {
}
}
extension CgroupManager {
extension Cgroup2Manager {
enum Error: Swift.Error, CustomStringConvertible {
case errno(errno: Int32, message: String)
@@ -24,7 +24,7 @@ actor ManagedContainer {
let id: String
let initProcess: ManagedProcess
private let cgroupManager: CgroupManager
private let cgroupManager: Cgroup2Manager
private let log: Logger
private let bundle: ContainerizationOCI.Bundle
private var execs: [String: ManagedProcess] = [:]
@@ -52,7 +52,7 @@ actor ManagedContainer {
cgroupsPath = "/container/\(id)"
}
let cgManager = try CgroupManager(
let cgManager = try Cgroup2Manager(
path: URL(filePath: cgroupsPath),
logger: log
)
+2 -2
View File
@@ -34,7 +34,7 @@ final class ManagedProcess: Sendable {
private let syncPipe: FileHandle
private let terminal: Bool
private let bundle: ContainerizationOCI.Bundle
private let cgroupManager: CgroupManager
private let cgroupManager: Cgroup2Manager
private struct State {
init(io: IO) {
@@ -75,7 +75,7 @@ final class ManagedProcess: Sendable {
id: String,
stdio: HostStdio,
bundle: ContainerizationOCI.Bundle,
cgroupManager: CgroupManager,
cgroupManager: Cgroup2Manager,
owningPid: Int32? = nil,
log: Logger
) throws {