summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/crosvm.rs1
-rw-r--r--src/linux.rs1
-rw-r--r--src/main.rs13
3 files changed, 14 insertions, 1 deletions
diff --git a/src/crosvm.rs b/src/crosvm.rs
index de23573..0e0e218 100644
--- a/src/crosvm.rs
+++ b/src/crosvm.rs
@@ -39,6 +39,7 @@ pub struct DiskOption {
     pub path: PathBuf,
     pub read_only: bool,
     pub sparse: bool,
+    pub block_size: u32,
 }
 
 /// A bind mount for directories in the plugin process.
diff --git a/src/linux.rs b/src/linux.rs
index 006af42..a9a3445 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -386,6 +386,7 @@ fn create_block_device(
         disk_file,
         disk.read_only,
         disk.sparse,
+        disk.block_size,
         Some(disk_device_socket),
     )
     .map_err(Error::BlockDeviceNew)?;
diff --git a/src/main.rs b/src/main.rs
index 8d9c890..9c97c4d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -378,6 +378,7 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
                 path: disk_path,
                 read_only,
                 sparse: true,
+                block_size: 512,
             };
 
             for opt in components {
@@ -399,6 +400,14 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
                         })?;
                         disk.sparse = sparse;
                     }
+                    "block_size" => {
+                        let block_size =
+                            value.parse().map_err(|_| argument::Error::InvalidValue {
+                                value: value.to_owned(),
+                                expected: "`block_size` must be an integer",
+                            })?;
+                        disk.block_size = block_size;
+                    }
                     _ => {
                         return Err(argument::Error::InvalidValue {
                             value: kind.to_owned(),
@@ -423,6 +432,7 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
                 path: disk_path,
                 read_only: !name.starts_with("rw"),
                 sparse: false,
+                block_size: sys_util::pagesize() as u32,
             });
         }
         "host_ip" => {
@@ -893,7 +903,8 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> {
                               See --disk for valid options."),
           Argument::short_value('d', "disk", "PATH[,key=value[,key=value[,...]]", "Path to a disk image followed by optional comma-separated options.
                               Valid keys:
-                              sparse=BOOL - Indicates whether the disk should support the discard operation (default: true)"),
+                              sparse=BOOL - Indicates whether the disk should support the discard operation (default: true)
+                              block_size=BYTES - Set the reported block size of the disk (default: 512)"),
           Argument::value("qcow", "PATH", "Path to a qcow2 disk image. (Deprecated; use --disk instead.)"),
           Argument::value("rwdisk", "PATH[,key=value[,key=value[,...]]", "Path to a writable disk image followed by optional comma-separated options.
                               See --disk for valid options."),