diff --git a/Sources/tart/VM.swift b/Sources/tart/VM.swift index 149bb0c..30b95c0 100644 --- a/Sources/tart/VM.swift +++ b/Sources/tart/VM.swift @@ -223,7 +223,7 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject { try vmDir.resizeDisk(diskSizeGB) // Create config - let config = VMConfig(platform: Linux(), cpuCountMin: 4, memorySizeMin: 4096 * 1024 * 1024) + let config = VMConfig(platform: Linux(), cpuCountMin: 1, cpuCount: 4, memorySizeMin: 256 * 1024 * 1024, memorySize: 4096 * 1024 * 1024) try config.save(toURL: vmDir.configURL) return try VM(vmDir: vmDir) diff --git a/Sources/tart/VMConfig.swift b/Sources/tart/VMConfig.swift index 0ff2480..86a069f 100644 --- a/Sources/tart/VMConfig.swift +++ b/Sources/tart/VMConfig.swift @@ -58,15 +58,29 @@ struct VMConfig: Codable { cpuCountMin: Int, memorySizeMin: UInt64, macAddress: VZMACAddress = VZMACAddress.randomLocallyAdministered() + ) { + self.init(platform: platform, + cpuCountMin: cpuCountMin, cpuCount: cpuCountMin, + memorySizeMin: memorySizeMin, memorySize: memorySizeMin, + macAddress: macAddress) + } + + init( + platform: Platform, + cpuCountMin: Int, + cpuCount: Int, + memorySizeMin: UInt64, + memorySize: UInt64, + macAddress: VZMACAddress = VZMACAddress.randomLocallyAdministered() ) { self.os = platform.os() self.arch = CurrentArchitecture() self.platform = platform self.macAddress = macAddress self.cpuCountMin = cpuCountMin + self.cpuCount = cpuCount self.memorySizeMin = memorySizeMin - cpuCount = cpuCountMin - memorySize = memorySizeMin + self.memorySize = memorySize } init(fromJSON: Data) throws {