diff options
author | Dylan Reid <dgreid@chromium.org> | 2018-01-11 09:20:16 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-01-19 23:29:52 -0800 |
commit | 88624f890e7e2a09c122c89f397a4d796c7680fb (patch) | |
tree | e34d9467f5a290e4d3546ab62487ce3ad63fdeea /src/main.rs | |
parent | 76968703ad9f5c4edb4c533026ee35b6bd54a3d2 (diff) | |
download | crosvm-88624f890e7e2a09c122c89f397a4d796c7680fb.tar crosvm-88624f890e7e2a09c122c89f397a4d796c7680fb.tar.gz crosvm-88624f890e7e2a09c122c89f397a4d796c7680fb.tar.bz2 crosvm-88624f890e7e2a09c122c89f397a4d796c7680fb.tar.lz crosvm-88624f890e7e2a09c122c89f397a4d796c7680fb.tar.xz crosvm-88624f890e7e2a09c122c89f397a4d796c7680fb.tar.zst crosvm-88624f890e7e2a09c122c89f397a4d796c7680fb.zip |
main: Allow qcow files to be used as disks
Using qcow to allow for growable disk. These will be used for user data. Change-Id: Iefb54eb4255db2ea7693db0020c5f1429acd73fd Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/862629 Reviewed-by: Stephen Barber <smbarber@chromium.org>
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 68bdb67..4339336 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ extern crate kvm; extern crate x86_64; extern crate kernel_loader; extern crate byteorder; +extern crate qcow; #[macro_use] extern crate sys_util; extern crate vm_control; @@ -36,9 +37,15 @@ use vm_control::VmRequest; static SECCOMP_POLICY_DIR: &'static str = "/usr/share/policy/crosvm"; +enum DiskType { + FlatFile, + Qcow, +} + struct DiskOption { path: PathBuf, writable: bool, + disk_type: DiskType, } pub struct Config { @@ -162,7 +169,7 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument:: } })?) } - "root" | "disk" | "rwdisk" => { + "root" | "disk" | "rwdisk" | "qcow" | "rwqcow" => { let disk_path = PathBuf::from(value.unwrap()); if !disk_path.exists() { return Err(argument::Error::InvalidValue { @@ -188,6 +195,11 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument:: .push(DiskOption { path: disk_path, writable: name.starts_with("rw"), + disk_type: if name.ends_with("qcow") { + DiskType::Qcow + } else { + DiskType::FlatFile + }, }); } "host_ip" => { @@ -308,7 +320,9 @@ fn run_vm(args: std::env::Args) { "PATH", "Path to a root disk image. Like `--disk` but adds appropriate kernel command line option."), Argument::short_value('d', "disk", "PATH", "Path to a disk image."), + Argument::value("qcow", "PATH", "Path to a qcow2 disk image."), Argument::value("rwdisk", "PATH", "Path to a writable disk image."), + Argument::value("rwqcow", "PATH", "Path to a writable qcow2 disk image."), Argument::value("host_ip", "IP", "IP address to assign to host tap interface."), |