Skip to content

Commit

Permalink
config(qemu): fallback to TCG if hypervisor is not supported
Browse files Browse the repository at this point in the history
Resolves #4407
  • Loading branch information
osy committed Sep 16, 2022
1 parent 1d4ac30 commit 581b36d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
15 changes: 14 additions & 1 deletion Configuration/UTMQemuConfiguration+Arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,24 @@ import Foundation
#endif
}

private var supportsHypervisor: Bool {
guard jb_has_hypervisor() else {
return false
}
#if arch(arm64)
return system.architecture == .aarch64
#elseif arch(x86_64)
return system.architecture == .x86_64
#else
return false
#endif
}

@QEMUArgumentBuilder private var machineArguments: [QEMUArgument] {
f("-machine")
system.target
f(machineProperties)
if qemu.hasHypervisor {
if qemu.hasHypervisor && supportsHypervisor {
f("-accel")
f("hvf")
} else {
Expand Down
3 changes: 0 additions & 3 deletions Configuration/UTMQemuConfigurationQEMU.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ struct UTMQemuConfigurationQEMU: Codable {
debugLogURL = dataURL.appendingPathComponent(QEMUPackageFileName.debugLog.rawValue)
efiVarsURL = dataURL.appendingPathComponent(QEMUPackageFileName.efiVariables.rawValue)
}
if !jb_has_hypervisor() {
hasHypervisor = false
}
}

func encode(to encoder: Encoder) throws {
Expand Down
14 changes: 0 additions & 14 deletions Platform/Shared/VMConfigQEMUView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,6 @@ struct VMConfigQEMUView: View {
}
}

private var supportsHypervisor: Bool {
guard jb_has_hypervisor() else {
return false
}
#if arch(arm64)
return system.architecture == .aarch64
#elseif arch(x86_64)
return system.architecture == .x86_64
#else
return false
#endif
}

var body: some View {
VStack {
Form {
Expand All @@ -86,7 +73,6 @@ struct VMConfigQEMUView: View {
.help("This is required to boot Windows 11.")
#endif
Toggle("Use Hypervisor", isOn: $config.hasHypervisor)
.disabled(!supportsHypervisor)
.help("Only available if host architecture matches the target. Otherwise, TCG emulation is used.")
Toggle("Use local time for base clock", isOn: $config.hasRTCLocalTime)
.help("If checked, use local time for RTC which is required for Windows. Otherwise, use UTC clock.")
Expand Down

0 comments on commit 581b36d

Please sign in to comment.