@@ -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 , GuestMemoryRegionBytes , GuestRegionCollection ,
32
+ GuestUsize , 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,14 @@ impl<B: Bitmap> GuestMemoryRegion for MmapRegion<B> {
194
197
}
195
198
}
196
199
200
+ impl < B : Bitmap > GuestMemoryRegionBytes for MmapRegion < B > { }
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
+
197
208
// SAFETY: Send and Sync aren't automatically inherited for the raw address pointer.
198
209
// Accessing that pointer is only done through the stateless interface which
199
210
// allows the object to be shared by multiple threads without a decrease in
@@ -215,8 +226,7 @@ impl<B: NewBitmap> MmapRegion<B> {
215
226
/// use std::fs::File;
216
227
/// use std::path::Path;
217
228
/// use vm_memory::{
218
- /// Bytes, FileOffset, GuestAddress, GuestMemoryMmap, GuestRegionMmap, MmapRange, MmapRegion,
219
- /// MmapXenFlags,
229
+ /// Bytes, FileOffset, GuestAddress, GuestMemoryXen, MmapRange, MmapRegionXen, MmapXenFlags,
220
230
/// };
221
231
/// # use vmm_sys_util::tempfile::TempFile;
222
232
///
@@ -232,13 +242,9 @@ impl<B: NewBitmap> MmapRegion<B> {
232
242
/// # // We need a UNIX mapping for tests to succeed.
233
243
/// # let range = MmapRange::new_unix(0x400, None, addr);
234
244
///
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");
245
+ /// let r = MmapRegionXen::<()>::from_range(range).expect("Could not create mmap region");
240
246
///
241
- /// 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");
242
248
/// let res = gm
243
249
/// .write(&[1, 2, 3, 4, 5], GuestAddress(0x1200))
244
250
/// .expect("Could not write to guest memory");
@@ -251,8 +257,7 @@ impl<B: NewBitmap> MmapRegion<B> {
251
257
/// use std::fs::File;
252
258
/// use std::path::Path;
253
259
/// use vm_memory::{
254
- /// Bytes, FileOffset, GuestAddress, GuestMemoryMmap, GuestRegionMmap, MmapRange, MmapRegion,
255
- /// MmapXenFlags,
260
+ /// Bytes, FileOffset, GuestAddress, GuestMemoryXen, MmapRange, MmapRegionXen, MmapXenFlags,
256
261
/// };
257
262
/// # use vmm_sys_util::tempfile::TempFile;
258
263
///
@@ -268,13 +273,9 @@ impl<B: NewBitmap> MmapRegion<B> {
268
273
/// # // We need a UNIX mapping for tests to succeed.
269
274
/// # let range = MmapRange::new_unix(0x400, None, addr);
270
275
///
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");
276
+ /// let r = MmapRegionXen::<()>::from_range(range).expect("Could not create mmap region");
276
277
///
277
- /// 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");
278
279
/// let res = gm
279
280
/// .write(&[1, 2, 3, 4, 5], GuestAddress(0x1200))
280
281
/// .expect("Could not write to guest memory");
0 commit comments