summary refs log tree commit diff
path: root/sys_util/src
diff options
context:
space:
mode:
authorGurchetan Singh <gurchetansingh@chromium.org>2019-10-01 09:52:49 -0700
committerCommit Bot <commit-bot@chromium.org>2019-11-16 11:07:22 +0000
commitf829a93b62bd117db30123a405f3087ff811b574 (patch)
treeb63a3a1ceadd2fb67cfff6977fbdfbcdf31da704 /sys_util/src
parent2da61323894c9c12d38fa18ed918987f297ea77d (diff)
downloadcrosvm-f829a93b62bd117db30123a405f3087ff811b574.tar
crosvm-f829a93b62bd117db30123a405f3087ff811b574.tar.gz
crosvm-f829a93b62bd117db30123a405f3087ff811b574.tar.bz2
crosvm-f829a93b62bd117db30123a405f3087ff811b574.tar.lz
crosvm-f829a93b62bd117db30123a405f3087ff811b574.tar.xz
crosvm-f829a93b62bd117db30123a405f3087ff811b574.tar.zst
crosvm-f829a93b62bd117db30123a405f3087ff811b574.zip
guest_memory: remove optional memfd
Builders should all have memfd support now.

BUG=chromium:942183
TEST=compile and run, CQ will also test

Cq-Depend: chromium:1901871, chromium:1907541
Change-Id: I0cd4ec43a51e9995def2e105d68e12a703168365
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1834701
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Diffstat (limited to 'sys_util/src')
-rw-r--r--sys_util/src/guest_memory.rs34
1 files changed, 6 insertions, 28 deletions
diff --git a/sys_util/src/guest_memory.rs b/sys_util/src/guest_memory.rs
index 162960f..a745248 100644
--- a/sys_util/src/guest_memory.rs
+++ b/sys_util/src/guest_memory.rs
@@ -95,15 +95,12 @@ fn region_end(region: &MemoryRegion) -> GuestAddress {
 #[derive(Clone)]
 pub struct GuestMemory {
     regions: Arc<Vec<MemoryRegion>>,
-    memfd: Option<Arc<SharedMemory>>,
+    memfd: Arc<SharedMemory>,
 }
 
 impl AsRawFd for GuestMemory {
     fn as_raw_fd(&self) -> RawFd {
-        match &self.memfd {
-            Some(memfd) => memfd.as_raw_fd(),
-            None => panic!("GuestMemory is not backed by a memfd"),
-        }
+        self.memfd.as_raw_fd()
     }
 }
 
@@ -142,19 +139,7 @@ impl GuestMemory {
     pub fn new(ranges: &[(GuestAddress, u64)]) -> Result<GuestMemory> {
         // Create memfd
 
-        // TODO(prilik) remove optional memfd once parallel CQ lands (crbug.com/942183).
-        // Many classic CQ builders run old kernels without memfd support, resulting in test
-        // failures. It's less effort to introduce this temporary optional path than to
-        // manually mark all affected tests as ignore.
-        let memfd = match GuestMemory::create_memfd(ranges) {
-            Err(Error::MemoryCreationFailed { .. }) => {
-                warn!("GuestMemory is not backed by a memfd");
-                None
-            }
-            Err(e) => return Err(e),
-            Ok(memfd) => Some(memfd),
-        };
-
+        let memfd = GuestMemory::create_memfd(ranges)?;
         // Create memory regions
         let mut regions = Vec::<MemoryRegion>::new();
         let mut offset = 0;
@@ -170,12 +155,8 @@ impl GuestMemory {
                 }
             }
 
-            let mapping = match &memfd {
-                Some(memfd) => MemoryMapping::from_fd_offset(memfd, range.1 as usize, offset),
-                None => MemoryMapping::new(range.1 as usize),
-            }
-            .map_err(Error::MemoryMappingFailed)?;
-
+            let mapping = MemoryMapping::from_fd_offset(&memfd, range.1 as usize, offset)
+                .map_err(Error::MemoryMappingFailed)?;
             regions.push(MemoryRegion {
                 mapping,
                 guest_base: range.0,
@@ -187,10 +168,7 @@ impl GuestMemory {
 
         Ok(GuestMemory {
             regions: Arc::new(regions),
-            memfd: match memfd {
-                Some(memfd) => Some(Arc::new(memfd)),
-                None => None,
-            },
+            memfd: Arc::new(memfd),
         })
     }