From 0463f4f1564fa758014f4f37196aa4c8aa61a249 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 21 May 2025 12:01:52 +0200 Subject: [PATCH] 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 `::bitmap()`, and works both with or without https://github.com/rust-vmm/vm-memory/pull/324. Signed-off-by: Paolo Bonzini --- vmm/src/memory_manager.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 90dae6737..26897a5f1 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -2765,7 +2765,7 @@ impl Migratable for MemoryManager { })?; for r in self.guest_memory.memory().iter() { - r.bitmap().reset(); + (**r).bitmap().reset(); } Ok(()) @@ -2792,7 +2792,7 @@ impl Migratable for MemoryManager { Some(region) => { assert!(region.start_addr().raw_value() == r.gpa); assert!(region.len() == r.size); - region.bitmap().get_and_reset() + (**region).bitmap().get_and_reset() } None => { return Err(MigratableError::MigrateSend(anyhow!(