main: replace block writable option with read_only

This is more consistent with the way it will be used in the virtio-blk
device model.

BUG=chromium:872973
TEST=cargo test

Change-Id: I28c5d007a7f3864ef6e18e9b343d263123302484
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1170304
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
Daniel Verkamp 2018-08-09 16:26:59 -07:00 committed by chrome-bot
parent 5f871eb8f4
commit de9ae03d52
2 changed files with 6 additions and 6 deletions

View file

@ -405,15 +405,15 @@ fn setup_mmio_bus(cfg: &Config,
} else { } else {
OpenOptions::new() OpenOptions::new()
.read(true) .read(true)
.write(disk.writable) .write(!disk.read_only)
.open(&disk.path) .open(&disk.path)
.map_err(|e| Error::Disk(e))? .map_err(|e| Error::Disk(e))?
}; };
// Lock the disk image to prevent other crosvm instances from using it. // Lock the disk image to prevent other crosvm instances from using it.
let lock_op = if disk.writable { let lock_op = if disk.read_only {
FlockOperation::LockExclusive
} else {
FlockOperation::LockShared FlockOperation::LockShared
} else {
FlockOperation::LockExclusive
}; };
flock(&raw_image, lock_op, true).map_err(Error::DiskImageLock)?; flock(&raw_image, lock_op, true).map_err(Error::DiskImageLock)?;

View file

@ -62,7 +62,7 @@ enum DiskType {
struct DiskOption { struct DiskOption {
path: PathBuf, path: PathBuf,
writable: bool, read_only: bool,
disk_type: DiskType, disk_type: DiskType,
} }
@ -216,7 +216,7 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
cfg.disks cfg.disks
.push(DiskOption { .push(DiskOption {
path: disk_path, path: disk_path,
writable: name.starts_with("rw"), read_only: !name.starts_with("rw"),
disk_type: if name.ends_with("qcow") { disk_type: if name.ends_with("qcow") {
DiskType::Qcow DiskType::Qcow
} else { } else {