mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
vmm: Add stop_on_boot
to Vm
to stop VM on boot
This commit adds `stop_on_boot` to `Vm` so that the VM stops before starting on boot requested. This change is required to keep the target VM stopped before a debugger attached as the user expected. Signed-off-by: Akira Moroo <retrage01@gmail.com>
This commit is contained in:
parent
bae63a8b8c
commit
23bb629241
@ -541,6 +541,7 @@ pub struct Vm {
|
|||||||
exit_evt: EventFd,
|
exit_evt: EventFd,
|
||||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||||
|
stop_on_boot: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Vm {
|
impl Vm {
|
||||||
@ -574,6 +575,8 @@ impl Vm {
|
|||||||
#[cfg(not(feature = "tdx"))]
|
#[cfg(not(feature = "tdx"))]
|
||||||
let force_iommu = false;
|
let force_iommu = false;
|
||||||
|
|
||||||
|
let stop_on_boot = false;
|
||||||
|
|
||||||
let device_manager = DeviceManager::new(
|
let device_manager = DeviceManager::new(
|
||||||
vm.clone(),
|
vm.clone(),
|
||||||
config.clone(),
|
config.clone(),
|
||||||
@ -670,6 +673,7 @@ impl Vm {
|
|||||||
exit_evt,
|
exit_evt,
|
||||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||||
hypervisor,
|
hypervisor,
|
||||||
|
stop_on_boot,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2009,7 +2013,11 @@ impl Vm {
|
|||||||
return self.resume().map_err(Error::Resume);
|
return self.resume().map_err(Error::Resume);
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_state = VmState::Running;
|
let new_state = if self.stop_on_boot {
|
||||||
|
VmState::BreakPoint
|
||||||
|
} else {
|
||||||
|
VmState::Running
|
||||||
|
};
|
||||||
current_state.valid_transition(new_state)?;
|
current_state.valid_transition(new_state)?;
|
||||||
|
|
||||||
// Load kernel if configured
|
// Load kernel if configured
|
||||||
@ -2077,11 +2085,13 @@ impl Vm {
|
|||||||
self.vm.tdx_finalize().map_err(Error::FinalizeTdx)?;
|
self.vm.tdx_finalize().map_err(Error::FinalizeTdx)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if new_state == VmState::Running {
|
||||||
self.cpu_manager
|
self.cpu_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.start_boot_vcpus()
|
.start_boot_vcpus()
|
||||||
.map_err(Error::CpuManager)?;
|
.map_err(Error::CpuManager)?;
|
||||||
|
}
|
||||||
|
|
||||||
self.setup_signal_handler()?;
|
self.setup_signal_handler()?;
|
||||||
self.setup_tty()?;
|
self.setup_tty()?;
|
||||||
|
Loading…
Reference in New Issue
Block a user