vmm: save elf header for coredump

The vmcore file of guest is an elf format, so the first step of coredump
is to save the elf header.

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
This commit is contained in:
Yi Wang
2022-05-21 17:12:09 +08:00
committed by Sebastien Boeuf
parent 90034fd6ba
commit 7e280b6f70
2 changed files with 199 additions and 0 deletions
+9
View File
@@ -19,6 +19,8 @@ use crate::config::{
#[cfg(feature = "guest_debug")]
use crate::coredump::DumpState;
#[cfg(feature = "guest_debug")]
use crate::coredump::{Elf64Writable, NoteDescType};
#[cfg(feature = "guest_debug")]
use crate::coredump::{GuestDebuggable, GuestDebuggableError};
use crate::cpu;
use crate::device_manager::{Console, DeviceManager, DeviceManagerError, PtyPair};
@@ -3020,6 +3022,9 @@ impl Debuggable for Vm {
#[cfg(feature = "guest_debug")]
pub const UINT16_MAX: u32 = 65535;
#[cfg(feature = "guest_debug")]
impl Elf64Writable for Vm {}
#[cfg(feature = "guest_debug")]
impl GuestDebuggable for Vm {
fn coredump(&mut self, destination_url: &str) -> std::result::Result<(), GuestDebuggableError> {
@@ -3043,6 +3048,10 @@ impl GuestDebuggable for Vm {
let coredump_state = self.get_dump_state(destination_url)?;
self.write_header(&coredump_state)?;
self.write_note(&coredump_state)?;
self.write_loads(&coredump_state)?;
Ok(())
}
}