vmm: use MmapRegion::bitmap() directly

For use in QEMU, I would like GuestMemoryRegion to return a BitmapSlice
instead of a &Bitmap.  This adds some flexibility that QEMU needs in
order to support a single global dirty bitmap that is sliced by the
various GuestMemoryRegions.

However, this removes access to the methods of AtomicBitmap, and in
particular reset() and get_and_reset().  Fortunately, cloud-hypervisor
always uses GuestMemoryMmap, and therefore `region` is known to be a
&GuestRegionMmap.  Dereferencing it returns the MmapRegion to which the
bitmap is attached, thus calling MmapRegion::bitmap(); this has the
same effect as `<GuestRegionMmap as GuestRegion>::bitmap()`, and works
both with or without https://github.com/rust-vmm/vm-memory/pull/324.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini
2025-05-21 12:01:52 +02:00
committed by Rob Bradford
parent fff62d9302
commit 0463f4f156

View File

@@ -2765,7 +2765,7 @@ impl Migratable for MemoryManager {
})?; })?;
for r in self.guest_memory.memory().iter() { for r in self.guest_memory.memory().iter() {
r.bitmap().reset(); (**r).bitmap().reset();
} }
Ok(()) Ok(())
@@ -2792,7 +2792,7 @@ impl Migratable for MemoryManager {
Some(region) => { Some(region) => {
assert!(region.start_addr().raw_value() == r.gpa); assert!(region.start_addr().raw_value() == r.gpa);
assert!(region.len() == r.size); assert!(region.len() == r.size);
region.bitmap().get_and_reset() (**region).bitmap().get_and_reset()
} }
None => { None => {
return Err(MigratableError::MigrateSend(anyhow!( return Err(MigratableError::MigrateSend(anyhow!(