-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Milestone
Description
Creating VM using Apple backend , will result in Linux (operating system) VM by default, which is fine.
However, the field Boot->Operating System is not exposed to config , which means we cannot update the the OS field in Boot section to macOS and hence we will not be able to create a macOS VM via script.
Default VM creation issue
let config = UTMAppleConfiguration()
// Creates Linux VM by default
config.system.boot = try UTMAppleConfigurationBoot(for: .linux)
// But the config.system.boot is not exposed in config to be updated, Hence you cannot create macOS VM via script
Originally requested in naveenrajm7/packer-plugin-utm#12
Suggested Fix:
// Get os via config record
guard let osString = record["operatingSystem"] as? String else {
throw ScriptingError.osNotSpecified
}
let config = UTMAppleConfiguration()
// validate os. Creating MacOS requires you to have a valid ipsw file, so enforce it
switch osString {
case "macos":
guard let ipswURL = record["ipsw"] as? URL else {
throw ScriptingError.ipswNotSpecified
}
let image = try await VZMacOSRestoreImage.image(from: ipswURL)
guard let model = image.mostFeaturefulSupportedConfiguration?.hardwareModel else {
throw ScriptingError.ipswNotSupported
}
config.system.macPlatform = UTMAppleConfigurationMacPlatform(newHardware: model)
config.system.boot = try UTMAppleConfigurationBoot(for: .macOS)
config.system.boot.macRecoveryIpswURL = ipswURL
case "linux":
config.system.boot = try UTMAppleConfigurationBoot(for: .linux)
default:
throw ScriptingError.osNotSupported
}
davidvasandani
Metadata
Metadata
Assignees
Labels
No labels