Skip to content

vfio-ioctls: Add VFIO DMA logging methods#150

Merged
rbradford merged 2 commits into
rust-vmm:mainfrom
saravan2:vfio-dma-logging
May 20, 2026
Merged

vfio-ioctls: Add VFIO DMA logging methods#150
rbradford merged 2 commits into
rust-vmm:mainfrom
saravan2:vfio-dma-logging

Conversation

@saravan2
Copy link
Copy Markdown
Contributor

Summary of the PR

Add VfioDevice methods that drive the VFIO DMA dirty page logging ioctls used by live migration to track guest pages dirtied by device DMA.

VfioDevice methods:

  • start_dma_logging
  • stop_dma_logging
  • report_dma_logging

Public types:

  • DmaLoggingRange { iova, length }

The kernel reads ranges and writes the dirty bitmap through user pointers embedded in the feature payload. The Vec backing each pointer is owned by the calling stack frame and outlives the ioctl.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

Copy link
Copy Markdown
Collaborator

@likebreath likebreath left a comment

Choose a reason for hiding this comment

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

Thanks for the patience. Some comments below.

Comment thread vfio-ioctls/src/vfio_device.rs
Comment thread vfio-ioctls/src/vfio_device.rs Outdated
Comment thread vfio-ioctls/src/vfio_device.rs
Comment thread vfio-ioctls/src/vfio_device.rs Outdated
Comment thread vfio-ioctls/src/vfio_device.rs
Comment thread vfio-ioctls/src/vfio_device.rs
Comment thread vfio-ioctls/src/vfio_device.rs
Comment thread vfio-ioctls/src/vfio_device.rs
@saravan2 saravan2 force-pushed the vfio-dma-logging branch 2 times, most recently from 3dd4ffe to db0f8c1 Compare May 19, 2026 05:24
Copy link
Copy Markdown
Contributor Author

@saravan2 saravan2 left a comment

Choose a reason for hiding this comment

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

Addressed.

Comment thread vfio-ioctls/src/vfio_device.rs
Comment thread vfio-ioctls/src/vfio_device.rs
Comment thread vfio-ioctls/src/vfio_device.rs
Comment thread vfio-ioctls/src/vfio_device.rs
@saravan2 saravan2 requested a review from likebreath May 19, 2026 05:34
Copy link
Copy Markdown
Collaborator

@likebreath likebreath left a comment

Choose a reason for hiding this comment

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

Only two more comments below. Thanks for the fast response.

Comment thread vfio-ioctls/src/vfio_device.rs Outdated
Comment thread vfio-ioctls/src/vfio_device.rs Outdated
@saravan2 saravan2 force-pushed the vfio-dma-logging branch from db0f8c1 to e5c986b Compare May 19, 2026 20:22
Copy link
Copy Markdown
Contributor Author

@saravan2 saravan2 left a comment

Choose a reason for hiding this comment

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

Updated rustdoc

Comment thread vfio-ioctls/src/vfio_device.rs Outdated
Comment thread vfio-ioctls/src/vfio_device.rs Outdated
@saravan2 saravan2 requested a review from likebreath May 19, 2026 20:23
Comment thread vfio-ioctls/CHANGELOG.md Outdated
@likebreath
Copy link
Copy Markdown
Collaborator

@rbradford @sboeuf PTAL.

saravan2 added 2 commits May 19, 2026 23:25
Add VfioDevice methods that drive the VFIO DMA dirty page logging
ioctls used by live migration to track guest pages dirtied by
device DMA.

VfioDevice methods:
  - start_dma_logging
  - stop_dma_logging
  - report_dma_logging

Public types:
  - DmaLoggingRange { iova, length }

The kernel reads ranges and writes the dirty bitmap through user
pointers embedded in the feature payload. The Vec backing each
pointer is owned by the calling stack frame and outlives the
ioctl.

VfioDevice tracks whether a logging session is active and enforces
the kernel's one session per device limit. start_dma_logging on an
active session returns DmaLoggingAlreadyStarted. stop_dma_logging
and report_dma_logging on an inactive session return
DmaLoggingNotStarted.

Signed-off-by: Saravanan D <saravanand@crusoe.ai>
dma-logging tests raised coverage percentage.

Signed-off-by: Saravanan D <saravanand@crusoe.ai>
@saravan2 saravan2 force-pushed the vfio-dma-logging branch from e5c986b to 424cea6 Compare May 19, 2026 23:25
@rbradford
Copy link
Copy Markdown
Contributor

Thanks!

@rbradford rbradford merged commit f870b7c into rust-vmm:main May 20, 2026
7 checks passed
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.

3 participants