From 888165bd8b0ab593ccc8498169f152d4a2a50b1f Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 21 May 2025 12:03:40 +0200 Subject: [PATCH] set_log_base: 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 BitmapReplace trait, because it is of course not possible to replace a slice of the bitmap only. Fortunately, vhost is built around the GM<> type alias, which has a pluggable bitmap type but hardcodes the backend: type GM = GuestMemoryAtomic>; and therefore `region` is known to be a GuestRegionMmap. Adding a single dereference of the GuestRegionMmap returns the MmapRegion to which the bitmap is attached, thus calling MmapRegion::bitmap() instead of ::bitmap(). Signed-off-by: Paolo Bonzini --- vhost-user-backend/src/handler.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/vhost-user-backend/src/handler.rs b/vhost-user-backend/src/handler.rs index 6da0c1c..27e8e9a 100644 --- a/vhost-user-backend/src/handler.rs +++ b/vhost-user-backend/src/handler.rs @@ -30,10 +30,7 @@ use vhost::vhost_user::{ use virtio_bindings::bindings::virtio_ring::VIRTIO_RING_F_EVENT_IDX; use virtio_queue::{Error as VirtQueError, QueueT}; use vm_memory::mmap::NewBitmap; -use vm_memory::{ - GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryMmap, GuestMemoryRegion, - GuestRegionMmap, -}; +use vm_memory::{GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryMmap, GuestRegionMmap}; use vmm_sys_util::epoll::EventSet; use super::backend::VhostUserBackend; @@ -788,7 +785,7 @@ where } for (region, bitmap) in bitmaps { - region.bitmap().replace(bitmap); + (*region).bitmap().replace(bitmap); } Ok(())