2
0
Эх сурвалжийг харах

vm(apple): support running from saved bookmark

osy 3 жил өмнө
parent
commit
753564cd3a

+ 5 - 1
Managers/UTMAppleVirtualMachine.swift

@@ -87,6 +87,10 @@ import Virtualization
     weak var screenshotDelegate: UTMScreenshotProvider?
     
     override static func isAppleVM(forPath path: URL) -> Bool {
+        _ = path.startAccessingSecurityScopedResource()
+        defer {
+            path.stopAccessingSecurityScopedResource()
+        }
         do {
             _ = try UTMAppleConfiguration.load(from: path)
             return true
@@ -136,7 +140,7 @@ import Virtualization
     }
     
     override func accessShortcut() async throws {
-        // FIXME: Apple VM doesn't support saving bookmarks
+        // not needed for Apple VMs
     }
     
     private func _vmStart() async throws {

+ 0 - 14
Platform/UTMData.swift

@@ -180,16 +180,7 @@ class UTMData: ObservableObject {
                     wrappedVM = UTMWrappedVirtualMachine(from: dict)
                 }
                 if let vm = wrappedVM?.unwrap() {
-                    #if os(macOS)
-                    // FIXME: we do not support Apple VM shortcuts because we cannot access the drives
-                    if let appleVM = vm as? UTMAppleVirtualMachine, appleVM.isShortcut {
-                        return nil
-                    } else {
-                        return vm
-                    }
-                    #else
                     return vm
-                    #endif
                 } else {
                     return wrappedVM
                 }
@@ -510,11 +501,6 @@ class UTMData: ObservableObject {
         if oldSelected == vm {
             await listSelect(vm: newVM)
         }
-        #if os(macOS)
-        if let _ = newVM as? UTMAppleVirtualMachine {
-            throw NSLocalizedString("Shortcuts to Apple virtual machines cannot be stored. You must open the .utm bundle from Finder each time UTM is launched.", comment: "UTMData")
-        }
-        #endif
     }
     
     /// Open settings modal