diff --git a/Managers/UTMVirtualMachine.swift b/Managers/UTMVirtualMachine.swift index 1f77d36b9..6f472aee4 100644 --- a/Managers/UTMVirtualMachine.swift +++ b/Managers/UTMVirtualMachine.swift @@ -110,11 +110,17 @@ extension UTMVirtualMachine: ObservableObject { } /// Called when we have a duplicate UUID - @MainActor func changeUuid(to uuid: UUID) { + @MainActor func changeUuid(to uuid: UUID, name: String? = nil) { if let qemuConfig = config.qemuConfig { qemuConfig.information.uuid = uuid + if let name = name { + qemuConfig.information.name = name + } } else if let appleConfig = config.appleConfig { appleConfig.information.uuid = uuid + if let name = name { + appleConfig.information.name = name + } } else { fatalError("Invalid configuration.") } diff --git a/Platform/UTMData.swift b/Platform/UTMData.swift index d00b40070..0d408e99d 100644 --- a/Platform/UTMData.swift +++ b/Platform/UTMData.swift @@ -460,8 +460,8 @@ class UTMData: ObservableObject { guard let newVM = UTMVirtualMachine(url: newPath) else { throw NSLocalizedString("Failed to clone VM.", comment: "UTMData") } - await vm.changeUuid(to: UUID()) - try await vm.saveUTM() + await newVM.changeUuid(to: UUID(), name: newName) + try await newVM.saveUTM() var index = await virtualMachines.firstIndex(of: vm) if index != nil { index! += 1