diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 4db263a..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index f3b5f7c..ec9d7e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Mac junk +.DS_Store + # Xcode # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore diff --git a/virtual/VirtualCommandRun.swift b/virtual/VirtualCommandRun.swift index bb3b65e..8a1f46e 100644 --- a/virtual/VirtualCommandRun.swift +++ b/virtual/VirtualCommandRun.swift @@ -36,6 +36,10 @@ struct VirtualCommandRun: ParsableCommand { @Flag(name: .shortAndLong, help: "Enable NAT Networking") var network: Bool = false + // if not specified, will generate at random + @Option(name: [.customShort("a"), .long], help: "MAC Address") + var macaddr: String = "" + @Flag(name: .long, help: "Show Version Information") var version: Bool = false diff --git a/virtual/VirtualSystem.swift b/virtual/VirtualSystem.swift index 059cb3d..1ede56d 100644 --- a/virtual/VirtualSystem.swift +++ b/virtual/VirtualSystem.swift @@ -40,7 +40,7 @@ class VirtualSystem: NSObject, VZVirtualMachineDelegate { var storage: [VZStorageDeviceConfiguration] = [] if !command.disk.isEmpty { for disk in command.disk { - let blockAttachment = try VZDiskImageStorageDeviceAttachment(url: URL(fileURLWithPath: disk).absoluteURL, readOnly: true) + let blockAttachment = try VZDiskImageStorageDeviceAttachment(url: URL(fileURLWithPath: disk).absoluteURL, readOnly: false) let blockDevice = VZVirtioBlockDeviceConfiguration(attachment: blockAttachment) storage.append(blockDevice) } @@ -50,6 +50,13 @@ class VirtualSystem: NSObject, VZVirtualMachineDelegate { if command.network { let networkDevice = VZVirtioNetworkDeviceConfiguration() + if !command.macaddr.isEmpty { + if let macAddress = VZMACAddress(string: command.macaddr) { + networkDevice.macAddress = macAddress + } else { + NSLog("Ignoring MAC Address: was not in acceptable format e.g. 01:23:45:ab:cd:ef") + } + } networkDevice.attachment = VZNATNetworkDeviceAttachment() network.append(networkDevice) }