mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
@@ -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)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user