From 02321efa6250580c4842336e9d0b3ff848b883ca Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Thu, 26 Mar 2026 14:37:30 +0100 Subject: [PATCH] vmm: migration: cleanup - replace error match with map_err On-behalf-of: SAP philipp.schuster@sap.com Signed-off-by: Philipp Schuster --- vmm/src/lib.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index c27b67dcd8..5a76b7de4b 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -4349,26 +4349,24 @@ impl RequestHandler for Vmm { } // When spawning the thread fails, the VM keeps running normally. - let migration_worker = match MigrationWorker::spawn( + let migration_worker = MigrationWorker::spawn( vm, self.check_migration_evt.try_clone().unwrap(), send_data_migration, self.postponed_lifecycle_event.clone(), #[cfg(all(feature = "kvm", target_arch = "x86_64"))] self.hypervisor.clone(), - ) { - Ok(worker) => worker, - Err((vm, e)) => { - self.vm = MaybeVmOwnership::Vmm(vm); + ) + .map_err(|(vm, e)| { + self.vm = MaybeVmOwnership::Vmm(vm); - let mut lock = MIGRATION_PROGRESS_SNAPSHOT.lock().unwrap(); - lock.as_mut() - .expect("live migration should be ongoing") - .mark_as_failed(&e); + let mut lock = MIGRATION_PROGRESS_SNAPSHOT.lock().unwrap(); + lock.as_mut() + .expect("live migration should be ongoing") + .mark_as_failed(&e); - return Err(e); - } - }; + e + })?; let old = self.migration_thread_handle.replace(migration_worker); // If this fails, we messed up the thread lifecycle management. debug_assert!(old.is_none());