mirror of
https://github.com/utmapp/UTM.git
synced 2026-10-11 21:59:56 +00:00
remote: fix list not showing when a single VM is unavailable
Fixes #6380
This commit is contained in:
@@ -73,6 +73,8 @@ fileprivate struct WrappedVMDetailsView: View {
|
||||
}
|
||||
#if os(macOS)
|
||||
.frame(width: 230)
|
||||
#else
|
||||
.padding()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -92,6 +94,8 @@ fileprivate struct UnsupportedVMDetailsView: View {
|
||||
}
|
||||
#if os(macOS)
|
||||
.frame(width: 230)
|
||||
#else
|
||||
.padding()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ extension VMRemoteDataError: LocalizedError {
|
||||
case .notImplemented:
|
||||
return NSLocalizedString("This function is not implemented.", comment: "VMData")
|
||||
case .backendNotSupported:
|
||||
return NSLocalizedString("This VM is configured for a backend that does not support remote clients.", comment: "VMData")
|
||||
return NSLocalizedString("This VM is not available or is configured for a backend that does not support remote clients.", comment: "VMData")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,13 +683,16 @@ extension UTMRemoteServer {
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func findVM(withId id: UUID) throws -> VMData {
|
||||
private func findVM(withId id: UUID, allowNotLoaded: Bool = false) throws -> VMData {
|
||||
let vm = data.virtualMachines.first(where: { $0.id == id })
|
||||
if let vm = vm, let _ = vm.wrapped {
|
||||
return vm
|
||||
} else {
|
||||
throw UTMRemoteServer.ServerError.notFound(id)
|
||||
if let vm = vm {
|
||||
if let _ = vm.wrapped {
|
||||
return vm
|
||||
} else if allowNotLoaded {
|
||||
return vm
|
||||
}
|
||||
}
|
||||
throw UTMRemoteServer.ServerError.notFound(id)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@@ -735,7 +738,7 @@ extension UTMRemoteServer {
|
||||
private func _getVirtualMachineInformation(parameters: M.GetVirtualMachineInformation.Request) async throws -> M.GetVirtualMachineInformation.Reply {
|
||||
let informations = try await Task { @MainActor in
|
||||
try parameters.ids.map { id in
|
||||
let vm = try findVM(withId: id)
|
||||
let vm = try findVM(withId: id, allowNotLoaded: true)
|
||||
let mountedDrives = vm.registryEntry?.externalDrives.mapValues({ $0.path }) ?? [:]
|
||||
let isTakeoverAllowed = data.vmWindows[vm] is VMRemoteSessionState && (vm.state == .started || vm.state == .paused)
|
||||
return M.VirtualMachineInformation(id: vm.id,
|
||||
|
||||
Reference in New Issue
Block a user