Always provide a serial console (#346)

This commit is contained in:
Danny Canter
2025-10-23 14:32:56 -07:00
committed by GitHub
parent dc4284a149
commit ca657f5009
3 changed files with 24 additions and 0 deletions
@@ -265,8 +265,12 @@ extension VZVirtualMachineInstance.Configuration {
config.memorySize = self.memoryInBytes
config.entropyDevices = [VZVirtioEntropyDeviceConfiguration()]
config.socketDevices = [VZVirtioSocketDeviceConfiguration()]
if let bootlog = self.bootlog {
config.serialPorts = try serialPort(path: bootlog)
} else {
// We always supply a serial console. If no explicit path was provided just send em to the void.
config.serialPorts = try serialPort(path: URL(filePath: "/dev/null"))
}
config.networkDevices = try self.interfaces.map {
+19
View File
@@ -999,6 +999,25 @@ extension IntegrationSuite {
}
}
func testNoSerialConsole() async throws {
let id = "test-no-serial-console"
let bs = try await bootstrap(id)
let container = try LinuxContainer(id, rootfs: bs.rootfs, vmm: bs.vmm) { config in
config.process.arguments = ["/bin/true"]
}
try await container.create()
try await container.start()
let status = try await container.wait()
try await container.stop()
guard status.exitCode == 0 else {
throw IntegrationError.assert(msg: "process status \(status) != 0")
}
}
private func createMountDirectory() throws -> URL {
let dir = FileManager.default.uniqueTemporaryDirectory(create: true)
try "hello".write(to: dir.appendingPathComponent("hi.txt"), atomically: true, encoding: .utf8)
+1
View File
@@ -291,6 +291,7 @@ struct IntegrationSuite: AsyncParsableCommand {
Test("container /dev/console", testContainerDevConsole),
Test("container statistics", testContainerStatistics),
Test("container cgroup limits", testCgroupLimits),
Test("container no serial console", testNoSerialConsole),
// Pods
Test("pod single container", testPodSingleContainer),