mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
Rob Bradford
parent
d5dad48618
commit
7f4b56b217
@@ -10,10 +10,10 @@ use std::os::unix::io::{AsRawFd, RawFd};
|
||||
use log::warn;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
use crate::DiskTopology;
|
||||
use crate::async_io::{
|
||||
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
|
||||
};
|
||||
use crate::{DiskTopology, probe_sparse_support};
|
||||
|
||||
pub struct RawFileDiskSync {
|
||||
file: File,
|
||||
@@ -52,6 +52,10 @@ impl DiskFile for RawFileDiskSync {
|
||||
}
|
||||
}
|
||||
|
||||
fn supports_sparse_operations(&self) -> bool {
|
||||
probe_sparse_support(&self.file)
|
||||
}
|
||||
|
||||
fn fd(&mut self) -> BorrowedDiskFd<'_> {
|
||||
BorrowedDiskFd::new(self.file.as_raw_fd())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user