devices: Add support for pvpanic device

Introduce emulation of pvpanic device to allow cloud hypervisor to get
the notify from guest's pvpanic driver when guest kernel crash.

Signed-off-by: Yi Wang <foxywang@tencent.com>
This commit is contained in:
Yi Wang 2023-06-14 17:26:09 +08:00 committed by Rob Bradford
parent 569a2a5f07
commit ef67eab8c3
2 changed files with 25 additions and 0 deletions

View File

@ -19,6 +19,7 @@ pub mod interrupt_controller;
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
pub mod ioapic; pub mod ioapic;
pub mod legacy; pub mod legacy;
pub mod pvpanic;
pub mod tpm; pub mod tpm;
pub use self::acpi::{AcpiGedDevice, AcpiPmTimerDevice, AcpiShutdownDevice}; pub use self::acpi::{AcpiGedDevice, AcpiPmTimerDevice, AcpiShutdownDevice};

24
devices/src/pvpanic.rs Normal file
View File

@ -0,0 +1,24 @@
// Copyright © 2023 Tencent Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
const PVPANIC_PANICKED: u8 = 1 << 0;
const PVPANIC_CRASH_LOADED: u8 = 1 << 1;
/// A device for handling guest panic event
pub struct PvPanicDevice {
_id: String,
_events: u8,
}
impl PvPanicDevice {
pub fn new() -> PvPanicDevice {
let events = PVPANIC_PANICKED | PVPANIC_CRASH_LOADED;
PvPanicDevice {
_id: String::from("_pvpanic"),
_events: events,
}
}
}