Skip to main content

disk_vmdk/
lib.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! VMDK disk format support.
5
6#![deny(unsafe_code)]
7
8mod errors;
9mod flat;
10#[cfg(target_os = "linux")]
11mod io_uring;
12
13pub use errors::OpenError;
14pub use errors::ParseError;
15pub use flat::FlatVmdkResolver;
16pub use flat::ResolveFlatVmdkError;
17
18use std::path::Path;
19use vm_resource::Resource;
20use vm_resource::kind::DiskHandleKind;
21
22// Reject VMDK descriptor files larger than 1 MiB.
23pub(crate) const MAX_DESCRIPTOR_SIZE: u64 = 1 << 20;
24
25/// Opens and validates a VMDK descriptor and its extent files.
26pub fn open_vmdk(path: &Path, read_only: bool) -> Result<Resource<DiskHandleKind>, OpenError> {
27    Ok(Resource::new(flat::open_flat_vmdk(path, read_only)?))
28}