mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
vmm: Rename the VM start and stop operations to boot and shutdown
To match the OpenAPI description. And also to map the real life terminology. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
ce0b475ef7
commit
46cde1a38e
@ -356,7 +356,7 @@ fn main() {
|
||||
};
|
||||
|
||||
if cmd_arguments.is_present("vm-config") && vm_config.valid() {
|
||||
// Create and start the VM based off the VM config we just built.
|
||||
// Create and boot the VM based off the VM config we just built.
|
||||
let sender = api_request_sender.clone();
|
||||
vmm::api::vm_create(
|
||||
api_evt.try_clone().unwrap(),
|
||||
@ -364,7 +364,7 @@ fn main() {
|
||||
Arc::new(vm_config),
|
||||
)
|
||||
.expect("Could not create the VM");
|
||||
vmm::api::vm_start(api_evt.try_clone().unwrap(), sender).expect("Could not start the VM");
|
||||
vmm::api::vm_boot(api_evt.try_clone().unwrap(), sender).expect("Could not boot the VM");
|
||||
}
|
||||
|
||||
match vmm_thread.join() {
|
||||
|
@ -48,8 +48,8 @@ pub enum ApiError {
|
||||
/// The VM could not be created.
|
||||
VmCreate(VmError),
|
||||
|
||||
/// The VM could not start.
|
||||
VmStart(VmError),
|
||||
/// The VM could not boot.
|
||||
VmBoot(VmError),
|
||||
}
|
||||
|
||||
pub enum ApiResponsePayload {
|
||||
@ -68,10 +68,10 @@ pub enum ApiRequest {
|
||||
/// error back.
|
||||
VmCreate(Arc<VmConfig>, Sender<ApiResponse>),
|
||||
|
||||
/// Start the previously created virtual machine.
|
||||
/// Boot the previously created virtual machine.
|
||||
/// If the VM was not previously created, the VMM API server will send a
|
||||
/// VmStart error back.
|
||||
VmStart(Sender<ApiResponse>),
|
||||
/// VmBoot error back.
|
||||
VmBoot(Sender<ApiResponse>),
|
||||
}
|
||||
|
||||
pub fn vm_create(
|
||||
@ -95,19 +95,19 @@ pub fn vm_create(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn vm_start(api_evt: EventFd, api_sender: Sender<ApiRequest>) -> Result<()> {
|
||||
pub fn vm_boot(api_evt: EventFd, api_sender: Sender<ApiRequest>) -> Result<()> {
|
||||
let (response_sender, response_receiver) = channel();
|
||||
|
||||
// Send the VM start request.
|
||||
// Send the VM boot request.
|
||||
api_sender
|
||||
.send(ApiRequest::VmStart(response_sender))
|
||||
.send(ApiRequest::VmBoot(response_sender))
|
||||
.map_err(Error::ApiRequestSend)?;
|
||||
api_evt.write(1).map_err(Error::EventFdWrite)?;
|
||||
|
||||
response_receiver
|
||||
.recv()
|
||||
.map_err(Error::ApiResponseRecv)?
|
||||
.map_err(Error::ApiVmStart)?;
|
||||
.map_err(Error::ApiVmBoot)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ pub enum Error {
|
||||
/// Cannot create a VM from the API
|
||||
ApiVmCreate(ApiError),
|
||||
|
||||
/// Cannot start a VM from the API
|
||||
ApiVmStart(ApiError),
|
||||
/// Cannot boot a VM from the API
|
||||
ApiVmBoot(ApiError),
|
||||
|
||||
/// Cannot bind to the UNIX domain socket path
|
||||
Bind(io::Error),
|
||||
@ -78,11 +78,11 @@ pub enum Error {
|
||||
/// Cannot create a VM
|
||||
VmCreate(VmError),
|
||||
|
||||
/// Cannot start a VM
|
||||
VmStart(VmError),
|
||||
/// Cannot boot a VM
|
||||
VmBoot(VmError),
|
||||
|
||||
/// Cannot stop a VM
|
||||
VmStop(VmError),
|
||||
/// Cannot shut a VM down
|
||||
VmShutdown(VmError),
|
||||
|
||||
/// Cannot create VMM thread
|
||||
VmmThreadSpawn(io::Error),
|
||||
@ -177,14 +177,14 @@ pub fn start_vmm_thread(
|
||||
Ok(ExitBehaviour::Reset) => {
|
||||
// The VMM control loop exites with a reset behaviour.
|
||||
// We have to reboot the VM, i.e. we create a new VM
|
||||
// based on the same VM config, start it and restart
|
||||
// based on the same VM config, boot it and restart
|
||||
// the control loop.
|
||||
|
||||
// Without ACPI, a reset is equivalent to a shutdown
|
||||
#[cfg(not(feature = "acpi"))]
|
||||
{
|
||||
if let Some(ref mut vm) = vmm.vm {
|
||||
vm.stop().map_err(Error::VmStop)?;
|
||||
vm.shtudown().map_err(Error::VmShutdown)?;
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
@ -192,7 +192,7 @@ pub fn start_vmm_thread(
|
||||
// First we stop the current VM and create a new one.
|
||||
if let Some(ref mut vm) = vmm.vm {
|
||||
let config = vm.get_config();
|
||||
vm.stop().map_err(Error::VmStop)?;
|
||||
vm.shutdown().map_err(Error::VmShutdown)?;
|
||||
|
||||
let exit_evt = vmm.exit_evt.try_clone().map_err(Error::EventFdClone)?;
|
||||
let reset_evt =
|
||||
@ -203,9 +203,9 @@ pub fn start_vmm_thread(
|
||||
);
|
||||
}
|
||||
|
||||
// Then we start the new VM.
|
||||
// Then we boot the new VM.
|
||||
if let Some(ref mut vm) = vmm.vm {
|
||||
vm.start().map_err(Error::VmStart)?;
|
||||
vm.boot().map_err(Error::VmBoot)?;
|
||||
}
|
||||
|
||||
// Continue and restart the VMM control loop
|
||||
@ -215,7 +215,7 @@ pub fn start_vmm_thread(
|
||||
// The VMM control loop exites with a shutdown behaviour.
|
||||
// We have to stop the VM and we exit thr thread.
|
||||
if let Some(ref mut vm) = vmm.vm {
|
||||
vm.stop().map_err(Error::VmStop)?;
|
||||
vm.shutdown().map_err(Error::VmShutdown)?;
|
||||
}
|
||||
break 'outer;
|
||||
}
|
||||
@ -345,11 +345,11 @@ impl Vmm {
|
||||
|
||||
sender.send(response).map_err(Error::ApiResponseSend)?;
|
||||
}
|
||||
ApiRequest::VmStart(sender) => {
|
||||
ApiRequest::VmBoot(sender) => {
|
||||
if let Some(ref mut vm) = self.vm {
|
||||
let response = match vm.start() {
|
||||
let response = match vm.boot() {
|
||||
Ok(_) => Ok(ApiResponsePayload::Empty),
|
||||
Err(e) => Err(ApiError::VmStart(e)),
|
||||
Err(e) => Err(ApiError::VmBoot(e)),
|
||||
};
|
||||
|
||||
sender.send(response).map_err(Error::ApiResponseSend)?;
|
||||
|
@ -753,7 +753,7 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stop(&mut self) -> Result<()> {
|
||||
pub fn shutdown(&mut self) -> Result<()> {
|
||||
if self.on_tty {
|
||||
// Don't forget to set the terminal in canonical mode
|
||||
// before to exit.
|
||||
@ -798,7 +798,7 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn start(&mut self) -> Result<()> {
|
||||
pub fn boot(&mut self) -> Result<()> {
|
||||
let entry_addr = self.load_kernel()?;
|
||||
let vcpu_count = u8::from(&self.config.cpus);
|
||||
let vcpu_thread_barrier = Arc::new(Barrier::new((vcpu_count + 1) as usize));
|
||||
|
Loading…
x
Reference in New Issue
Block a user