From ef67eab8c353a6f4dc7e1805a60a20e3679831fc Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Wed, 14 Jun 2023 17:26:09 +0800 Subject: [PATCH] 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 --- devices/src/lib.rs | 1 + devices/src/pvpanic.rs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 devices/src/pvpanic.rs diff --git a/devices/src/lib.rs b/devices/src/lib.rs index 1b8b0ca2c..d886ce479 100644 --- a/devices/src/lib.rs +++ b/devices/src/lib.rs @@ -19,6 +19,7 @@ pub mod interrupt_controller; #[cfg(target_arch = "x86_64")] pub mod ioapic; pub mod legacy; +pub mod pvpanic; pub mod tpm; pub use self::acpi::{AcpiGedDevice, AcpiPmTimerDevice, AcpiShutdownDevice}; diff --git a/devices/src/pvpanic.rs b/devices/src/pvpanic.rs new file mode 100644 index 000000000..0d065bab0 --- /dev/null +++ b/devices/src/pvpanic.rs @@ -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, + } + } +}