diff --git a/vminitd/Sources/vmexec/ExecCommand.swift b/vminitd/Sources/vmexec/ExecCommand.swift index af80f8ca..701d82c6 100644 --- a/vminitd/Sources/vmexec/ExecCommand.swift +++ b/vminitd/Sources/vmexec/ExecCommand.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025 Apple Inc. and the Containerization project authors. +// Copyright © 2025-2026 Apple Inc. and the Containerization project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -36,16 +36,13 @@ struct ExecCommand: ParsableCommand { func run() throws { do { - LoggingSystem.bootstrap(App.standardError) - let log = Logger(label: "vmexec") - let src = URL(fileURLWithPath: processPath) let processBytes = try Data(contentsOf: src) let process = try JSONDecoder().decode( ContainerizationOCI.Process.self, from: processBytes ) - try execInNamespaces(process: process, log: log) + try execInNamespaces(process: process) } catch { App.writeError(error) throw error @@ -58,10 +55,7 @@ struct ExecCommand: ParsableCommand { } } - private func execInNamespaces( - process: ContainerizationOCI.Process, - log: Logger - ) throws { + private func execInNamespaces(process: ContainerizationOCI.Process) throws { let syncPipe = FileHandle(fileDescriptor: 3) let ackPipe = FileHandle(fileDescriptor: 4) diff --git a/vminitd/Sources/vmexec/RunCommand.swift b/vminitd/Sources/vmexec/RunCommand.swift index d6b1973b..ccd89fd2 100644 --- a/vminitd/Sources/vmexec/RunCommand.swift +++ b/vminitd/Sources/vmexec/RunCommand.swift @@ -34,9 +34,6 @@ struct RunCommand: ParsableCommand { mutating func run() throws { do { - LoggingSystem.bootstrap(App.standardError) - let log = Logger(label: "vmexec") - let spec: ContainerizationOCI.Spec do { let bundle = try ContainerizationOCI.Bundle.load(path: URL(filePath: bundlePath)) @@ -44,14 +41,14 @@ struct RunCommand: ParsableCommand { } catch { throw App.Failure(message: "failed to load OCI bundle at \(bundlePath): \(error)") } - try execInNamespace(spec: spec, log: log) + try execInNamespace(spec: spec) } catch { App.writeError(error) throw error } } - private func childRootSetup(rootfs: ContainerizationOCI.Root, mounts: [ContainerizationOCI.Mount], log: Logger) throws { + private func childRootSetup(rootfs: ContainerizationOCI.Root, mounts: [ContainerizationOCI.Mount]) throws { // setup rootfs try prepareRoot(rootfs: rootfs.path) try mountRootfs(rootfs: rootfs.path, mounts: mounts) @@ -90,7 +87,6 @@ struct RunCommand: ParsableCommand { spec: ContainerizationOCI.Spec, ackPipe: FileHandle, syncPipe: FileHandle, - log: Logger ) throws { guard let process = spec.process else { throw App.Failure(message: "no process configuration found in runtime spec") @@ -119,7 +115,7 @@ struct RunCommand: ParsableCommand { throw App.Errno(stage: "setsid()") } - try childRootSetup(rootfs: root, mounts: spec.mounts, log: log) + try childRootSetup(rootfs: root, mounts: spec.mounts) if process.terminal { let pty = try Console() @@ -223,7 +219,7 @@ struct RunCommand: ParsableCommand { return unshareFlags } - private func execInNamespace(spec: ContainerizationOCI.Spec, log: Logger) throws { + private func execInNamespace(spec: ContainerizationOCI.Spec) throws { let syncPipe = FileHandle(fileDescriptor: 3) let ackPipe = FileHandle(fileDescriptor: 4) @@ -241,7 +237,7 @@ struct RunCommand: ParsableCommand { } if processID == 0 { // child - try childSetup(spec: spec, ackPipe: ackPipe, syncPipe: syncPipe, log: log) + try childSetup(spec: spec, ackPipe: ackPipe, syncPipe: syncPipe) } else { // parent process // Setup cgroup before child enters cgroup namespace if let linux = spec.linux { diff --git a/vminitd/Sources/vmexec/vmexec.swift b/vminitd/Sources/vmexec/vmexec.swift index 0f70242c..3286d4e7 100644 --- a/vminitd/Sources/vmexec/vmexec.swift +++ b/vminitd/Sources/vmexec/vmexec.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025 Apple Inc. and the Containerization project authors. +// Copyright © 2025-2026 Apple Inc. and the Containerization project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -41,15 +41,6 @@ struct App: ParsableCommand { RunCommand.self, ] ) - - static let standardErrorLock = NSLock() - - @Sendable - static func standardError(label: String) -> StreamLogHandler { - standardErrorLock.withLock { - StreamLogHandler.standardError(label: label) - } - } } extension App {