Skip to content

Commit

Permalink
add debug log event
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Jan 10, 2024
1 parent 747bbe2 commit 65580e1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion bin/propolis-server/src/lib/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;

Expand Down
18 changes: 15 additions & 3 deletions lib/propolis/src/hw/qemu/pvpanic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::pio::{PioBus, PioFn};
#[derive(Debug)]
pub struct QemuPvpanic {
counts: Mutex<Counts>,
log: slog::Logger,
}

#[derive(Debug)]
Expand All @@ -45,9 +46,10 @@ mod probes {
impl QemuPvpanic {
const IOPORT: u16 = 0x505;

pub fn create() -> Arc<Self> {
pub fn create(log: slog::Logger) -> Arc<Self> {
Arc::new(Self {
counts: Mutex::new(Counts { host_handled: 0, guest_handled: 0 }),
log,
})
}

Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 65580e1

Please sign in to comment.