Skip to content

Commit 1d605f5

Browse files
committed
Rudimentary NVMe emulation fuzzer
This tries doing a bunch of random operations against an NVMe device and checks the operations against a limited model of what the results of those operations should be. The initial stab at this is what caught #965, and it caught a bug in an intermediate state of #953 (which other phd tests did notice anyway). This fuzzing would probably be best with actual I/O operations mixed in, and I think that *should* be relatively straightforward to add from here., but as-is it's useful! This would probably be best phrased as a `cargo-fuzz` test to at least get coverage-guided fuzzing. Because of the statefulness of NVMe I think either way we'd want the model of expected device state and a pick-actions-then-run execution to further guide `cargo-fuzz` into useful parts of the device state. The initial approach at this allowed for device reset and migration at arbitrary times via a separate thread. When that required synchronizing the model of device state it was effectively interleaved with "guest" operations on the device, and in practice admin commands are serialized by the `NvmeCtrl` state lock anyway. It may be more interesting to revisit with concurrent I/O operations on submission/completion queues.
1 parent ddbbde4 commit 1d605f5

File tree

5 files changed

+661
-0
lines changed

5 files changed

+661
-0
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ progenitor-client = "0.10.0"
146146
proptest = "1.5.0"
147147
quote = "1.0"
148148
rand = "0.9.1"
149+
rand_pcg = "0.9.0"
149150
reqwest = { version = "0.12.0", default-features = false }
150151
ring = "0.17"
151152
ron = "0.8"

lib/propolis/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ tempfile.workspace = true
5252
slog-term.workspace = true
5353
slog-async.workspace = true
5454
rand.workspace = true
55+
rand_pcg.workspace = true
56+
ron.workspace = true
5557

5658
[features]
5759
default = []

lib/propolis/src/hw/nvme/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ mod cmds;
2626
mod queue;
2727
mod requests;
2828

29+
#[cfg(test)]
30+
mod test;
31+
2932
use bits::*;
3033
use queue::{CompQueue, Permit, QueueId, SubQueue};
3134

0 commit comments

Comments
 (0)