From 2c478995a30cf8becd8f5e451e5ec7cbaba29020 Mon Sep 17 00:00:00 2001 From: Danny Canter Date: Mon, 5 Jan 2026 02:31:59 -0800 Subject: [PATCH] vmexec: Remove the logger setup We can't write to stderr because it may be the containers stderr, so this is mostly dead code. We should think about how to do logging from here as there's a couple spots it'd be nice. --- vminitd/Sources/vmexec/ExecCommand.swift | 12 +++--------- vminitd/Sources/vmexec/RunCommand.swift | 14 +++++--------- vminitd/Sources/vmexec/vmexec.swift | 11 +---------- 3 files changed, 9 insertions(+), 28 deletions(-) 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 {