@@ -64,6 +64,34 @@ public final class LinuxContainer: Container, Sendable {
6464 public var bootlog : URL ?
6565
6666 public init ( ) { }
67+
68+ public init (
69+ process: LinuxProcessConfiguration ,
70+ cpus: Int = 4 ,
71+ memoryInBytes: UInt64 = 1024 . mib ( ) ,
72+ hostname: String = " " ,
73+ sysctl: [ String : String ] = [ : ] ,
74+ interfaces: [ any Interface ] = [ ] ,
75+ sockets: [ UnixSocketConfiguration ] = [ ] ,
76+ mounts: [ Mount ] = LinuxContainer . defaultMounts ( ) ,
77+ dns: DNS ? = nil ,
78+ hosts: Hosts ? = nil ,
79+ virtualization: Bool = false ,
80+ bootlog: URL ? = nil
81+ ) {
82+ self . process = process
83+ self . cpus = cpus
84+ self . memoryInBytes = memoryInBytes
85+ self . hostname = hostname
86+ self . sysctl = sysctl
87+ self . interfaces = interfaces
88+ self . sockets = sockets
89+ self . mounts = mounts
90+ self . dns = dns
91+ self . hosts = hosts
92+ self . virtualization = virtualization
93+ self . bootlog = bootlog
94+ }
6795 }
6896
6997 private let state : AsyncMutex < State >
@@ -189,10 +217,14 @@ public final class LinuxContainer: Container, Sendable {
189217 private let vmm : VirtualMachineManager
190218 private let logger : Logger ?
191219
192- /// Create a new `LinuxContainer`. A `Mount` that contains the contents
193- /// of the container image must be provided, as well as a `VirtualMachineManager`
194- /// instance that will handle launching the virtual machine the container will
195- /// execute inside of.
220+ /// Create a new `LinuxContainer`.
221+ ///
222+ /// - Parameters:
223+ /// - id: The identifier for the container.
224+ /// - rootfs: The root filesystem mount containing the container image contents.
225+ /// - vmm: The virtual machine manager that will handle launching the VM for the container.
226+ /// - logger: Optional logger for container operations.
227+ /// - configuration: A closure that configures the container by modifying the Configuration instance.
196228 public init (
197229 _ id: String ,
198230 rootfs: Mount ,
@@ -214,6 +246,32 @@ public final class LinuxContainer: Container, Sendable {
214246 self . state = AsyncMutex ( . initialized)
215247 }
216248
249+ /// Create a new `LinuxContainer`.
250+ ///
251+ /// - Parameters:
252+ /// - id: The identifier for the container.
253+ /// - rootfs: The root filesystem mount containing the container image contents.
254+ /// - vmm: The virtual machine manager that will handle launching the VM for the container.
255+ /// - configuration: The container configuration specifying process, resources, networking, and other settings.
256+ /// - logger: Optional logger for container operations.
257+ public init (
258+ _ id: String ,
259+ rootfs: Mount ,
260+ vmm: VirtualMachineManager ,
261+ configuration: LinuxContainer . Configuration ,
262+ logger: Logger ? = nil
263+ ) {
264+ self . id = id
265+ self . vmm = vmm
266+ self . hostVsockPorts = Atomic < UInt32 > ( 0x1000_0000 )
267+ self . guestVsockPorts = Atomic < UInt32 > ( 0x1000_0000 )
268+ self . rootfs = rootfs
269+ self . logger = logger
270+
271+ self . config = configuration
272+ self . state = AsyncMutex ( . initialized)
273+ }
274+
217275 private static func createDefaultRuntimeSpec( _ id: String ) -> Spec {
218276 . init(
219277 process: . init( ) ,
0 commit comments