Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions vminitd/Sources/vminitd/ManagedProcess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ import Logging
import Synchronization

final class ManagedProcess: Sendable {
let id: String

private let log: Logger
private let command: Command
private let state: Mutex<State>
private let owningPid: Int32?
private let ackPipe: Pipe
private let syncPipe: Pipe
private let terminal: Bool
private let bundle: ContainerizationOCI.Bundle
private let cgroupManager: Cgroup2Manager?
// swiftlint: disable type_name
protocol IO {
func attach(pid: Int32, fd: Int32) throws
func start(process: inout Command) throws
func resize(size: Terminal.Size) throws
func close() throws
func closeStdin() throws
func closeAfterExec() throws
}
// swiftlint: enable type_name

struct ExitStatus {
var exitStatus: Int32
Expand All @@ -53,26 +52,27 @@ final class ManagedProcess: Sendable {
var pid: Int32 = 0
}

private static let ackPid = "AckPid"
private static let ackConsole = "AckConsole"

let id: String

private let log: Logger
private let command: Command
private let state: Mutex<State>
private let owningPid: Int32?
private let ackPipe: Pipe
private let syncPipe: Pipe
private let terminal: Bool
private let bundle: ContainerizationOCI.Bundle
private let cgroupManager: Cgroup2Manager?

var pid: Int32 {
self.state.withLock {
$0.pid
}
}

// swiftlint: disable type_name
protocol IO {
func attach(pid: Int32, fd: Int32) throws
func start(process: inout Command) throws
func resize(size: Terminal.Size) throws
func close() throws
func closeStdin() throws
func closeAfterExec() throws
}
// swiftlint: enable type_name

private static let ackPid = "AckPid"
private static let ackConsole = "AckConsole"

init(
id: String,
stdio: HostStdio,
Expand Down
4 changes: 2 additions & 2 deletions vminitd/Sources/vminitd/OSFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import Foundation

struct OSFile: Sendable {
private let fd: Int32

enum IOAction: Equatable {
case eof
case again
Expand All @@ -27,6 +25,8 @@ struct OSFile: Sendable {
case error(_ errno: Int32)
}

private let fd: Int32

var closed: Bool {
Foundation.fcntl(fd, F_GETFD) == -1 && errno == EBADF
}
Expand Down
8 changes: 4 additions & 4 deletions vminitd/Sources/vminitd/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import NIOCore
import NIOPosix

final class Initd: Sendable {
let log: Logger
let state: State
let group: EventLoopGroup

actor State {
var containers: [String: ManagedContainer] = [:]
var proxies: [String: VsockProxy] = [:]
Expand Down Expand Up @@ -80,6 +76,10 @@ final class Initd: Sendable {
}
}

let log: Logger
let state: State
let group: EventLoopGroup

init(log: Logger, group: EventLoopGroup) {
self.log = log
self.group = group
Expand Down
20 changes: 10 additions & 10 deletions vminitd/Sources/vminitd/VsockProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ actor VsockProxy {
case vsock
}

public let id: String
private let path: URL
private let action: Action
private let port: UInt32
private let udsPerms: UInt32?
private let log: Logger?

private var listener: Socket?
private var task: Task<(), Never>?

init(
id: String,
action: Action,
Expand All @@ -45,16 +55,6 @@ actor VsockProxy {
self.udsPerms = udsPerms
self.log = log
}

public let id: String
private let path: URL
private let action: Action
private let port: UInt32
private let udsPerms: UInt32?
private let log: Logger?

private var listener: Socket?
private var task: Task<(), Never>?
}

extension VsockProxy {
Expand Down