diff options
author | Dylan Reid <dgreid@chromium.org> | 2018-07-13 10:42:48 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-07-16 03:42:07 -0700 |
commit | 2dcb632405718305b7443501bd3839987e9971f7 (patch) | |
tree | 56ca608f62d68845cb70fb4f74b9797f4c78428b /qcow_utils | |
parent | 5ad21740e4fbb4a10c1395396d058b85cd6c9dab (diff) | |
download | crosvm-2dcb632405718305b7443501bd3839987e9971f7.tar crosvm-2dcb632405718305b7443501bd3839987e9971f7.tar.gz crosvm-2dcb632405718305b7443501bd3839987e9971f7.tar.bz2 crosvm-2dcb632405718305b7443501bd3839987e9971f7.tar.lz crosvm-2dcb632405718305b7443501bd3839987e9971f7.tar.xz crosvm-2dcb632405718305b7443501bd3839987e9971f7.tar.zst crosvm-2dcb632405718305b7443501bd3839987e9971f7.zip |
qcow: Set refcounts for initial clusters.
All qcow clusters need to have their refcounts set. Add a `new` method to `Qcowfile` and use it instead of just headers from the library. The new method will loop over the initial clusters and initialize their refcounts. Add a `create_qcow2` option to the main executable so there is a way to test image creation that doesn't require DBUS and Concierge. BUG=none TEST='crosvm create_qcow2 /tmp/file.qcow2 1000000' 'qemu-img check /tmp/file.qcow2' no errors reported. Change-Id: I8798df5942fb23f79cc7ca86820d0783d1f2b608 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1136900 Reviewed-by: Stephen Barber <smbarber@chromium.org>
Diffstat (limited to 'qcow_utils')
-rw-r--r-- | qcow_utils/src/qcow_utils.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/qcow_utils/src/qcow_utils.rs b/qcow_utils/src/qcow_utils.rs index 308fb01..c96678e 100644 --- a/qcow_utils/src/qcow_utils.rs +++ b/qcow_utils/src/qcow_utils.rs @@ -7,12 +7,12 @@ extern crate libc; extern crate qcow; +use libc::EINVAL; use std::ffi::CStr; use std::fs::OpenOptions; use std::os::raw::{c_char, c_int}; -use libc::EINVAL; -use qcow::QcowHeader; +use qcow::QcowFile; #[no_mangle] pub unsafe extern "C" fn create_qcow_with_size(path: *const c_char, virtual_size: u64) -> c_int { @@ -27,18 +27,18 @@ pub unsafe extern "C" fn create_qcow_with_size(path: *const c_char, virtual_size Err(_) => return -EINVAL, }; - let h = QcowHeader::create_for_size(virtual_size); - let mut file = match OpenOptions::new() - .create(true) - .read(true) - .write(true) - .open(file_path) { + let file = match OpenOptions::new() + .create(true) + .read(true) + .write(true) + .open(file_path) + { Ok(f) => f, Err(_) => return -1, }; - match h.write_to(&mut file) { - Ok(()) => 0, + match QcowFile::new(file, virtual_size) { + Ok(_) => 0, Err(_) => -1, } } |