From 65580e15b2f658e821cf0097f889c070c0c50557 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 10 Jan 2024 11:24:57 -0800 Subject: [PATCH] add debug log event --- bin/propolis-server/src/lib/initializer.rs | 4 +++- lib/propolis/src/hw/qemu/pvpanic.rs | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/bin/propolis-server/src/lib/initializer.rs b/bin/propolis-server/src/lib/initializer.rs index 467ce6a1d..1f4c08081 100644 --- a/bin/propolis-server/src/lib/initializer.rs +++ b/bin/propolis-server/src/lib/initializer.rs @@ -283,7 +283,9 @@ impl<'a> MachineInitializer<'a> { ) -> Result<(), anyhow::Error> { if let Some(ref spec) = self.spec.devices.qemu_pvpanic { if spec.enable_isa { - let pvpanic = QemuPvpanic::create(); + let pvpanic = QemuPvpanic::create( + self.log.new(slog::o!("dev" => "qemu-pvpanic")), + ); pvpanic.attach_pio(&self.machine.bus_pio); self.inv.register(&pvpanic)?; diff --git a/lib/propolis/src/hw/qemu/pvpanic.rs b/lib/propolis/src/hw/qemu/pvpanic.rs index 85331f8fc..cdf2d9423 100644 --- a/lib/propolis/src/hw/qemu/pvpanic.rs +++ b/lib/propolis/src/hw/qemu/pvpanic.rs @@ -19,6 +19,7 @@ use crate::pio::{PioBus, PioFn}; #[derive(Debug)] pub struct QemuPvpanic { counts: Mutex, + log: slog::Logger, } #[derive(Debug)] @@ -45,9 +46,10 @@ mod probes { impl QemuPvpanic { const IOPORT: u16 = 0x505; - pub fn create() -> Arc { + pub fn create(log: slog::Logger) -> Arc { Arc::new(Self { counts: Mutex::new(Counts { host_handled: 0, guest_handled: 0 }), + log, }) } @@ -75,12 +77,22 @@ impl QemuPvpanic { RWOp::Write(wo) => { let value = wo.read_u8(); probes::pvpanic_pio_write!(|| value); + let host_handled = value & HOST_HANDLED != 0; + let guest_handled = value & GUEST_HANDLED != 0; + slog::debug!( + self.log, + "guest kernel panic"; + "host_handled" => host_handled, + "guest_handled" => guest_handled, + ); + let mut counts = self.counts.lock().unwrap(); - if value & HOST_HANDLED != 0 { + + if host_handled { counts.host_handled += 1; } - if value & GUEST_HANDLED != 0 { + if guest_handled { counts.guest_handled += 1; } }