From 017592075fc044a7e588fdaf62e190d18162d909 Mon Sep 17 00:00:00 2001 From: Fedor Korotkov Date: Mon, 17 Jun 2024 08:20:21 -0700 Subject: [PATCH] Drop Monterey Support (#843) * Drop Monterey Support People will still be able to run and SSH into Monterey VMs or use VNC but pointing devices/keyboard won't work. Fixes #841 * Fixed x86 build --- Sources/tart/Commands/Run.swift | 2 +- Sources/tart/Platform/Darwin.swift | 22 ++++------------------ Sources/tart/Platform/Platform.swift | 5 ----- Sources/tart/VM.swift | 9 ++------- 4 files changed, 7 insertions(+), 31 deletions(-) diff --git a/Sources/tart/Commands/Run.swift b/Sources/tart/Commands/Run.swift index 7590c12..48bee2a 100644 --- a/Sources/tart/Commands/Run.swift +++ b/Sources/tart/Commands/Run.swift @@ -172,7 +172,7 @@ struct Run: AsyncParsableCommand { if suspendable { let config = try VMConfig.init(fromURL: vmDir.configURL) - if !(config.platform is PlatformSuspendable) { + if (config.platform is Linux) { throw ValidationError("You can only suspend macOS VMs") } if dir.count > 0 { diff --git a/Sources/tart/Platform/Darwin.swift b/Sources/tart/Platform/Darwin.swift index f765864..73d24cb 100644 --- a/Sources/tart/Platform/Darwin.swift +++ b/Sources/tart/Platform/Darwin.swift @@ -8,7 +8,7 @@ struct UnsupportedHostOSError: Error, CustomStringConvertible { #if arch(arm64) - struct Darwin: PlatformSuspendable { + struct Darwin: Platform { var ecid: VZMacMachineIdentifier var hardwareModel: VZMacHardwareModel @@ -103,32 +103,18 @@ struct UnsupportedHostOSError: Error, CustomStringConvertible { func keyboards() -> [VZKeyboardConfiguration] { if #available(macOS 14, *) { // Mac keyboard is only supported by guests starting with macOS Ventura - return [VZUSBKeyboardConfiguration(), VZMacKeyboardConfiguration()] + return [VZMacKeyboardConfiguration()] } else { return [VZUSBKeyboardConfiguration()] } } - func keyboardsSuspendable() -> [VZKeyboardConfiguration] { - if #available(macOS 14, *) { - return [VZMacKeyboardConfiguration()] - } else { - // fallback to the regular configuration - return keyboards() - } - } - func pointingDevices() -> [VZPointingDeviceConfiguration] { - // Trackpad is only supported by guests starting with macOS Ventura - [VZUSBScreenCoordinatePointingDeviceConfiguration(), VZMacTrackpadConfiguration()] - } - - func pointingDevicesSuspendable() -> [VZPointingDeviceConfiguration] { - if #available(macOS 14, *) { + if #available(macOS 13, *) { return [VZMacTrackpadConfiguration()] } else { // fallback to the regular configuration - return pointingDevices() + return [VZUSBScreenCoordinatePointingDeviceConfiguration()] } } } diff --git a/Sources/tart/Platform/Platform.swift b/Sources/tart/Platform/Platform.swift index e862781..9b8c04e 100644 --- a/Sources/tart/Platform/Platform.swift +++ b/Sources/tart/Platform/Platform.swift @@ -8,8 +8,3 @@ protocol Platform: Codable { func keyboards() -> [VZKeyboardConfiguration] func pointingDevices() -> [VZPointingDeviceConfiguration] } - -protocol PlatformSuspendable: Platform { - func pointingDevicesSuspendable() -> [VZPointingDeviceConfiguration] - func keyboardsSuspendable() -> [VZKeyboardConfiguration] -} diff --git a/Sources/tart/VM.swift b/Sources/tart/VM.swift index e55f343..5cdf5b5 100644 --- a/Sources/tart/VM.swift +++ b/Sources/tart/VM.swift @@ -323,13 +323,8 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject { } // Keyboard and mouse - if suspendable, let platformSuspendable = vmConfig.platform.self as? PlatformSuspendable { - configuration.keyboards = platformSuspendable.keyboardsSuspendable() - configuration.pointingDevices = platformSuspendable.pointingDevicesSuspendable() - } else { - configuration.keyboards = vmConfig.platform.keyboards() - configuration.pointingDevices = vmConfig.platform.pointingDevices() - } + configuration.keyboards = vmConfig.platform.keyboards() + configuration.pointingDevices = vmConfig.platform.pointingDevices() // Networking configuration.networkDevices = network.attachments().map {