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:
@@ -5,6 +5,10 @@
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::config::SgxEpcConfig;
|
||||
use crate::config::{HotplugMethod, MemoryConfig, MemoryZoneConfig};
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use crate::coredump::{CoredumpMemoryRegion, CoredumpMemoryRegions};
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use crate::coredump::{DumpState, GuestDebuggable, GuestDebuggableError};
|
||||
use crate::migration::url_to_path;
|
||||
use crate::MEMORY_MANAGER_SNAPSHOT_ID;
|
||||
use crate::{GuestMemoryMmap, GuestRegionMmap};
|
||||
@@ -18,6 +22,8 @@ use devices::ioapic;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use libc::{MAP_NORESERVE, MAP_POPULATE, MAP_SHARED, PROT_READ, PROT_WRITE};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "guest_debug")]
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryInto;
|
||||
use std::ffi;
|
||||
@@ -1846,6 +1852,31 @@ impl MemoryManager {
|
||||
pub fn acpi_address(&self) -> Option<GuestAddress> {
|
||||
self.acpi_address
|
||||
}
|
||||
|
||||
pub fn num_guest_ram_mappings(&self) -> u32 {
|
||||
self.guest_ram_mappings.len() as u32
|
||||
}
|
||||
|
||||
#[cfg(feature = "guest_debug")]
|
||||
pub fn coredump_memory_regions(&self, mem_offset: u64) -> CoredumpMemoryRegions {
|
||||
let mut mapping_sorted_by_gpa = self.guest_ram_mappings.clone();
|
||||
mapping_sorted_by_gpa.sort_by_key(|m| m.gpa);
|
||||
|
||||
let mut mem_offset_in_elf = mem_offset;
|
||||
let mut ram_maps = BTreeMap::new();
|
||||
for mapping in mapping_sorted_by_gpa.iter() {
|
||||
ram_maps.insert(
|
||||
mapping.gpa,
|
||||
CoredumpMemoryRegion {
|
||||
mem_offset_in_elf,
|
||||
mem_size: mapping.size,
|
||||
},
|
||||
);
|
||||
mem_offset_in_elf += mapping.size;
|
||||
}
|
||||
|
||||
CoredumpMemoryRegions { ram_maps }
|
||||
}
|
||||
}
|
||||
|
||||
struct MemoryNotify {
|
||||
|
||||
Reference in New Issue
Block a user