MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / vm_reboot

Method vm_reboot

vmm/src/lib.rs:2007–2077  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

2005 }
2006
2007 fn vm_reboot(&mut self) -> result::Result<(), VmError> {
2008 event!("vm", "rebooting");
2009
2010 // First we stop the current VM
2011 let config = if let Some(mut vm) = self.vm.take() {
2012 let config = vm.get_config();
2013 vm.shutdown()?;
2014 config
2015 } else {
2016 return Err(VmError::VmNotCreated);
2017 };
2018
2019 // vm.shutdown() closes all the console devices, so set console_info to None
2020 // so that the closed FD #s are not reused.
2021 let _ = self.console_info.take();
2022
2023 let exit_evt = self.exit_evt.try_clone().map_err(VmError::EventFdClone)?;
2024 let reset_evt = self.reset_evt.try_clone().map_err(VmError::EventFdClone)?;
2025 let guest_exit_evt = self
2026 .guest_exit_evt
2027 .try_clone()
2028 .map_err(VmError::EventFdClone)?;
2029 #[cfg(feature = "guest_debug")]
2030 let debug_evt = self
2031 .vm_debug_evt
2032 .try_clone()
2033 .map_err(VmError::EventFdClone)?;
2034 let activate_evt = self
2035 .activate_evt
2036 .try_clone()
2037 .map_err(VmError::EventFdClone)?;
2038
2039 // The Linux kernel fires off an i8042 reset after doing the ACPI reset so there may be
2040 // an event sitting in the shared reset_evt. Without doing this we get very early reboots
2041 // during the boot process.
2042 if self.reset_evt.read().is_ok() {
2043 warn!("Spurious second reset event received. Ignoring.");
2044 }
2045
2046 self.console_info =
2047 Some(pre_create_console_devices(self).map_err(VmError::CreateConsoleDevices)?);
2048
2049 // Then we create the new VM
2050 let mut vm = Vm::new(
2051 config,
2052 exit_evt,
2053 reset_evt,
2054 guest_exit_evt,
2055 #[cfg(feature = "guest_debug")]
2056 debug_evt,
2057 &self.seccomp_action,
2058 self.hypervisor.clone(),
2059 activate_evt,
2060 self.console_info.clone(),
2061 self.console_resize_pipe.clone(),
2062 Arc::clone(&self.original_termios_opt),
2063 None,
2064 None,

Callers 2

api_vm_rebootMethod · 0.45
control_loopMethod · 0.45

Calls 9

newFunction · 0.85
takeMethod · 0.80
bootMethod · 0.80
get_configMethod · 0.45
shutdownMethod · 0.45
try_cloneMethod · 0.45
readMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected