From 2029a083db5ea93df9d5d5ed9c5a5e07ba3a9c1f Mon Sep 17 00:00:00 2001 From: James Curtis Date: Mon, 19 Aug 2024 09:03:47 +0000 Subject: [PATCH] Use BootTimer to measure hotplug latency Change the boot timer timestamp to be public, so that the timer can also be used for measuring hotplugging Signed-off-by: James Curtis --- src/vmm/src/devices/pseudo/boot_timer.rs | 2 +- src/vmm/src/lib.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vmm/src/devices/pseudo/boot_timer.rs b/src/vmm/src/devices/pseudo/boot_timer.rs index ba16e92355f..255ec6f2801 100644 --- a/src/vmm/src/devices/pseudo/boot_timer.rs +++ b/src/vmm/src/devices/pseudo/boot_timer.rs @@ -10,7 +10,7 @@ const MAGIC_VALUE_SIGNAL_GUEST_BOOT_COMPLETE: u8 = 123; /// Pseudo device to record the kernel boot time. #[derive(Debug)] pub struct BootTimer { - start_ts: TimestampUs, + pub start_ts: TimestampUs, } impl BootTimer { diff --git a/src/vmm/src/lib.rs b/src/vmm/src/lib.rs index 6d6445686a2..0d74bfd2276 100644 --- a/src/vmm/src/lib.rs +++ b/src/vmm/src/lib.rs @@ -683,6 +683,14 @@ impl Vmm { self.acpi_device_manager.notify_cpu_container()?; + #[cfg(test)] + if let Some(devices::BusDevice::BootTimer(timer)) = + self.get_bus_device(DeviceType::BootTimer, "BootTimer") + { + let mut locked_timer = timer.lock().expect("Poisoned lock"); + locked_timer.start_ts = utils::time::TimestampUs::default(); + } + Ok(new_machine_config) }