summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2018-10-10 17:25:14 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-19 12:19:52 -0700
commitf02fdd1f663760fc884073ea74fffb39a3f4ea4c (patch)
tree5cc148458abb1d8e7be7f99f227d2b4028f3f142 /src/main.rs
parentde198cc9be3f3741a4c9cc6f97275cc4ec7f7505 (diff)
downloadcrosvm-f02fdd1f663760fc884073ea74fffb39a3f4ea4c.tar
crosvm-f02fdd1f663760fc884073ea74fffb39a3f4ea4c.tar.gz
crosvm-f02fdd1f663760fc884073ea74fffb39a3f4ea4c.tar.bz2
crosvm-f02fdd1f663760fc884073ea74fffb39a3f4ea4c.tar.lz
crosvm-f02fdd1f663760fc884073ea74fffb39a3f4ea4c.tar.xz
crosvm-f02fdd1f663760fc884073ea74fffb39a3f4ea4c.tar.zst
crosvm-f02fdd1f663760fc884073ea74fffb39a3f4ea4c.zip
main: autodetect disk image type
Make --disk and --rwdisk automatically distinguish between qcow2 and raw
disk images.  --qcow and --rwqcow are kept as aliases for compatibility.

BUG=chromium:893380
TEST=Boot crosvm with both raw and qcow2 disk images.

Change-Id: I5b572626ca5ab894c78454f59355f27d552cbf7d
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1275185
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs
index 28bc09e..4dec03e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -55,15 +55,9 @@ use vm_control::VmRequest;
 
 static SECCOMP_POLICY_DIR: &'static str = "/usr/share/policy/crosvm";
 
-enum DiskType {
-    FlatFile,
-    Qcow,
-}
-
 struct DiskOption {
     path: PathBuf,
     read_only: bool,
-    disk_type: DiskType,
 }
 
 /// Contains all the info needed to create the system's virtio devices.
@@ -233,11 +227,6 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
             cfg.virtio_dev_info.disks.push(DiskOption {
                 path: disk_path,
                 read_only: !name.starts_with("rw"),
-                disk_type: if name.ends_with("qcow") {
-                    DiskType::Qcow
-                } else {
-                    DiskType::FlatFile
-                },
             });
         }
         "host_ip" => {
@@ -448,9 +437,9 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> {
                                 "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("qcow", "PATH", "Path to a qcow2 disk image. (Deprecated; use --disk instead.)"),
           Argument::value("rwdisk", "PATH", "Path to a writable disk image."),
-          Argument::value("rwqcow", "PATH", "Path to a writable qcow2 disk image."),
+          Argument::value("rwqcow", "PATH", "Path to a writable qcow2 disk image. (Deprecated; use --rwdisk instead.)"),
           Argument::value("host_ip",
                           "IP",
                           "IP address to assign to host tap interface."),