summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorDavid Reveman <reveman@chromium.org>2018-04-22 21:42:09 -0400
committerchrome-bot <chrome-bot@chromium.org>2018-05-16 08:34:40 -0700
commit52ba4e5c6492d69a8ff57e87a0134c148a74a1f2 (patch)
treee7afc45010d50be4cb42db47314222af8d6b121d /src/main.rs
parent0f1770d3ef9469b23edbaaa5f977dc0bb59602c6 (diff)
downloadcrosvm-52ba4e5c6492d69a8ff57e87a0134c148a74a1f2.tar
crosvm-52ba4e5c6492d69a8ff57e87a0134c148a74a1f2.tar.gz
crosvm-52ba4e5c6492d69a8ff57e87a0134c148a74a1f2.tar.bz2
crosvm-52ba4e5c6492d69a8ff57e87a0134c148a74a1f2.tar.lz
crosvm-52ba4e5c6492d69a8ff57e87a0134c148a74a1f2.tar.xz
crosvm-52ba4e5c6492d69a8ff57e87a0134c148a74a1f2.tar.zst
crosvm-52ba4e5c6492d69a8ff57e87a0134c148a74a1f2.zip
virtwl: Add DMABuf allocation support.
This implements DMABuf allocation type in the virtio wayland
device.

We attempt to locate a supported DRM device prior to engaging
the device jail. If found, the DRM device is passed to the
wayland device code and used to serve DMABuf allocations.

DMABuf support can be disabled by not providing crosvm with
access to any DRM device nodes.

The guest is expected to handle the case when DMABuf allocation
fails and fall-back to standard shared memory.

This initial change uses DRM directly but is structured in a
way that would allow the allocator to be replaced by minigbm
with minimal effort.

BUG=chromium:837209
TEST=crosvm finds drm device and returns valid dmabufs to guest

Change-Id: Ic1fd776dfdfefae2d7b321d449273ef269e9cc62
Reviewed-on: https://chromium-review.googlesource.com/1034088
Commit-Ready: David Reveman <reveman@chromium.org>
Tested-by: David Reveman <reveman@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index f8ed715..7c248e2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,6 +29,8 @@ extern crate data_model;
 extern crate plugin_proto;
 #[cfg(feature = "plugin")]
 extern crate protobuf;
+#[cfg(feature = "wl-dmabuf")]
+extern crate gpu_buffer;
 
 pub mod argument;
 pub mod linux;
@@ -71,6 +73,7 @@ pub struct Config {
     mac_address: Option<net_util::MacAddress>,
     vhost_net: bool,
     wayland_socket_path: Option<PathBuf>,
+    wayland_dmabuf: bool,
     socket_path: Option<PathBuf>,
     multiprocess: bool,
     seccomp_policy_dir: PathBuf,
@@ -92,6 +95,7 @@ impl Default for Config {
             mac_address: None,
             vhost_net: false,
             wayland_socket_path: None,
+            wayland_dmabuf: false,
             socket_path: None,
             multiprocess: !cfg!(feature = "default-no-sandbox"),
             seccomp_policy_dir: PathBuf::from(SECCOMP_POLICY_DIR),
@@ -269,6 +273,10 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
             }
             cfg.wayland_socket_path = Some(wayland_socket_path);
         }
+        #[cfg(feature = "wl-dmabuf")]
+        "enable-wayland-dmabuf" => {
+            cfg.wayland_dmabuf = true
+        },
         "socket" => {
             if cfg.socket_path.is_some() {
                 return Err(argument::Error::TooManyArguments("`socket` already given".to_owned()));
@@ -363,6 +371,8 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> {
           Argument::value("wayland-group",
                           "GROUP",
                           "Name of the group with access to the Wayland socket."),
+          #[cfg(feature = "wl-dmabuf")]
+          Argument::flag("wayland-dmabuf", "Enable support for DMABufs in Wayland device."),
           Argument::short_value('s',
                                 "socket",
                                 "PATH",