diff --git a/block/src/lib.rs b/block/src/lib.rs index e831502be..82142724a 100644 --- a/block/src/lib.rs +++ b/block/src/lib.rs @@ -68,9 +68,9 @@ pub const SECTOR_SIZE: u64 = 0x01 << SECTOR_SHIFT; #[derive(Error, Debug)] pub enum Error { #[error("Guest gave us bad memory addresses")] - GuestMemory(GuestMemoryError), + GuestMemory(#[source] GuestMemoryError), #[error("Guest gave us offsets that would have overflowed a usize")] - CheckedOffset(GuestAddress, usize), + CheckedOffset(GuestAddress, usize /* sector offset */), #[error("Guest gave us a write only descriptor that protocol says to read from")] UnexpectedWriteOnlyDescriptor, #[error("Guest gave us a read only descriptor that protocol says to write to")] @@ -80,21 +80,21 @@ pub enum Error { #[error("Guest gave us a descriptor that was too short to use")] DescriptorLengthTooSmall, #[error("Failed to detect image type: {0}")] - DetectImageType(std::io::Error), + DetectImageType(#[source] std::io::Error), #[error("Failure in fixed vhd: {0}")] - FixedVhdError(std::io::Error), + FixedVhdError(#[source] std::io::Error), #[error("Getting a block's metadata fails for any reason")] GetFileMetadata, #[error("The requested operation would cause a seek beyond disk end")] InvalidOffset, #[error("Failure in qcow: {0}")] - QcowError(qcow::Error), + QcowError(#[source] qcow::Error), #[error("Failure in raw file: {0}")] - RawFileError(std::io::Error), + RawFileError(#[source] std::io::Error), #[error("The requested operation does not support multiple descriptors")] TooManyDescriptors, #[error("Failure in vhdx: {0}")] - VhdxError(VhdxError), + VhdxError(#[source] VhdxError), } fn build_device_id(disk_path: &Path) -> result::Result { @@ -132,33 +132,33 @@ pub fn build_serial(disk_path: &Path) -> Vec { #[derive(Error, Debug)] pub enum ExecuteError { #[error("Bad request: {0}")] - BadRequest(Error), + BadRequest(#[source] Error), #[error("Failed to flush: {0}")] - Flush(io::Error), + Flush(#[source] io::Error), #[error("Failed to read: {0}")] - Read(GuestMemoryError), + Read(#[source] GuestMemoryError), #[error("Failed to read_exact: {0}")] - ReadExact(io::Error), + ReadExact(#[source] io::Error), #[error("Failed to seek: {0}")] - Seek(io::Error), + Seek(#[source] io::Error), #[error("Failed to write: {0}")] - Write(GuestMemoryError), + Write(#[source] GuestMemoryError), #[error("Failed to write_all: {0}")] - WriteAll(io::Error), + WriteAll(#[source] io::Error), #[error("Unsupported request: {0}")] Unsupported(u32), #[error("Failed to submit io uring: {0}")] - SubmitIoUring(io::Error), + SubmitIoUring(#[source] io::Error), #[error("Failed to get guest address: {0}")] - GetHostAddress(GuestMemoryError), + GetHostAddress(#[source] GuestMemoryError), #[error("Failed to async read: {0}")] - AsyncRead(AsyncIoError), + AsyncRead(#[source] AsyncIoError), #[error("Failed to async write: {0}")] - AsyncWrite(AsyncIoError), + AsyncWrite(#[source] AsyncIoError), #[error("failed to async flush: {0}")] - AsyncFlush(AsyncIoError), + AsyncFlush(#[source] AsyncIoError), #[error("Failed allocating a temporary buffer: {0}")] - TemporaryBufferAllocation(io::Error), + TemporaryBufferAllocation(#[source] io::Error), } impl ExecuteError { diff --git a/block/src/qcow/mod.rs b/block/src/qcow/mod.rs index a62729380..1efa59883 100644 --- a/block/src/qcow/mod.rs +++ b/block/src/qcow/mod.rs @@ -37,23 +37,23 @@ const MAX_NESTING_DEPTH: u32 = 10; #[derive(Debug, Error)] pub enum Error { #[error("Backing file io error: {0}")] - BackingFileIo(io::Error), + BackingFileIo(#[source] io::Error), #[error("Backing file open error: {0}")] - BackingFileOpen(Box), + BackingFileOpen(#[source] Box), #[error("Backing file name is too long: {0} bytes over")] BackingFileTooLong(usize), #[error("Compressed blocks not supported")] CompressedBlocksNotSupported, #[error("Failed to evict cache: {0}")] - EvictingCache(io::Error), + EvictingCache(#[source] io::Error), #[error("File larger than max of {MAX_QCOW_FILE_SIZE}: {0}")] FileTooBig(u64), #[error("Failed to get file size: {0}")] - GettingFileSize(io::Error), + GettingFileSize(#[source] io::Error), #[error("Failed to get refcount: {0}")] - GettingRefcount(refcount::Error), + GettingRefcount(#[source] refcount::Error), #[error("Failed to parse filename: {0}")] - InvalidBackingFileName(str::Utf8Error), + InvalidBackingFileName(#[source] str::Utf8Error), #[error("Invalid cluster index")] InvalidClusterIndex, #[error("Invalid cluster size")] @@ -81,29 +81,29 @@ pub enum Error { #[error("Not enough space for refcounts")] NotEnoughSpaceForRefcounts, #[error("Failed to open file {0}")] - OpeningFile(io::Error), + OpeningFile(#[source] io::Error), #[error("Failed to read data: {0}")] - ReadingData(io::Error), + ReadingData(#[source] io::Error), #[error("Failed to read header: {0}")] - ReadingHeader(io::Error), + ReadingHeader(#[source] io::Error), #[error("Failed to read pointers: {0}")] - ReadingPointers(io::Error), + ReadingPointers(#[source] io::Error), #[error("Failed to read ref count block: {0}")] - ReadingRefCountBlock(refcount::Error), + ReadingRefCountBlock(#[source] refcount::Error), #[error("Failed to read ref counts: {0}")] - ReadingRefCounts(io::Error), + ReadingRefCounts(#[source] io::Error), #[error("Failed to rebuild ref counts: {0}")] - RebuildingRefCounts(io::Error), + RebuildingRefCounts(#[source] io::Error), #[error("Refcount table offset past file end")] RefcountTableOffEnd, #[error("Too many clusters specified for refcount")] RefcountTableTooLarge, #[error("Failed to seek file: {0}")] - SeekingFile(io::Error), + SeekingFile(#[source] io::Error), #[error("Failed to set file size: {0}")] - SettingFileSize(io::Error), + SettingFileSize(#[source] io::Error), #[error("Failed to set refcount refcount: {0}")] - SettingRefcountRefcount(io::Error), + SettingRefcountRefcount(#[source] io::Error), #[error("Size too small for number of clusters")] SizeTooSmallForNumberOfClusters, #[error("L1 entry table too large: {0}")] @@ -115,9 +115,9 @@ pub enum Error { #[error("Unsupported version: {0}")] UnsupportedVersion(u32), #[error("Failed to write data: {0}")] - WritingData(io::Error), + WritingData(#[source] io::Error), #[error("Failed to write header: {0}")] - WritingHeader(io::Error), + WritingHeader(#[source] io::Error), } pub type Result = std::result::Result; diff --git a/block/src/qcow/refcount.rs b/block/src/qcow/refcount.rs index 33bf5c045..deeccf161 100644 --- a/block/src/qcow/refcount.rs +++ b/block/src/qcow/refcount.rs @@ -16,7 +16,7 @@ use crate::qcow::vec_cache::{CacheMap, Cacheable, VecCache}; pub enum Error { /// `EvictingCache` - Error writing a refblock from the cache to disk. #[error("Failed to write a refblock from the cache to disk: {0}")] - EvictingRefCounts(io::Error), + EvictingRefCounts(#[source] io::Error), /// `InvalidIndex` - Address requested isn't within the range of the disk. #[error("Address requested is not within the range of the disk")] InvalidIndex, @@ -28,7 +28,7 @@ pub enum Error { NeedNewCluster, /// `ReadingRefCounts` - Error reading the file into the refcount cache. #[error("Failed to read the file into the refcount cache: {0}")] - ReadingRefCounts(io::Error), + ReadingRefCounts(#[source] io::Error), } pub type Result = std::result::Result; diff --git a/block/src/vhdx/mod.rs b/block/src/vhdx/mod.rs index 2ec266c62..03a312ea7 100644 --- a/block/src/vhdx/mod.rs +++ b/block/src/vhdx/mod.rs @@ -26,19 +26,19 @@ mod vhdx_metadata; #[sorted] #[derive(Error, Debug)] pub enum VhdxError { - #[error("Not a VHDx file {0}")] + #[error("Not a VHDx file: {0}")] NotVhdx(#[source] VhdxHeaderError), - #[error("Failed to parse VHDx header {0}")] + #[error("Failed to parse VHDx header: {0}")] ParseVhdxHeader(#[source] VhdxHeaderError), - #[error("Failed to parse VHDx metadata {0}")] + #[error("Failed to parse VHDx metadata: {0}")] ParseVhdxMetadata(#[source] VhdxMetadataError), - #[error("Failed to parse VHDx region entries {0}")] + #[error("Failed to parse VHDx region entries: {0}")] ParseVhdxRegionEntry(#[source] VhdxHeaderError), - #[error("Failed reading metadata {0}")] + #[error("Failed reading metadata: {0}")] ReadBatEntry(#[source] VhdxBatError), - #[error("Failed reading sector from disk {0}")] + #[error("Failed reading sector from disk: {0}")] ReadFailed(#[source] VhdxIoError), - #[error("Failed writing to sector on disk {0}")] + #[error("Failed writing to sector on disk: {0}")] WriteFailed(#[source] VhdxIoError), } diff --git a/block/src/vhdx/vhdx_bat.rs b/block/src/vhdx/vhdx_bat.rs index 01d86425e..a12ec23ec 100644 --- a/block/src/vhdx/vhdx_bat.rs +++ b/block/src/vhdx/vhdx_bat.rs @@ -33,9 +33,9 @@ pub enum VhdxBatError { InvalidBatEntry, #[error("Invalid BAT entry count")] InvalidEntryCount, - #[error("Failed to read BAT entry {0}")] + #[error("Failed to read BAT entry: {0}")] ReadBat(#[source] io::Error), - #[error("Failed to write BAT entry {0}")] + #[error("Failed to write BAT entry: {0}")] WriteBat(#[source] io::Error), }