mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-08 12:41:35 +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() {
|
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();
|
let sender = api_request_sender.clone();
|
||||||
vmm::api::vm_create(
|
vmm::api::vm_create(
|
||||||
api_evt.try_clone().unwrap(),
|
api_evt.try_clone().unwrap(),
|
||||||
@ -364,7 +364,7 @@ fn main() {
|
|||||||
Arc::new(vm_config),
|
Arc::new(vm_config),
|
||||||
)
|
)
|
||||||
.expect("Could not create the VM");
|
.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() {
|
match vmm_thread.join() {
|
||||||
|
@ -48,8 +48,8 @@ pub enum ApiError {
|
|||||||
/// The VM could not be created.
|
/// The VM could not be created.
|
||||||
VmCreate(VmError),
|
VmCreate(VmError),
|
||||||
|
|
||||||
/// The VM could not start.
|
/// The VM could not boot.
|
||||||
VmStart(VmError),
|
VmBoot(VmError),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum ApiResponsePayload {
|
pub enum ApiResponsePayload {
|
||||||
@ -68,10 +68,10 @@ pub enum ApiRequest {
|
|||||||
/// error back.
|
/// error back.
|
||||||
VmCreate(Arc<VmConfig>, Sender<ApiResponse>),
|
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
|
/// If the VM was not previously created, the VMM API server will send a
|
||||||
/// VmStart error back.
|
/// VmBoot error back.
|
||||||
VmStart(Sender<ApiResponse>),
|
VmBoot(Sender<ApiResponse>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vm_create(
|
pub fn vm_create(
|
||||||
@ -95,19 +95,19 @@ pub fn vm_create(
|
|||||||
Ok(())
|
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();
|
let (response_sender, response_receiver) = channel();
|
||||||
|
|
||||||
// Send the VM start request.
|
// Send the VM boot request.
|
||||||
api_sender
|
api_sender
|
||||||
.send(ApiRequest::VmStart(response_sender))
|
.send(ApiRequest::VmBoot(response_sender))
|
||||||
.map_err(Error::ApiRequestSend)?;
|
.map_err(Error::ApiRequestSend)?;
|
||||||
api_evt.write(1).map_err(Error::EventFdWrite)?;
|
api_evt.write(1).map_err(Error::EventFdWrite)?;
|
||||||
|
|
||||||
response_receiver
|
response_receiver
|
||||||
.recv()
|
.recv()
|
||||||
.map_err(Error::ApiResponseRecv)?
|
.map_err(Error::ApiResponseRecv)?
|
||||||
.map_err(Error::ApiVmStart)?;
|
.map_err(Error::ApiVmBoot)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ pub enum Error {
|
|||||||
/// Cannot create a VM from the API
|
/// Cannot create a VM from the API
|
||||||
ApiVmCreate(ApiError),
|
ApiVmCreate(ApiError),
|
||||||
|
|
||||||
/// Cannot start a VM from the API
|
/// Cannot boot a VM from the API
|
||||||
ApiVmStart(ApiError),
|
ApiVmBoot(ApiError),
|
||||||
|
|
||||||
/// Cannot bind to the UNIX domain socket path
|
/// Cannot bind to the UNIX domain socket path
|
||||||
Bind(io::Error),
|
Bind(io::Error),
|
||||||
@ -78,11 +78,11 @@ pub enum Error {
|
|||||||
/// Cannot create a VM
|
/// Cannot create a VM
|
||||||
VmCreate(VmError),
|
VmCreate(VmError),
|
||||||
|
|
||||||
/// Cannot start a VM
|
/// Cannot boot a VM
|
||||||
VmStart(VmError),
|
VmBoot(VmError),
|
||||||
|
|
||||||
/// Cannot stop a VM
|
/// Cannot shut a VM down
|
||||||
VmStop(VmError),
|
VmShutdown(VmError),
|
||||||
|
|
||||||
/// Cannot create VMM thread
|
/// Cannot create VMM thread
|
||||||
VmmThreadSpawn(io::Error),
|
VmmThreadSpawn(io::Error),
|
||||||
@ -177,14 +177,14 @@ pub fn start_vmm_thread(
|
|||||||
Ok(ExitBehaviour::Reset) => {
|
Ok(ExitBehaviour::Reset) => {
|
||||||
// The VMM control loop exites with a reset behaviour.
|
// The VMM control loop exites with a reset behaviour.
|
||||||
// We have to reboot the VM, i.e. we create a new VM
|
// 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.
|
// the control loop.
|
||||||
|
|
||||||
// Without ACPI, a reset is equivalent to a shutdown
|
// Without ACPI, a reset is equivalent to a shutdown
|
||||||
#[cfg(not(feature = "acpi"))]
|
#[cfg(not(feature = "acpi"))]
|
||||||
{
|
{
|
||||||
if let Some(ref mut vm) = vmm.vm {
|
if let Some(ref mut vm) = vmm.vm {
|
||||||
vm.stop().map_err(Error::VmStop)?;
|
vm.shtudown().map_err(Error::VmShutdown)?;
|
||||||
break 'outer;
|
break 'outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ pub fn start_vmm_thread(
|
|||||||
// First we stop the current VM and create a new one.
|
// First we stop the current VM and create a new one.
|
||||||
if let Some(ref mut vm) = vmm.vm {
|
if let Some(ref mut vm) = vmm.vm {
|
||||||
let config = vm.get_config();
|
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 exit_evt = vmm.exit_evt.try_clone().map_err(Error::EventFdClone)?;
|
||||||
let reset_evt =
|
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 {
|
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
|
// 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.
|
// The VMM control loop exites with a shutdown behaviour.
|
||||||
// We have to stop the VM and we exit thr thread.
|
// We have to stop the VM and we exit thr thread.
|
||||||
if let Some(ref mut vm) = vmm.vm {
|
if let Some(ref mut vm) = vmm.vm {
|
||||||
vm.stop().map_err(Error::VmStop)?;
|
vm.shutdown().map_err(Error::VmShutdown)?;
|
||||||
}
|
}
|
||||||
break 'outer;
|
break 'outer;
|
||||||
}
|
}
|
||||||
@ -345,11 +345,11 @@ impl Vmm {
|
|||||||
|
|
||||||
sender.send(response).map_err(Error::ApiResponseSend)?;
|
sender.send(response).map_err(Error::ApiResponseSend)?;
|
||||||
}
|
}
|
||||||
ApiRequest::VmStart(sender) => {
|
ApiRequest::VmBoot(sender) => {
|
||||||
if let Some(ref mut vm) = self.vm {
|
if let Some(ref mut vm) = self.vm {
|
||||||
let response = match vm.start() {
|
let response = match vm.boot() {
|
||||||
Ok(_) => Ok(ApiResponsePayload::Empty),
|
Ok(_) => Ok(ApiResponsePayload::Empty),
|
||||||
Err(e) => Err(ApiError::VmStart(e)),
|
Err(e) => Err(ApiError::VmBoot(e)),
|
||||||
};
|
};
|
||||||
|
|
||||||
sender.send(response).map_err(Error::ApiResponseSend)?;
|
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 {
|
if self.on_tty {
|
||||||
// Don't forget to set the terminal in canonical mode
|
// Don't forget to set the terminal in canonical mode
|
||||||
// before to exit.
|
// 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 entry_addr = self.load_kernel()?;
|
||||||
let vcpu_count = u8::from(&self.config.cpus);
|
let vcpu_count = u8::from(&self.config.cpus);
|
||||||
let vcpu_thread_barrier = Arc::new(Barrier::new((vcpu_count + 1) as usize));
|
let vcpu_thread_barrier = Arc::new(Barrier::new((vcpu_count + 1) as usize));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user