@@ -28,8 +28,8 @@ use crate::bitmap::{Bitmap, NewBitmap, BS};
2828use crate :: guest_memory:: { FileOffset , GuestAddress } ;
2929use crate :: volatile_memory:: { self , VolatileMemory , VolatileSlice } ;
3030use crate :: {
31- guest_memory, Address , GuestMemoryRegion , GuestMemoryRegionBytes , GuestUsize ,
32- MemoryRegionAddress ,
31+ guest_memory, Address , GuestMemoryRegion , GuestMemoryRegionBytes , GuestRegionCollection ,
32+ GuestUsize , MemoryRegionAddress ,
3333} ;
3434
3535/// Error conditions that may arise when creating a new `MmapRegion` object.
@@ -199,6 +199,12 @@ impl<B: Bitmap> GuestMemoryRegion for MmapRegion<B> {
199199
200200impl < B : Bitmap > GuestMemoryRegionBytes for MmapRegion < B > { }
201201
202+ /// A collection of Xen guest memory regions.
203+ ///
204+ /// Represents the entire physical memory of the guest by tracking all its memory regions.
205+ /// Each region is an instance of [`MmapRegionXen`].
206+ pub type GuestMemoryXen < B > = GuestRegionCollection < MmapRegion < B > > ;
207+
202208// SAFETY: Send and Sync aren't automatically inherited for the raw address pointer.
203209// Accessing that pointer is only done through the stateless interface which
204210// allows the object to be shared by multiple threads without a decrease in
@@ -220,8 +226,7 @@ impl<B: NewBitmap> MmapRegion<B> {
220226 /// use std::fs::File;
221227 /// use std::path::Path;
222228 /// use vm_memory::{
223- /// Bytes, FileOffset, GuestAddress, GuestMemoryMmap, GuestRegionMmap, MmapRange, MmapRegion,
224- /// MmapXenFlags,
229+ /// Bytes, FileOffset, GuestAddress, GuestMemoryXen, MmapRange, MmapRegionXen, MmapXenFlags,
225230 /// };
226231 /// # use vmm_sys_util::tempfile::TempFile;
227232 ///
@@ -237,13 +242,9 @@ impl<B: NewBitmap> MmapRegion<B> {
237242 /// # // We need a UNIX mapping for tests to succeed.
238243 /// # let range = MmapRange::new_unix(0x400, None, addr);
239244 ///
240- /// let r = GuestRegionMmap::new(
241- /// MmapRegion::<()>::from_range(range).expect("Could not create mmap region"),
242- /// addr,
243- /// )
244- /// .expect("Could not create guest region");
245+ /// let r = MmapRegionXen::<()>::from_range(range).expect("Could not create mmap region");
245246 ///
246- /// let mut gm = GuestMemoryMmap ::from_regions(vec![r]).expect("Could not create guest memory");
247+ /// let mut gm = GuestMemoryXen ::from_regions(vec![r]).expect("Could not create guest memory");
247248 /// let res = gm
248249 /// .write(&[1, 2, 3, 4, 5], GuestAddress(0x1200))
249250 /// .expect("Could not write to guest memory");
@@ -256,8 +257,7 @@ impl<B: NewBitmap> MmapRegion<B> {
256257 /// use std::fs::File;
257258 /// use std::path::Path;
258259 /// use vm_memory::{
259- /// Bytes, FileOffset, GuestAddress, GuestMemoryMmap, GuestRegionMmap, MmapRange, MmapRegion,
260- /// MmapXenFlags,
260+ /// Bytes, FileOffset, GuestAddress, GuestMemoryXen, MmapRange, MmapRegionXen, MmapXenFlags,
261261 /// };
262262 /// # use vmm_sys_util::tempfile::TempFile;
263263 ///
@@ -273,13 +273,9 @@ impl<B: NewBitmap> MmapRegion<B> {
273273 /// # // We need a UNIX mapping for tests to succeed.
274274 /// # let range = MmapRange::new_unix(0x400, None, addr);
275275 ///
276- /// let r = GuestRegionMmap::new(
277- /// MmapRegion::<()>::from_range(range).expect("Could not create mmap region"),
278- /// addr,
279- /// )
280- /// .expect("Could not create guest region");
276+ /// let r = MmapRegionXen::<()>::from_range(range).expect("Could not create mmap region");
281277 ///
282- /// let mut gm = GuestMemoryMmap ::from_regions(vec![r]).expect("Could not create guest memory");
278+ /// let mut gm = GuestMemoryXen ::from_regions(vec![r]).expect("Could not create guest memory");
283279 /// let res = gm
284280 /// .write(&[1, 2, 3, 4, 5], GuestAddress(0x1200))
285281 /// .expect("Could not write to guest memory");
0 commit comments