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