mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
vmm: Use event!() for some key VM actions
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
4822ed79e1
commit
9260c4c10e
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1614,6 +1614,7 @@ dependencies = [
|
||||
"credibility",
|
||||
"devices",
|
||||
"epoll",
|
||||
"event_monitor",
|
||||
"hypervisor",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
|
@ -23,6 +23,7 @@ block_util = { path = "../block_util" }
|
||||
clap = "2.33.3"
|
||||
devices = { path = "../devices" }
|
||||
epoll = ">=4.0.1"
|
||||
event_monitor = { path = "../event_monitor" }
|
||||
hypervisor = { path = "../hypervisor" }
|
||||
lazy_static = "1.4.0"
|
||||
libc = "0.2.86"
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
extern crate anyhow;
|
||||
extern crate arc_swap;
|
||||
#[macro_use]
|
||||
extern crate event_monitor;
|
||||
extern crate hypervisor;
|
||||
extern crate option_parser;
|
||||
#[macro_use]
|
||||
@ -555,11 +557,15 @@ impl Vmm {
|
||||
|
||||
self.vm_config = None;
|
||||
|
||||
event!("vm", "deleted");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn vmm_shutdown(&mut self) -> result::Result<(), VmError> {
|
||||
self.vm_delete()
|
||||
self.vm_delete()?;
|
||||
event!("vmm", "shutdown");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn vm_resize(
|
||||
|
@ -1115,6 +1115,8 @@ impl Vm {
|
||||
}
|
||||
*state = new_state;
|
||||
|
||||
event!("vm", "shutdown");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -1124,6 +1126,8 @@ impl Vm {
|
||||
desired_memory: Option<u64>,
|
||||
desired_balloon: Option<u64>,
|
||||
) -> Result<()> {
|
||||
event!("vm", "resizing");
|
||||
|
||||
if let Some(desired_vcpus) = desired_vcpus {
|
||||
if self
|
||||
.cpu_manager
|
||||
@ -1199,6 +1203,8 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
event!("vm", "resized");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -1485,6 +1491,7 @@ impl Vm {
|
||||
}
|
||||
|
||||
pub fn boot(&mut self) -> Result<()> {
|
||||
event!("vm", "booting");
|
||||
let current_state = self.get_state()?;
|
||||
if current_state == VmState::Paused {
|
||||
return self.resume().map_err(Error::Resume);
|
||||
@ -1556,7 +1563,7 @@ impl Vm {
|
||||
|
||||
let mut state = self.state.try_write().map_err(|_| Error::PoisonedState)?;
|
||||
*state = new_state;
|
||||
|
||||
event!("vm", "booted");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -1825,6 +1832,7 @@ impl Vm {
|
||||
|
||||
impl Pausable for Vm {
|
||||
fn pause(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
event!("vm", "pausing");
|
||||
let mut state = self
|
||||
.state
|
||||
.try_write()
|
||||
@ -1850,10 +1858,12 @@ impl Pausable for Vm {
|
||||
|
||||
*state = new_state;
|
||||
|
||||
event!("vm", "paused");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn resume(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
event!("vm", "resuming");
|
||||
let mut state = self
|
||||
.state
|
||||
.try_write()
|
||||
@ -1877,7 +1887,7 @@ impl Pausable for Vm {
|
||||
|
||||
// And we're back to the Running state.
|
||||
*state = new_state;
|
||||
|
||||
event!("vm", "resumed");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -1897,6 +1907,8 @@ impl Snapshottable for Vm {
|
||||
}
|
||||
|
||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||
event!("vm", "snapshotting");
|
||||
|
||||
let current_state = self.get_state().unwrap();
|
||||
if current_state != VmState::Paused {
|
||||
return Err(MigratableError::Snapshot(anyhow!(
|
||||
@ -1930,10 +1942,13 @@ impl Snapshottable for Vm {
|
||||
snapshot: vm_snapshot_data,
|
||||
});
|
||||
|
||||
event!("vm", "snapshotted");
|
||||
Ok(vm_snapshot)
|
||||
}
|
||||
|
||||
fn restore(&mut self, snapshot: Snapshot) -> std::result::Result<(), MigratableError> {
|
||||
event!("vm", "restoring");
|
||||
|
||||
let current_state = self
|
||||
.get_state()
|
||||
.map_err(|e| MigratableError::Restore(anyhow!("Could not get VM state: {:#?}", e)))?;
|
||||
@ -2053,6 +2068,8 @@ impl Snapshottable for Vm {
|
||||
.try_write()
|
||||
.map_err(|e| MigratableError::Restore(anyhow!("Could not set VM state: {:#?}", e)))?;
|
||||
*state = new_state;
|
||||
|
||||
event!("vm", "restored");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user