devices: virtio: video: fix build with base MemoryMapping
The base version of MemoryMapping does not have the from_fd_offset
function. Use base::MemoryMappingBuilder and MemoryMappingBuilderUnix to
get the same functionality without depending directly on sys_util.
Fixes the build with virtio video features enabled.
BUG=b:213149154
TEST=emerge-hatch crosvm
Fixes: 45f1a419d429 ("Make crates depend on base instead of sys_util")
Change-Id: I8924d2334ae3d3ef489114b17071143871d1424d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3490743
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
diff --git a/devices/src/virtio/video/resource.rs b/devices/src/virtio/video/resource.rs
index 7b005e1..0acb819 100644
--- a/devices/src/virtio/video/resource.rs
+++ b/devices/src/virtio/video/resource.rs
@@ -8,8 +8,8 @@
use std::fmt;
use base::{
- self, FromRawDescriptor, IntoRawDescriptor, MemoryMapping, MemoryMappingArena, MmapError,
- SafeDescriptor,
+ self, FromRawDescriptor, IntoRawDescriptor, MemoryMappingArena, MemoryMappingBuilder,
+ MemoryMappingBuilderUnix, MmapError, SafeDescriptor,
};
use vm_memory::{GuestAddress, GuestMemory, GuestMemoryError};
@@ -135,7 +135,11 @@
}
fn get_mapping(&self, offset: usize, size: usize) -> Result<MemoryMappingArena, MmapError> {
- MemoryMapping::from_fd_offset(&self.desc, size, offset as u64).map(MemoryMappingArena::from)
+ MemoryMappingBuilder::new(size)
+ .from_descriptor(&self.desc)
+ .offset(offset as u64)
+ .build()
+ .map(MemoryMappingArena::from)
}
}