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
+43
View File
@@ -0,0 +1,43 @@
// Copyright © 2022 ZTE Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
use std::fs::File;
#[derive(Clone)]
pub struct CoredumpMemoryRegion {
pub mem_offset_in_elf: u64,
pub mem_size: u64,
}
#[derive(Clone)]
pub struct CoredumpMemoryRegions {
pub ram_maps: std::collections::BTreeMap<u64, CoredumpMemoryRegion>,
}
/// Platform information
#[derive(Default)]
pub struct DumpState {
pub elf_note_size: isize,
pub elf_phdr_num: u16,
pub elf_sh_info: u32,
pub mem_offset: u64,
pub mem_info: Option<CoredumpMemoryRegions>,
pub file: Option<File>,
}
#[derive(Debug)]
pub enum GuestDebuggableError {
Coredump(anyhow::Error),
CoredumpFile(std::io::Error),
}
pub trait GuestDebuggable: vm_migration::Pausable {
fn coredump(
&mut self,
_destination_url: &str,
) -> std::result::Result<(), GuestDebuggableError> {
Ok(())
}
}