virtio-blk: add discard request support - #6142
Open
JackThomson2 wants to merge 4 commits into
Open
Conversation
JackThomson2
force-pushed
the
pr-5908-rebase
branch
from
August 21, 2026 13:01
eff7e01 to
5d91a17
Compare
Extend the virtio-blk config space through the discard limit fields so the device can report discard capability details when the feature is enabled. [jackabt@amazon.com: rebased onto main and reconciled with the read-only config space test] Signed-off-by: Jonas Savulionis <jonas@esnet.lt> Signed-off-by: Jack Thomson <jackabt@amazon.com>
JackThomson2
force-pushed
the
pr-5908-rebase
branch
from
August 24, 2026 15:08
5d91a17 to
9da880c
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6142 +/- ##
==========================================
- Coverage 82.98% 82.91% -0.07%
==========================================
Files 277 277
Lines 30885 31010 +125
==========================================
+ Hits 25630 25713 +83
- Misses 5255 5297 +42
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add opt-in virtio-blk discard support for sync file-backed drives. The device advertises VIRTIO_BLK_F_DISCARD only when enabled, validates guest discard ranges once during request parsing, and executes discard through BLKDISCARD for block devices or fallocate hole punching for regular files. Reject discard for read-only drives and the async IO engine for now, and return UNSUPP if a guest submits discard without negotiating the feature. [jackabt@amazon.com: rebased onto main, updated the config round-trip expectations for the normalised discard field in test_block_config, resources, and the two device manager persistence tests, and moved the changelog entry to the unreleased section] Signed-off-by: Jonas Savulionis <jonas@esnet.lt> Signed-off-by: Rekas <aure369@gmail.com> Signed-off-by: Jack Thomson <jackabt@amazon.com>
Allow the sync virtio-blk discard path to punch holes in regular files and issue BLKDISCARD for block-device backed drives. [jackabt@amazon.com: rebased onto main] Signed-off-by: Jonas Savulionis <jonas@esnet.lt> Signed-off-by: Rekas <aure369@gmail.com> Signed-off-by: Jack Thomson <jackabt@amazon.com>
Cover the discard drive API by validating successful configuration, guest-visible discard granularity, and rejection of unsupported read-only or async combinations. Add a guest functional test that writes data to a file-backed drive, issues blkdiscard, and verifies host block allocation decreases. [jackabt@amazon.com: rebased onto main] Signed-off-by: Jonas Savulionis <jonas@esnet.lt> Signed-off-by: Rekas <aure369@gmail.com> Signed-off-by: Jack Thomson <jackabt@amazon.com>
JackThomson2
force-pushed
the
pr-5908-rebase
branch
from
August 24, 2026 15:41
9da880c to
09dd359
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Update of the PR: #5908
To fix a few warning and update against main
Also fixed a bug in which the config space was no longer calling
.to_le()Reason
...
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.PR Checklist
tools/devtool checkbuild --allto verify that the PR passesbuild checks on all supported architectures.
tools/devtool checkstyleto verify that the PR passes theautomated style checks.
how they are solving the problem in a clear and encompassing way.
in the PR.
CHANGELOG.md.Runbook for Firecracker API changes.
integration tests.
TODO.rust-vmm.