vmm: add GuestDebuggable trait

It's useful to dump the guest, which named coredump so that crash
tool can be used to analysize it when guest hung up.

Let's add GuestDebuggable trait and Coredumpxxx error to support
coredump firstly.

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-24 08:35:15 +08:00
committed by Sebastien Boeuf
parent 642309f141
commit 90034fd6ba
6 changed files with 183 additions and 0 deletions

View File

@@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: Apache-2.0
#[cfg(feature = "guest_debug")]
use crate::coredump::GuestDebuggableError;
use crate::{
config::VmConfig,
vm::{VmSnapshot, VM_SNAPSHOT_ID},
@@ -32,6 +34,18 @@ pub fn url_to_path(url: &str) -> std::result::Result<PathBuf, MigratableError> {
Ok(path)
}
#[cfg(feature = "guest_debug")]
pub fn url_to_file(url: &str) -> std::result::Result<PathBuf, GuestDebuggableError> {
let file: PathBuf = url
.strip_prefix("file://")
.ok_or_else(|| {
GuestDebuggableError::Coredump(anyhow!("Could not extract file from URL: {}", url))
})
.map(|s| s.into())?;
Ok(file)
}
pub fn recv_vm_config(source_url: &str) -> std::result::Result<VmConfig, MigratableError> {
let mut vm_config_path = url_to_path(source_url)?;