tart create --linux: allow scaling VM down to 1 CPU and 256 MiB (#693)

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

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

This reverts commit 7a31443eea.

* Check minimum CPU and memory sizes in "tart set"
This commit is contained in:
Nikolay Edigaryev 2024-01-03 19:48:13 +04:00 committed by GitHub
parent 36c54d95cb
commit 1a267d4a39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -132,20 +132,30 @@ struct VMConfig: Codable {
}
mutating func setCPU(cpuCount: Int) throws {
if cpuCount < cpuCountMin {
if os == .darwin && cpuCount < cpuCountMin {
throw LessThanMinimalResourcesError("VM should have \(cpuCountMin) CPU cores"
+ " at minimum (requested \(cpuCount))")
}
if cpuCount < VZVirtualMachineConfiguration.minimumAllowedCPUCount {
throw LessThanMinimalResourcesError("VM should have \(VZVirtualMachineConfiguration.minimumAllowedCPUCount) CPU cores"
+ " at minimum (requested \(cpuCount))")
}
self.cpuCount = cpuCount
}
mutating func setMemory(memorySize: UInt64) throws {
if memorySize < memorySizeMin {
if os == .darwin && memorySize < memorySizeMin {
throw LessThanMinimalResourcesError("VM should have \(memorySizeMin) bytes"
+ " of memory at minimum (requested \(memorySize))")
}
if memorySize < VZVirtualMachineConfiguration.minimumAllowedMemorySize {
throw LessThanMinimalResourcesError("VM should have \(VZVirtualMachineConfiguration.minimumAllowedMemorySize) bytes"
+ " of memory at minimum (requested \(memorySize))")
}
self.memorySize = memorySize
}
}