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
1 change: 0 additions & 1 deletion Sources/ContainerPlugin/PluginConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public struct PluginConfig: Sendable, Codable {
public let services: [Service]
/// An optional parameter that include any command line arguments
/// that must be passed to the plugin binary when it is loaded.
/// This parameter is used only when `servicesConfig.loadAtBoot` is `true`
public let defaultArguments: [String]
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ContainerPlugin/PluginLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ extension PluginLoader {

let plist = LaunchPlist(
label: id,
arguments: [plugin.binaryURL.path] + (args ?? serviceConfig.defaultArguments),
arguments: [plugin.binaryURL.path] + (args ?? ["start"]) + serviceConfig.defaultArguments,
environment: env,
limitLoadToSessionType: [.Aqua, .Background, .System],
runAtLoad: serviceConfig.runAtLoad,
Expand Down
35 changes: 30 additions & 5 deletions Sources/Helpers/NetworkVmnet/NetworkVmnetHelper+Start.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ import ContainerNetworkService
import ContainerNetworkServiceClient
import ContainerResource
import ContainerXPC
import ContainerizationError
import ContainerizationExtras
import Foundation
import Logging

enum Variant: String, ExpressibleByArgument {
case reserved
case allocationOnly
}

extension NetworkVmnetHelper {
struct Start: AsyncParsableCommand {
static let configuration = CommandConfiguration(
Expand All @@ -45,6 +51,14 @@ extension NetworkVmnetHelper {
@Option(name: .customLong("subnet-v6"), help: "CIDR address for the IPv6 prefix")
var ipv6Subnet: String?

@Option(name: .long, help: "Variant of the network helper to use.")
var variant: Variant = {
guard #available(macOS 26, *) else {
return .allocationOnly
}
return .reserved
}()

func run() async throws {
let commandName = NetworkVmnetHelper._commandName
let log = setupLogger(id: id, debug: debug)
Expand All @@ -63,7 +77,11 @@ extension NetworkVmnetHelper {
ipv4Subnet: ipv4Subnet,
ipv6Subnet: ipv6Subnet,
)
let network = try Self.createNetwork(configuration: configuration, log: log)
let network = try Self.createNetwork(
configuration: configuration,
variant: self.variant,
log: log
)
try await network.start()
let server = try await NetworkService(network: network, log: log)
let xpc = XPCServer(
Expand All @@ -86,12 +104,19 @@ extension NetworkVmnetHelper {
}
}

private static func createNetwork(configuration: NetworkConfiguration, log: Logger) throws -> Network {
guard #available(macOS 26, *) else {
private static func createNetwork(configuration: NetworkConfiguration, variant: Variant, log: Logger) throws -> Network {
switch variant {
case .allocationOnly:
return try AllocationOnlyVmnetNetwork(configuration: configuration, log: log)
case .reserved:
guard #available(macOS 26, *) else {
throw ContainerizationError(
.invalidArgument,
message: "variant ReservedVmnetNetwork is only available on macOS 26+"
)
}
return try ReservedVmnetNetwork(configuration: configuration, log: log)
}

return try ReservedVmnetNetwork(configuration: configuration, log: log)
}
}
}
2 changes: 1 addition & 1 deletion config/container-core-images-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"description": "Provide an XPC interface to interact with an image store."
}
],
"defaultArguments": ["start"]
"defaultArguments": []
}
}