summary refs log tree commit diff
path: root/src/linux.rs
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2019-11-08 10:11:16 -0800
committerCommit Bot <commit-bot@chromium.org>2019-11-18 09:30:58 +0000
commite73c80f355099a38293108baf0aed9666664a6e7 (patch)
treee325810bd77f52f6f525fe1255029e8d16e45982 /src/linux.rs
parent40a721b434f8bc59aac0010d5612ef3ac39f20c8 (diff)
downloadcrosvm-e73c80f355099a38293108baf0aed9666664a6e7.tar
crosvm-e73c80f355099a38293108baf0aed9666664a6e7.tar.gz
crosvm-e73c80f355099a38293108baf0aed9666664a6e7.tar.bz2
crosvm-e73c80f355099a38293108baf0aed9666664a6e7.tar.lz
crosvm-e73c80f355099a38293108baf0aed9666664a6e7.tar.xz
crosvm-e73c80f355099a38293108baf0aed9666664a6e7.tar.zst
crosvm-e73c80f355099a38293108baf0aed9666664a6e7.zip
devices: block: add option to control sparseness
Extend the --disk option and other related options to allow a particular
disk to have the sparse operations (virtio-blk's discard command)
enabled or disabled.

By default, the sparse flag will be enabled for virtio-blk devices,
matching current behavior.

BUG=chromium:858815
TEST=Run `crosvm with --rwdisk file.img,sparse=false` and try to discard

Change-Id: Ib72c949711fbe869a3f444d7f929a80d0e039f72
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1906750
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'src/linux.rs')
-rw-r--r--src/linux.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/linux.rs b/src/linux.rs
index 1177377..25aba0f 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -358,8 +358,13 @@ fn create_block_device(
     flock(&raw_image, lock_op, true).map_err(Error::DiskImageLock)?;
 
     let disk_file = disk::create_disk_file(raw_image).map_err(Error::CreateDiskError)?;
-    let dev = virtio::Block::new(disk_file, disk.read_only, Some(disk_device_socket))
-        .map_err(Error::BlockDeviceNew)?;
+    let dev = virtio::Block::new(
+        disk_file,
+        disk.read_only,
+        disk.sparse,
+        Some(disk_device_socket),
+    )
+    .map_err(Error::BlockDeviceNew)?;
 
     Ok(VirtioDeviceStub {
         dev: Box::new(dev),