@@ -28,8 +28,8 @@ use crate::bitmap::{Bitmap, NewBitmap, BS};
28
28
use crate :: guest_memory:: { FileOffset , GuestAddress } ;
29
29
use crate :: volatile_memory:: { self , VolatileMemory , VolatileSlice } ;
30
30
use crate :: {
31
- guest_memory, Address , GuestMemoryRegion , GuestMemoryRegionBytes , GuestUsize ,
32
- MemoryRegionAddress ,
31
+ guest_memory, Address , GuestMemoryRegion , GuestMemoryRegionBytes , GuestRegionCollection ,
32
+ GuestUsize , MemoryRegionAddress ,
33
33
} ;
34
34
35
35
/// Error conditions that may arise when creating a new `MmapRegion` object.
@@ -199,6 +199,12 @@ impl<B: Bitmap> GuestMemoryRegion for MmapRegion<B> {
199
199
200
200
impl < B : Bitmap > GuestMemoryRegionBytes for MmapRegion < B > { }
201
201
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
+
202
208
// SAFETY: Send and Sync aren't automatically inherited for the raw address pointer.
203
209
// Accessing that pointer is only done through the stateless interface which
204
210
// allows the object to be shared by multiple threads without a decrease in
@@ -220,8 +226,7 @@ impl<B: NewBitmap> MmapRegion<B> {
220
226
/// use std::fs::File;
221
227
/// use std::path::Path;
222
228
/// use vm_memory::{
223
- /// Bytes, FileOffset, GuestAddress, GuestMemoryMmap, GuestRegionMmap, MmapRange, MmapRegion,
224
- /// MmapXenFlags,
229
+ /// Bytes, FileOffset, GuestAddress, GuestMemoryXen, MmapRange, MmapRegionXen, MmapXenFlags,
225
230
/// };
226
231
/// # use vmm_sys_util::tempfile::TempFile;
227
232
///
@@ -237,13 +242,9 @@ impl<B: NewBitmap> MmapRegion<B> {
237
242
/// # // We need a UNIX mapping for tests to succeed.
238
243
/// # let range = MmapRange::new_unix(0x400, None, addr);
239
244
///
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");
245
246
///
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");
247
248
/// let res = gm
248
249
/// .write(&[1, 2, 3, 4, 5], GuestAddress(0x1200))
249
250
/// .expect("Could not write to guest memory");
@@ -256,8 +257,7 @@ impl<B: NewBitmap> MmapRegion<B> {
256
257
/// use std::fs::File;
257
258
/// use std::path::Path;
258
259
/// use vm_memory::{
259
- /// Bytes, FileOffset, GuestAddress, GuestMemoryMmap, GuestRegionMmap, MmapRange, MmapRegion,
260
- /// MmapXenFlags,
260
+ /// Bytes, FileOffset, GuestAddress, GuestMemoryXen, MmapRange, MmapRegionXen, MmapXenFlags,
261
261
/// };
262
262
/// # use vmm_sys_util::tempfile::TempFile;
263
263
///
@@ -273,13 +273,9 @@ impl<B: NewBitmap> MmapRegion<B> {
273
273
/// # // We need a UNIX mapping for tests to succeed.
274
274
/// # let range = MmapRange::new_unix(0x400, None, addr);
275
275
///
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");
281
277
///
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");
283
279
/// let res = gm
284
280
/// .write(&[1, 2, 3, 4, 5], GuestAddress(0x1200))
285
281
/// .expect("Could not write to guest memory");
0 commit comments