Skip to content

Conversation

bonzini
Copy link
Member

@bonzini bonzini commented Aug 12, 2025

Summary of the PR

The idea of GuestAddressSpace is that you would distribute as many references to it as needed. However, GuestAddressSpace itself was not always cloneable because GuestMemoryAtomic uses #[derive(Clone)] which in turn requires all type parameters to be cloneable.

However, that is not a useful requirement for GuestMemoryAtomic, which is essentially an Arc wrapper. Fix that by implementing Clone by hand; this allows GuestAddressSpace to become a subtrait of Clone as well.

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).

derive(Clone) requires the GuestMemory type parameter of
GuestMemoryAtomic to be cloneable as well.  However, this
is pointless for GuestMemoryAtomic since it is basically
an Arc<> wrapper.  Make GuestMemoryAtomic<> implement Clone
always, just like Arc<>.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
All of our implementation already provide it, just make it
part of the interface.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
roypat
roypat previously approved these changes Aug 12, 2025
Copy link
Member

@roypat roypat left a comment

Choose a reason for hiding this comment

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

Seems like rustfmt is demanding an addition comma, but functionally looks good!

@bonzini
Copy link
Member Author

bonzini commented Aug 18, 2025

Ping @ShadowCurse

@ShadowCurse ShadowCurse merged commit fbd1426 into rust-vmm:main Aug 26, 2025
2 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