tart create --linux: allow scaling VM down to 1 CPU and 256 MiB

This commit is contained in:
Nikolay Edigaryev 2024-01-03 17:01:07 +04:00
parent 36c54d95cb
commit 7a31443eea
2 changed files with 17 additions and 3 deletions

View File

@ -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)

View File

@ -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 {