MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / new

Method new

block/src/qcow_disk.rs:52–88  ·  view source on GitHub ↗
(
        file: File,
        direct_io: bool,
        backing_files: bool,
        sparse: bool,
        use_io_uring: bool,
    )

Source from the content-addressed store, hash-verified

50
51impl QcowDisk {
52 pub fn new(
53 file: File,
54 direct_io: bool,
55 backing_files: bool,
56 sparse: bool,
57 use_io_uring: bool,
58 ) -> BlockResult<Self> {
59 #[cfg(not(feature = "io_uring"))]
60 if use_io_uring {
61 return Err(BlockError::new(
62 BlockErrorKind::UnsupportedFeature,
63 DiskFileError::NewAsyncIo(io::Error::other(
64 "io_uring requested but feature is not enabled",
65 )),
66 ));
67 }
68
69 let max_nesting_depth = if backing_files { MAX_NESTING_DEPTH } else { 0 };
70 let raw_file = RawFile::new(file, direct_io);
71 let (inner, backing_file, sparse) = parse_qcow(raw_file, max_nesting_depth, sparse)
72 .map_err(|e| {
73 let e = if !backing_files && matches!(e.kind(), BlockErrorKind::Overflow) {
74 e.with_kind(BlockErrorKind::UnsupportedFeature)
75 } else {
76 e
77 };
78 e.with_op(ErrorOp::Open)
79 })?;
80 let data_raw_file = inner.raw_file.clone();
81 Ok(QcowDisk {
82 metadata: Arc::new(QcowMetadata::new(inner)),
83 backing_file: backing_file.map(shared_backing_from).transpose()?,
84 sparse,
85 data_raw_file,
86 use_io_uring,
87 })
88 }
89}
90
91impl Drop for QcowDisk {

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
parse_qcowFunction · 0.85
with_kindMethod · 0.80
with_opMethod · 0.80
cloneMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected