Skip to content

Conversation

roypat
Copy link
Member

@roypat roypat commented Sep 30, 2025

Summary of the PR

[ based on rust-vmm/vm-memory#317 ]

Fix up the xen feature such that compiling with --feature xen allows serving both xen and non-xen VMMs. Whether or not we are dealing with a xen frontend is determined by inspecting the control messages (if the xen fields are around, then construct GuestRegionXen', otherwise just use plain old GuestRegionMmap` (unix)).

The first 4 commits are just cleanups that could probably be merged as is, but I'm not too sure whether they mess up the crates' API or not.

As for how to test this, you'll need a [patch.crates-io] for vm-memory pointed to a checkout of the above PR, with vm-memory's Cargo.toml fixed up to pretend to be version 0.16.2.

I also had a quick go at compile testing this against vhost-device, but vmm-sys-util incompatibilities were the only errors I got (apart from some needed changes from GuestMemoryMmap to GuestMemoryCollection).

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.

Instead of having cfg'd calls to different functions, just directly
construct the VhostUserMemoryRegion object. Also convert the conversion
to a `From` impl

Signed-off-by: Patrick Roy <patrick.roy@linux.dev>
instead of providing cfg'd conversion methods and constructors based on
whether the xen feature is enabled, just rely on the existing
`From&VhostUserMemoryRegionInfo> for VhostUserMemoryRegion` impl, and
add a further from impl to convert to a a `VhostUserSingleMemoryRegion`.

Signed-off-by: Patrick Roy <patrick.roy@linux.dev>
VhostUserMemoryRegion::new()/with_xen() were unused / only used in test
code, so inline them into the one use-site in test code.

Signed-off-by: Patrick Roy <patrick.roy@linux.dev>
Replace some instances of GuestMemoryAtomic<GuestMemoryMmap<B>> with the
`GM` type alias. For cases where no bitmap type was specified, add a
default type to the type alias we those can just use `GM`.

Signed-off-by: Patrick Roy <patrick.roy@linux.dev>
Allow supporting both Xen and non-xen backends when --feature xen is
enable (e.g. make the feature additive). Determine whether a memory
region is a xen one from the passed vhost messages (e.g. xen_flags and
xen_data being != 0).

Signed-off-by: Patrick Roy <patrick.roy@linux.dev>
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.

1 participant