vmm: enable coredump

Based on the newly added guest_debug feature, this patch adds http
endpoint support.

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Co-authored-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Yi Wang
2022-05-10 19:21:02 +08:00
committed by Sebastien Boeuf
parent ccb604e1e1
commit 8b585b96c1
6 changed files with 59 additions and 1 deletions
+20
View File
@@ -18,6 +18,8 @@ use crate::config::{
add_to_config, DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, RestoreConfig,
UserDeviceConfig, VdpaConfig, VmConfig, VsockConfig,
};
#[cfg(feature = "guest_debug")]
use crate::coredump::GuestDebuggable;
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
use crate::migration::get_vm_snapshot;
use crate::migration::{recv_vm_config, recv_vm_state};
@@ -562,6 +564,15 @@ impl Vmm {
}
}
#[cfg(feature = "guest_debug")]
fn vm_coredump(&mut self, destination_url: &str) -> result::Result<(), VmError> {
if let Some(ref mut vm) = self.vm {
vm.coredump(destination_url).map_err(VmError::Coredump)
} else {
Err(VmError::VmNotRunning)
}
}
fn vm_shutdown(&mut self) -> result::Result<(), VmError> {
if let Some(ref mut vm) = self.vm.take() {
vm.shutdown()
@@ -1684,6 +1695,15 @@ impl Vmm {
sender.send(response).map_err(Error::ApiResponseSend)?;
}
#[cfg(feature = "guest_debug")]
ApiRequest::VmCoredump(coredump_data, sender) => {
let response = self
.vm_coredump(&coredump_data.destination_url)
.map_err(ApiError::VmCoredump)
.map(|_| ApiResponsePayload::Empty);
sender.send(response).map_err(Error::ApiResponseSend)?;
}
ApiRequest::VmmShutdown(sender) => {
let response = self
.vmm_shutdown()