mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow_sync: impl AsyncDiskFile for QcowDiskSync
Implement try_clone by sharing the metadata Arc and cloning the data file descriptor. The new_async_io method creates a QcowSync worker identical to the async_io::DiskFile version. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
1fc8e4adb6
commit
fe6e3e8fef
@@ -328,6 +328,28 @@ impl disk_file::Resizable for QcowDiskSync {
|
|||||||
|
|
||||||
impl disk_file::DiskFile for QcowDiskSync {}
|
impl disk_file::DiskFile for QcowDiskSync {}
|
||||||
|
|
||||||
|
impl disk_file::AsyncDiskFile for QcowDiskSync {
|
||||||
|
fn try_clone(&self) -> BlockResult<Box<dyn disk_file::AsyncDiskFile>> {
|
||||||
|
Ok(Box::new(QcowDiskSync {
|
||||||
|
metadata: Arc::clone(&self.metadata),
|
||||||
|
backing_file: self.backing_file.as_ref().map(Arc::clone),
|
||||||
|
sparse: self.sparse,
|
||||||
|
data_raw_file: self.data_raw_file.clone(),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ring_depth is unused - this sync backend performs blocking I/O
|
||||||
|
// instead of submitting to an async ring.
|
||||||
|
fn new_async_io(&self, _ring_depth: u32) -> BlockResult<Box<dyn AsyncIo>> {
|
||||||
|
Ok(Box::new(QcowSync::new(
|
||||||
|
Arc::clone(&self.metadata),
|
||||||
|
self.data_raw_file.clone(),
|
||||||
|
self.backing_file.as_ref().map(Arc::clone),
|
||||||
|
self.sparse,
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct QcowSync {
|
pub struct QcowSync {
|
||||||
metadata: Arc<QcowMetadata>,
|
metadata: Arc<QcowMetadata>,
|
||||||
data_file: QcowRawFile,
|
data_file: QcowRawFile,
|
||||||
|
|||||||
Reference in New Issue
Block a user