Skip to content

Commit

Permalink
tart run: deprecate --with-softnet and introduce --net-softnet (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
edigaryev authored Oct 14, 2022
1 parent afd707e commit 36bb68a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Sources/tart/Commands/Run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ struct Run: AsyncParsableCommand {
+ "Note that this feature is experimental and there may be bugs present when using VNC."))
var vncExperimental: Bool = false

@Flag var withSoftnet: Bool = false
@Flag(help: ArgumentHelp(visibility: .private))
var withSoftnet: Bool = false

@Option(help: ArgumentHelp("""
Additional disk attachments with an optional read-only specifier\n(e.g. --disk=\"disk.bin\" --disk=\"ubuntu.iso:ro\")
Expand All @@ -64,6 +65,10 @@ struct Run: AsyncParsableCommand {
""", valueName: "interface name"))
var netBridged: String?

@Flag(help: ArgumentHelp("Use software networking instead of the default shared (NAT) networking",
discussion: "Learn how to configure Softnet for use with Tart here: https://github.com/cirruslabs/softnet"))
var netSoftnet: Bool = false

func validate() throws {
if vnc && vncExperimental {
throw ValidationError("--vnc and --vnc-experimental are mutually exclusive")
Expand All @@ -73,6 +78,10 @@ struct Run: AsyncParsableCommand {
throw ValidationError("--with-softnet and --net-bridged are mutually exclusive")
}

if netBridged != nil && netSoftnet {
throw ValidationError("--net-bridged and --net-softnet are mutually exclusive")
}

if graphics && noGraphics {
throw ValidationError("--graphics and --no-graphics are mutually exclusive")
}
Expand Down Expand Up @@ -145,7 +154,7 @@ struct Run: AsyncParsableCommand {
}

func userSpecifiedNetwork(vmDir: VMDirectory) throws -> Network? {
if withSoftnet {
if withSoftnet || netSoftnet {
let config = try VMConfig.init(fromURL: vmDir.configURL)

return try Softnet(vmMACAddress: config.macAddress.string)
Expand Down

0 comments on commit 36bb68a

Please sign in to comment.