vmm: add helper to measure successful operation duration

Add a small helper that returns both the successful result of an
operation and the time it took to complete.

Subsequent migration instrumentation uses this to keep timing code
compact and consistent.

On-behalf-of: SAP philipp.schuster@sap.com
Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
This commit is contained in:
Philipp Schuster
2026-04-09 09:32:14 +02:00
committed by Rob Bradford
parent 6a3024c13d
commit f32506447f

View File

@@ -563,6 +563,17 @@ pub fn start_vmm_thread(
})
}
/// Measures the time of the callback, in case it returns `Ok`.
fn measure_ok<T, E, F>(f: F) -> result::Result<(T, Duration), E>
where
F: FnOnce() -> result::Result<T, E>,
{
let begin = Instant::now();
let value = f()?;
let duration = begin.elapsed();
Ok((value, duration))
}
#[derive(Clone, Deserialize, Serialize)]
struct VmMigrationConfig {
vm_config: Arc<Mutex<VmConfig>>,