block: Add sparse operations capability query

Add capability query to DiskFile trait to check backend
support for sparse operations (punch hole, write zeroes,
discard). Only advertise VIRTIO_BLK_F_DISCARD and
VIRTIO_BLK_F_WRITE_ZEROES when the backend supports these
operations.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-01-29 21:49:42 +01:00
committed by Rob Bradford
parent d5dad48618
commit 7f4b56b217
6 changed files with 32 additions and 3 deletions
+4
View File
@@ -76,6 +76,10 @@ impl DiskFile for QcowDiskSync {
.map_err(|e| DiskFileError::ResizeError(io::Error::other(e)))
}
fn supports_sparse_operations(&self) -> bool {
true
}
fn fd(&mut self) -> BorrowedDiskFd<'_> {
BorrowedDiskFd::new(self.qcow_file.lock().unwrap().as_raw_fd())
}