Skip to content

[disk_delay] A disk wrapper with runtime configurable I/O read and write delays to any underlying disk #1614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

gurasinghMS
Copy link
Contributor

@gurasinghMS gurasinghMS commented Jun 27, 2025

This change is part of changes for nvme keepalive testing and it will be used in the nvme emulator to induce artificial delays and thus attempt to capture perf of keepalive during servicing.
As a long term goal, the functionality in this crate will be expanded to include configurable I/O drops, randomized slowdown and much more in order to make testing of devices easier.

@mattkur
Copy link
Contributor

mattkur commented Jun 27, 2025

Thanks for making these changes, Guramrit!

@gurasinghMS gurasinghMS changed the title [disk_delay] Added a disk_delay type of disk that is able to wrap other disks and provide delay functionality on some functions [disk_delay] Adisk wrapper with runtime configurable I/O read and write delays to any underlying disk Jul 3, 2025
@gurasinghMS gurasinghMS marked this pull request as ready for review July 3, 2025 03:30
@gurasinghMS gurasinghMS requested review from a team as code owners July 3, 2025 03:30
@gurasinghMS gurasinghMS changed the title [disk_delay] Adisk wrapper with runtime configurable I/O read and write delays to any underlying disk [disk_delay] A disk wrapper with runtime configurable I/O read and write delays to any underlying disk Jul 3, 2025
@gurasinghMS
Copy link
Contributor Author

Adding @axelandrejs for visibility

@mattkur mattkur requested a review from Copilot July 3, 2025 23:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new disk_delay wrapper to inject configurable I/O delays and propagates the VM task driver source (VmTaskDriverSource) through existing disk resolvers to enable timer-based operations.

  • Adds a disk_delay crate with DelayDisk and its resolver
  • Updates all existing resolvers (scsi, nvme, layered, crypt, backend, guest/emulation) to accept and forward driver_source
  • Adjusts workspace Cargo.toml files to include new dependencies and the disk_delay member

Reviewed Changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vm/devices/storage/scsidisk/src/resolver.rs Pass driver_source into SCSI disk and DVD resolvers
vm/devices/storage/nvme/src/resolver.rs Forward driver_source in NVMe resolver
vm/devices/storage/disk_layered/src/resolver.rs Forward driver_source in layered disk resolver
vm/devices/storage/disk_layered/src/resolve.rs Add driver_source field to ResolveDiskLayerParameters
vm/devices/storage/disk_layered/Cargo.toml Add vmcore workspace dependency
vm/devices/storage/disk_delay/src/resolver.rs Implement resolver for DelayDisk
vm/devices/storage/disk_delay/src/lib.rs Define DelayDisk wrapper with delay timer integration
vm/devices/storage/disk_delay/Cargo.toml Introduce disk_delay crate and dependencies
vm/devices/storage/disk_crypt/src/resolver.rs Forward driver_source in disk-crypt resolver
vm/devices/storage/disk_backend_resources/src/lib.rs Define new DelayDiskHandle resource
vm/devices/storage/disk_backend/src/resolve.rs Add driver_source to core disk resolver parameters
vm/devices/storage/disk_backend/Cargo.toml Add vmcore workspace dependency
vm/devices/get/guest_emulation_device/src/resolver.rs Forward driver_source in guest-emulation-device resolver
openvmm/hvlite_core/src/worker/dispatch.rs Update open_simple_disk calls to include driver_source
openhcl/underhill_core/src/worker.rs Update disk_from_disk_type calls to include driver_source
openhcl/underhill_core/src/dispatch/vtl2_settings_worker.rs Add driver_source to disk_from_disk_type in VTL2 settings
Cargo.toml Add vm/devices/storage/disk_delay to workspace members
Comments suppressed due to low confidence (1)

vm/devices/storage/disk_delay/src/lib.rs:25

  • The new DelayDisk wrapper is not covered by any unit or integration tests. Adding tests to verify that delays are applied correctly (including boundary cases) would improve reliability.
pub struct DelayDisk {

Copy link
Contributor

@mattkur mattkur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments are mostly stylistic. I think the behavior looks perfectly great for a first pass. Certainly we'd like this to do more (as you say in the notes). Please create an issue to track all the things you think we should do here, so we can communicate the roadmap. I'm happy to do that with you, if you like.

@@ -23,6 +24,8 @@ pub struct ResolveDiskParameters<'a> {
// with missing lifetimes. Remove once we stop using async_trait for async
// resolvers.
pub _async_trait_workaround: &'a (),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super micro nit: in general, I'd suggest putting this type of stuff (workarounds for language niggles) at the end of a type. Separately, I wonder if this could be a std::marker::PhantomData<``a> instead. But that stuff still confuses me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I wonder: since this struct now has a member that uses the ```alifetime, can we just remove_async_trait_workaround`? I'll try this myself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that works I think. See gurasinghMS#11 (take my commit if you like)

/// A disk with delay on every I/O operation.
#[derive(Inspect)]
pub struct DelayDisk {
#[inspect(skip)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of all the fields here, I think delay is the one we'd want to inspect :) Is there a problem with Inspect and Cells?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, Cell apparently doesn't allow inspect :(
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use inspect's with helper in the derive to make a custom reader. Check out the crate's docs for more, it has a lot of functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants