Skip to content
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

Fix PATCH operation in virtio-block devices backed by asynchronous engine #4286

Merged
merged 5 commits into from
Dec 1, 2023

Conversation

bchalios
Copy link
Contributor

@bchalios bchalios commented Nov 29, 2023

Changes

Changes the implementation along the PATCH code path for virtio-block devices so that, for the case of asynchronous engines (IO uring), it reuses the existing EventFd for getting completion callback notifications, rather than creating a knew one.

It also modifies the virtio-block tests to also test the asynchronous engine. It extends a test that verifies the PATCH operation works to also check that mount-ing an asynchronous device works.

Reason

The asynchronous engine maintains an event file descriptor which passes to the IO uring interface when creating a new ring. IO uring uses this EventFd to notify us about completion of IO requests.

When we PATCH an async block device, we create a new asynchronous engine, including a new EventFd. However, we still monitor the old EventFd. This breaks the use of async drives post PATCH requests, because we never get notified about the results of requests we submit to the IO uring engine.

As a result, mounting a virtio-block device backed from an asynchronous file engine was blocking for ever.

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

  • If a specific issue led to this PR, this PR closes the issue.
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • API changes follow the Runbook for Firecracker API changes.
  • User-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.
  • New TODOs link to an issue.
  • Commits meet contribution quality standards.

  • This functionality cannot be added in rust-vmm.

@bchalios bchalios added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Nov 29, 2023
Copy link

codecov bot commented Nov 29, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6704797) 81.69% compared to head (16056a4) 81.71%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4286      +/-   ##
==========================================
+ Coverage   81.69%   81.71%   +0.02%     
==========================================
  Files         240      240              
  Lines       29293    29332      +39     
==========================================
+ Hits        23932    23970      +38     
- Misses       5361     5362       +1     
Flag Coverage Δ
4.14-c7g.metal 77.14% <68.96%> (-0.01%) ⬇️
4.14-m5d.metal 79.03% <68.96%> (-0.02%) ⬇️
4.14-m6a.metal 78.15% <68.96%> (-0.01%) ⬇️
4.14-m6g.metal 77.14% <68.96%> (-0.01%) ⬇️
4.14-m6i.metal 79.02% <68.96%> (-0.02%) ⬇️
5.10-c7g.metal 80.04% <93.10%> (+0.01%) ⬆️
5.10-m5d.metal 81.69% <93.10%> (+<0.01%) ⬆️
5.10-m6a.metal 80.91% <93.10%> (+<0.01%) ⬆️
5.10-m6g.metal 80.04% <93.10%> (+0.01%) ⬆️
5.10-m6i.metal 81.68% <93.10%> (+<0.01%) ⬆️
6.1-c7g.metal 80.04% <93.10%> (+0.01%) ⬆️
6.1-m5d.metal 81.70% <93.10%> (+<0.01%) ⬆️
6.1-m6a.metal 80.91% <93.10%> (+<0.01%) ⬆️
6.1-m6g.metal 80.04% <93.10%> (+0.01%) ⬆️
6.1-m6i.metal 81.68% <93.10%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bchalios bchalios force-pushed the fix_patch_async_drives branch 2 times, most recently from 981e88f to d0b988c Compare November 29, 2023 18:37
So far, tests for virtio block devices only used the synchronous engine
for testing. This commit, uses the "io_engine" fixture which returns
both "Sync" and "Async" (for the kernels > 4.14). It also adds a test
the we can mount devices after patching the backing file on the host.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
In test test_send_ctrl_alt_del we send a CTRL+ALT+DEL to the microVM,
which, in x86, makes the microVM to shutdown. Then we send a signal to
the Firecracker process with `os.kill(firecracker_pid, 0)` and wait for
it to fail. This works but logs an error in the test logs which can be
confusing.

Instead we can call os.waitpid() which waits for the Firecracker process
to exit and returns immediately if the process has already exited.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
The asynchronous engine maintains an event file descriptor which passes
to the IO uring interface when creating a new ring. IO uring uses this
EventFd to notify us about completion of IO requests.

When we PATCH an async block device, we create a new asynchronous
engine, including a new EventFd. However, we still monitor the old
EventFd. This breaks the use of async drives post PATCH requests,
because we never get notified about the results of requests we submit to
the IO uring engine.

This commit changes the implementation along the PATCH code path, to
reuse the previous EventFd for the asynchronous engine.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
@bchalios bchalios merged commit 7df1359 into firecracker-microvm:main Dec 1, 2023
7 checks passed
@bchalios bchalios deleted the fix_patch_async_drives branch December 1, 2023 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting review Indicates that a pull request is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants