diff options
Diffstat (limited to 'disk/src/qcow/mod.rs')
-rw-r--r-- | disk/src/qcow/mod.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/disk/src/qcow/mod.rs b/disk/src/qcow/mod.rs index b1df192..add4f48 100644 --- a/disk/src/qcow/mod.rs +++ b/disk/src/qcow/mod.rs @@ -10,8 +10,8 @@ use data_model::{VolatileMemory, VolatileSlice}; use libc::{EINVAL, ENOSPC, ENOTSUP}; use remain::sorted; use sys_util::{ - error, FileReadWriteAtVolatile, FileReadWriteVolatile, FileSetLen, FileSync, PunchHole, - SeekHole, WriteZeroesAt, + error, FileAllocate, FileReadWriteAtVolatile, FileReadWriteVolatile, FileSetLen, FileSync, + PunchHole, SeekHole, WriteZeroesAt, }; use std::cmp::{max, min}; @@ -1582,6 +1582,15 @@ impl DiskGetLen for QcowFile { } } +impl FileAllocate for QcowFile { + fn allocate(&mut self, offset: u64, len: u64) -> io::Result<()> { + // Call write_cb with a do-nothing callback, which will have the effect + // of allocating all clusters in the specified range. + self.write_cb(offset, len as usize, |_file, _offset, _count| Ok(()))?; + Ok(()) + } +} + impl PunchHole for QcowFile { fn punch_hole(&mut self, offset: u64, length: u64) -> std::io::Result<()> { let mut remaining = length; |