@@ -27,7 +27,10 @@ use tests::ioctl_with_ref;
27
27
use crate :: bitmap:: { Bitmap , NewBitmap , BS } ;
28
28
use crate :: guest_memory:: { FileOffset , GuestAddress } ;
29
29
use crate :: volatile_memory:: { self , VolatileMemory , VolatileSlice } ;
30
- use crate :: { guest_memory, Address , GuestMemoryRegion , GuestUsize , MemoryRegionAddress } ;
30
+ use crate :: {
31
+ guest_memory, Address , GuestMemoryRegion , GuestRegionCollection , GuestUsize ,
32
+ MemoryRegionAddress ,
33
+ } ;
31
34
32
35
/// Error conditions that may arise when creating a new `MmapRegion` object.
33
36
#[ derive( Debug , thiserror:: Error ) ]
@@ -194,6 +197,12 @@ impl<B: Bitmap> GuestMemoryRegion for MmapRegion<B> {
194
197
}
195
198
}
196
199
200
+ /// A collection of Xen guest memory regions.
201
+ ///
202
+ /// Represents the entire physical memory of the guest by tracking all its memory regions.
203
+ /// Each region is an instance of [`MmapRegionXen`].
204
+ pub type GuestMemoryXen < B > = GuestRegionCollection < MmapRegion < B > > ;
205
+
197
206
// SAFETY: Send and Sync aren't automatically inherited for the raw address pointer.
198
207
// Accessing that pointer is only done through the stateless interface which
199
208
// allows the object to be shared by multiple threads without a decrease in
@@ -215,8 +224,7 @@ impl<B: NewBitmap> MmapRegion<B> {
215
224
/// use std::fs::File;
216
225
/// use std::path::Path;
217
226
/// use vm_memory::{
218
- /// Bytes, FileOffset, GuestAddress, GuestMemoryMmap, GuestRegionMmap, MmapRange, MmapRegion,
219
- /// MmapXenFlags,
227
+ /// Bytes, FileOffset, GuestAddress, GuestMemoryXen, MmapRange, MmapRegionXen, MmapXenFlags,
220
228
/// };
221
229
/// # use vmm_sys_util::tempfile::TempFile;
222
230
///
@@ -232,13 +240,9 @@ impl<B: NewBitmap> MmapRegion<B> {
232
240
/// # // We need a UNIX mapping for tests to succeed.
233
241
/// # let range = MmapRange::new_unix(0x400, None, addr);
234
242
///
235
- /// let r = GuestRegionMmap::new(
236
- /// MmapRegion::<()>::from_range(range).expect("Could not create mmap region"),
237
- /// addr,
238
- /// )
239
- /// .expect("Could not create guest region");
243
+ /// let r = MmapRegionXen::<()>::from_range(range).expect("Could not create mmap region");
240
244
///
241
- /// let mut gm = GuestMemoryMmap ::from_regions(vec![r]).expect("Could not create guest memory");
245
+ /// let mut gm = GuestMemoryXen ::from_regions(vec![r]).expect("Could not create guest memory");
242
246
/// let res = gm
243
247
/// .write(&[1, 2, 3, 4, 5], GuestAddress(0x1200))
244
248
/// .expect("Could not write to guest memory");
@@ -251,8 +255,7 @@ impl<B: NewBitmap> MmapRegion<B> {
251
255
/// use std::fs::File;
252
256
/// use std::path::Path;
253
257
/// use vm_memory::{
254
- /// Bytes, FileOffset, GuestAddress, GuestMemoryMmap, GuestRegionMmap, MmapRange, MmapRegion,
255
- /// MmapXenFlags,
258
+ /// Bytes, FileOffset, GuestAddress, GuestMemoryXen, MmapRange, MmapRegionXen, MmapXenFlags,
256
259
/// };
257
260
/// # use vmm_sys_util::tempfile::TempFile;
258
261
///
@@ -268,13 +271,9 @@ impl<B: NewBitmap> MmapRegion<B> {
268
271
/// # // We need a UNIX mapping for tests to succeed.
269
272
/// # let range = MmapRange::new_unix(0x400, None, addr);
270
273
///
271
- /// let r = GuestRegionMmap::new(
272
- /// MmapRegion::<()>::from_range(range).expect("Could not create mmap region"),
273
- /// addr,
274
- /// )
275
- /// .expect("Could not create guest region");
274
+ /// let r = MmapRegionXen::<()>::from_range(range).expect("Could not create mmap region");
276
275
///
277
- /// let mut gm = GuestMemoryMmap ::from_regions(vec![r]).expect("Could not create guest memory");
276
+ /// let mut gm = GuestMemoryXen ::from_regions(vec![r]).expect("Could not create guest memory");
278
277
/// let res = gm
279
278
/// .write(&[1, 2, 3, 4, 5], GuestAddress(0x1200))
280
279
/// .expect("Could not write to guest memory");
0 commit comments