mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vhdx: Fixed and dynamic VHDx block device implementation
Microsoft’s VHDx block device format specification is implemented here as a crate. This commit includes the implementation for the fixed and dynamic formats, where the other format is known as differencing. The vhdx_header.rs, vhdx_bat.rs, vhdx_metadata.rs implements parser and manipulators for the VHDx header, Block Allocation Table, and metadata, respectively, for the VHDx file. The vhdx_io.rs implements read and write routines for the VHDx file. The vhdx.rs implements the Vhdx structure, which provides the wrapper functions for standard I/O operations like read, write, and seek. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com> Signed-off-by: Fazla Mehrab <akm.fazla.mehrab@intel.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
fc24f39507
commit
452af9b17c
@@ -0,0 +1,31 @@
|
||||
// Copyright © 2021 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use std::result::Result;
|
||||
use uuid::Uuid;
|
||||
|
||||
macro_rules! div_round_up {
|
||||
($n:expr,$d:expr) => {
|
||||
($n + $d - 1) / $d
|
||||
};
|
||||
}
|
||||
|
||||
pub mod vhdx;
|
||||
mod vhdx_bat;
|
||||
mod vhdx_header;
|
||||
mod vhdx_io;
|
||||
mod vhdx_metadata;
|
||||
|
||||
pub(crate) fn uuid_from_guid(buf: &[u8]) -> Result<Uuid, uuid::Error> {
|
||||
// The first 3 fields of UUID are stored in Big Endian format, and
|
||||
// the last 8 bytes are stored as byte array. Therefore, we read the
|
||||
// first 3 fields in Big Endian format instead of Little Endian.
|
||||
Uuid::from_fields_le(
|
||||
BigEndian::read_u32(&buf[0..4]),
|
||||
BigEndian::read_u16(&buf[4..6]),
|
||||
BigEndian::read_u16(&buf[6..8]),
|
||||
&buf[8..16],
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user