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