mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
downtime: add downtime support
add downtime support in `resume_all_vcpus_with_downtime` Signed-off-by: Chao Wu <chaowu@linux.alibaba.com>
This commit is contained in:
parent
6a1fe85f10
commit
5d3b53ee7b
@ -54,6 +54,8 @@ pub struct InstanceInfo {
|
||||
pub async_state: AsyncState,
|
||||
/// List of tids of vcpu threads (vcpu index, tid)
|
||||
pub tids: Vec<(u8, u32)>,
|
||||
/// Last instance downtime
|
||||
pub last_instance_downtime: u64,
|
||||
}
|
||||
|
||||
impl InstanceInfo {
|
||||
@ -66,6 +68,7 @@ impl InstanceInfo {
|
||||
pid: std::process::id(),
|
||||
async_state: AsyncState::Uninitialized,
|
||||
tids: Vec::new(),
|
||||
last_instance_downtime: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,6 +82,7 @@ impl Default for InstanceInfo {
|
||||
pid: std::process::id(),
|
||||
async_state: AsyncState::Uninitialized,
|
||||
tids: Vec::new(),
|
||||
last_instance_downtime: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -420,6 +420,18 @@ impl Vm {
|
||||
pub fn resume_all_vcpus_with_downtime(&mut self) -> std::result::Result<(), VcpuManagerError> {
|
||||
self.vcpu_manager()?.resume_all_vcpus()?;
|
||||
|
||||
if self.start_instance_downtime != 0 {
|
||||
let now = TimestampUs::default();
|
||||
let downtime = now.time_us - self.start_instance_downtime;
|
||||
info!(self.logger, "VM: instance downtime: {} us", downtime);
|
||||
self.start_instance_downtime = 0;
|
||||
if let Ok(mut info) = self.shared_info.write() {
|
||||
info.last_instance_downtime = downtime;
|
||||
} else {
|
||||
error!(self.logger, "Failed to update live upgrade downtime, couldn't be written due to poisoned lock");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user