diff --git a/src/config.rs b/src/config.rs index 995db41..cb08699 100644 --- a/src/config.rs +++ b/src/config.rs @@ -317,12 +317,16 @@ pub enum PreAlloc { Full, } impl PreAlloc { - pub fn qemu_arg(&self) -> &'static str { + pub fn qemu_arg(&self, is_qcow2: bool) -> &'static str { match self { - Self::Off => "lazy_refcounts=on,preallocation=off", - Self::Metadata => "lazy_refcounts=on,preallocation=metadata", - Self::Falloc => "lazy_refcounts=on,preallocation=falloc", - Self::Full => "lazy_refcounts=on,preallocation=full", + Self::Off if is_qcow2 => "lazy_refcounts=on,preallocation=off,nocow=on", + Self::Off => "preallocation=off", + Self::Metadata if is_qcow2 => "lazy_refcounts=on,preallocation=metadata,nocow=on", + Self::Metadata => "preallocation=metadata", + Self::Falloc if is_qcow2 => "lazy_refcounts=on,preallocation=falloc,nocow=on", + Self::Falloc => "preallocation=falloc", + Self::Full if is_qcow2 => "lazy_refcounts=on,preallocation=full,nocow=on", + Self::Full => "preallocation=full" } } } diff --git a/src/qemu_args/images.rs b/src/qemu_args/images.rs index ba3d0f6..b1ee212 100644 --- a/src/qemu_args/images.rs +++ b/src/qemu_args/images.rs @@ -19,7 +19,7 @@ pub fn image_args(vm_dir: &Path, images: Option>, disks: Vec