summary refs log tree commit diff
path: root/src/linux.rs
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2018-10-18 16:45:13 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-19 15:07:43 -0700
commit8eceba31c0d2842d8d7bfaa84253121709b1ee81 (patch)
tree35de26e27c5e5a9f91bbdad3ee0ca34f6f1f5b99 /src/linux.rs
parentf02fdd1f663760fc884073ea74fffb39a3f4ea4c (diff)
downloadcrosvm-8eceba31c0d2842d8d7bfaa84253121709b1ee81.tar
crosvm-8eceba31c0d2842d8d7bfaa84253121709b1ee81.tar.gz
crosvm-8eceba31c0d2842d8d7bfaa84253121709b1ee81.tar.bz2
crosvm-8eceba31c0d2842d8d7bfaa84253121709b1ee81.tar.lz
crosvm-8eceba31c0d2842d8d7bfaa84253121709b1ee81.tar.xz
crosvm-8eceba31c0d2842d8d7bfaa84253121709b1ee81.tar.zst
crosvm-8eceba31c0d2842d8d7bfaa84253121709b1ee81.zip
devices: make PCI work in --disable-sandbox mode
Make the Minijail part of the PCI device tuple optional so that an empty
jail is not created for --disable-sandbox.

BUG=None
TEST=Boot crosvm in both --multiprocess and --disable-sandbox modes

Change-Id: Ibb3f2dbf33ca19910ee7448ea823b2772e09ecc5
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1290289
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'src/linux.rs')
-rw-r--r--src/linux.rs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/linux.rs b/src/linux.rs
index 903b6b1..ae3130d 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -249,7 +249,7 @@ fn create_virtio_devs(
     _exit_evt: &EventFd,
     wayland_device_socket: UnixDatagram,
     balloon_device_socket: UnixDatagram,
-) -> std::result::Result<Vec<(Box<PciDevice + 'static>, Minijail)>, Box<error::Error>> {
+) -> std::result::Result<Vec<(Box<PciDevice + 'static>, Option<Minijail>)>, Box<error::Error>> {
     static DEFAULT_PIVOT_ROOT: &'static str = "/var/empty";
 
     let mut devs = Vec::new();
@@ -620,17 +620,11 @@ fn create_virtio_devs(
         devs.push(VirtioDeviceStub { dev: p9_box, jail });
     }
 
-    let mut pci_devices: Vec<(Box<PciDevice + 'static>, Minijail)> = Vec::new();
+    let mut pci_devices: Vec<(Box<PciDevice + 'static>, Option<Minijail>)> = Vec::new();
     for stub in devs {
         let pci_dev =
             Box::new(VirtioPciDevice::new((*mem).clone(), stub.dev).map_err(Error::VirtioPciDev)?);
-
-        // TODO(dverkamp): Make this work in non-multiprocess mode without creating an empty jail
-        let jail = match stub.jail {
-            Some(j) => j,
-            None => Minijail::new().unwrap(),
-        };
-        pci_devices.push((pci_dev, jail));
+        pci_devices.push((pci_dev, stub.jail));
     }
 
     Ok(pci_devices)