Skip to content

Commit

Permalink
config: reset CPU to default if not found
Browse files Browse the repository at this point in the history
QEMU sometimes removes CPU models. We handle this by defaulting to the
'default' CPU model when decoding the CPU model fails.

Fixes #4910
  • Loading branch information
osy committed Mar 3, 2023
1 parent b469a8b commit d1d2899
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Configuration/UTMQemuConfigurationSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ struct UTMQemuConfigurationSystem: Codable {
let values = try decoder.container(keyedBy: CodingKeys.self)
architecture = try values.decode(QEMUArchitecture.self, forKey: .architecture)
target = try values.decode(architecture.targetType, forKey: .target)
cpu = try values.decode(architecture.cpuType, forKey: .cpu)
do {
cpu = try values.decode(architecture.cpuType, forKey: .cpu)
} catch UTMConfigurationError.invalidConfigurationValue(let value) {
logger.warning("Unable to decode CPU '\(value)', resetting to default CPU")
cpu = architecture.cpuType.default
}
cpuFlagsAdd = try values.decode([AnyQEMUConstant].self, forKey: .cpuFlagsAdd)
cpuFlagsRemove = try values.decode([AnyQEMUConstant].self, forKey: .cpuFlagsRemove)
cpuCount = try values.decode(Int.self, forKey: .cpuCount)
Expand Down

0 comments on commit d1d2899

Please sign in to comment.