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, + } + } +}