mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: block: streamline error Display::fmt()
The changes were mostly automatically applied using the Python script mentioned in the first commit of this series. Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
committed by
Rob Bradford
parent
06a868cb85
commit
aebbd1aecd
@@ -13,10 +13,10 @@ use crate::DiskTopology;
|
|||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum DiskFileError {
|
pub enum DiskFileError {
|
||||||
/// Failed getting disk file size.
|
/// Failed getting disk file size.
|
||||||
#[error("Failed getting disk file size: {0}")]
|
#[error("Failed getting disk file size")]
|
||||||
Size(#[source] std::io::Error),
|
Size(#[source] std::io::Error),
|
||||||
/// Failed creating a new AsyncIo.
|
/// Failed creating a new AsyncIo.
|
||||||
#[error("Failed creating a new AsyncIo: {0}")]
|
#[error("Failed creating a new AsyncIo")]
|
||||||
NewAsyncIo(#[source] std::io::Error),
|
NewAsyncIo(#[source] std::io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,13 +71,13 @@ pub trait DiskFile: Send {
|
|||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum AsyncIoError {
|
pub enum AsyncIoError {
|
||||||
/// Failed vectored reading from file.
|
/// Failed vectored reading from file.
|
||||||
#[error("Failed vectored reading from file: {0}")]
|
#[error("Failed vectored reading from file")]
|
||||||
ReadVectored(#[source] std::io::Error),
|
ReadVectored(#[source] std::io::Error),
|
||||||
/// Failed vectored writing to file.
|
/// Failed vectored writing to file.
|
||||||
#[error("Failed vectored writing to file: {0}")]
|
#[error("Failed vectored writing to file")]
|
||||||
WriteVectored(#[source] std::io::Error),
|
WriteVectored(#[source] std::io::Error),
|
||||||
/// Failed synchronizing file.
|
/// Failed synchronizing file.
|
||||||
#[error("Failed synchronizing file: {0}")]
|
#[error("Failed synchronizing file")]
|
||||||
Fsync(#[source] std::io::Error),
|
Fsync(#[source] std::io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ pub enum LockError {
|
|||||||
#[error("The file is already locked")]
|
#[error("The file is already locked")]
|
||||||
AlreadyLocked,
|
AlreadyLocked,
|
||||||
/// IO error.
|
/// IO error.
|
||||||
#[error("The lock state could not be checked or set: {0}")]
|
#[error("The lock state could not be checked or set")]
|
||||||
Io(#[source] io::Error),
|
Io(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,21 +79,21 @@ pub enum Error {
|
|||||||
DescriptorChainTooShort,
|
DescriptorChainTooShort,
|
||||||
#[error("Guest gave us a descriptor that was too short to use")]
|
#[error("Guest gave us a descriptor that was too short to use")]
|
||||||
DescriptorLengthTooSmall,
|
DescriptorLengthTooSmall,
|
||||||
#[error("Failed to detect image type: {0}")]
|
#[error("Failed to detect image type")]
|
||||||
DetectImageType(#[source] std::io::Error),
|
DetectImageType(#[source] std::io::Error),
|
||||||
#[error("Failure in fixed vhd: {0}")]
|
#[error("Failure in fixed vhd")]
|
||||||
FixedVhdError(#[source] std::io::Error),
|
FixedVhdError(#[source] std::io::Error),
|
||||||
#[error("Getting a block's metadata fails for any reason")]
|
#[error("Getting a block's metadata fails for any reason")]
|
||||||
GetFileMetadata,
|
GetFileMetadata,
|
||||||
#[error("The requested operation would cause a seek beyond disk end")]
|
#[error("The requested operation would cause a seek beyond disk end")]
|
||||||
InvalidOffset,
|
InvalidOffset,
|
||||||
#[error("Failure in qcow: {0}")]
|
#[error("Failure in qcow")]
|
||||||
QcowError(#[source] qcow::Error),
|
QcowError(#[source] qcow::Error),
|
||||||
#[error("Failure in raw file: {0}")]
|
#[error("Failure in raw file")]
|
||||||
RawFileError(#[source] std::io::Error),
|
RawFileError(#[source] std::io::Error),
|
||||||
#[error("The requested operation does not support multiple descriptors")]
|
#[error("The requested operation does not support multiple descriptors")]
|
||||||
TooManyDescriptors,
|
TooManyDescriptors,
|
||||||
#[error("Failure in vhdx: {0}")]
|
#[error("Failure in vhdx")]
|
||||||
VhdxError(#[source] VhdxError),
|
VhdxError(#[source] VhdxError),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,33 +131,33 @@ pub fn build_serial(disk_path: &Path) -> Vec<u8> {
|
|||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum ExecuteError {
|
pub enum ExecuteError {
|
||||||
#[error("Bad request: {0}")]
|
#[error("Bad request")]
|
||||||
BadRequest(#[source] Error),
|
BadRequest(#[source] Error),
|
||||||
#[error("Failed to flush: {0}")]
|
#[error("Failed to flush")]
|
||||||
Flush(#[source] io::Error),
|
Flush(#[source] io::Error),
|
||||||
#[error("Failed to read: {0}")]
|
#[error("Failed to read")]
|
||||||
Read(#[source] GuestMemoryError),
|
Read(#[source] GuestMemoryError),
|
||||||
#[error("Failed to read_exact: {0}")]
|
#[error("Failed to read_exact")]
|
||||||
ReadExact(#[source] io::Error),
|
ReadExact(#[source] io::Error),
|
||||||
#[error("Failed to seek: {0}")]
|
#[error("Failed to seek")]
|
||||||
Seek(#[source] io::Error),
|
Seek(#[source] io::Error),
|
||||||
#[error("Failed to write: {0}")]
|
#[error("Failed to write")]
|
||||||
Write(#[source] GuestMemoryError),
|
Write(#[source] GuestMemoryError),
|
||||||
#[error("Failed to write_all: {0}")]
|
#[error("Failed to write_all")]
|
||||||
WriteAll(#[source] io::Error),
|
WriteAll(#[source] io::Error),
|
||||||
#[error("Unsupported request: {0}")]
|
#[error("Unsupported request: {0}")]
|
||||||
Unsupported(u32),
|
Unsupported(u32),
|
||||||
#[error("Failed to submit io uring: {0}")]
|
#[error("Failed to submit io uring")]
|
||||||
SubmitIoUring(#[source] io::Error),
|
SubmitIoUring(#[source] io::Error),
|
||||||
#[error("Failed to get guest address: {0}")]
|
#[error("Failed to get guest address")]
|
||||||
GetHostAddress(#[source] GuestMemoryError),
|
GetHostAddress(#[source] GuestMemoryError),
|
||||||
#[error("Failed to async read: {0}")]
|
#[error("Failed to async read")]
|
||||||
AsyncRead(#[source] AsyncIoError),
|
AsyncRead(#[source] AsyncIoError),
|
||||||
#[error("Failed to async write: {0}")]
|
#[error("Failed to async write")]
|
||||||
AsyncWrite(#[source] AsyncIoError),
|
AsyncWrite(#[source] AsyncIoError),
|
||||||
#[error("failed to async flush: {0}")]
|
#[error("failed to async flush")]
|
||||||
AsyncFlush(#[source] AsyncIoError),
|
AsyncFlush(#[source] AsyncIoError),
|
||||||
#[error("Failed allocating a temporary buffer: {0}")]
|
#[error("Failed allocating a temporary buffer")]
|
||||||
TemporaryBufferAllocation(#[source] io::Error),
|
TemporaryBufferAllocation(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,23 +36,23 @@ const MAX_NESTING_DEPTH: u32 = 10;
|
|||||||
#[sorted]
|
#[sorted]
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("Backing file io error: {0}")]
|
#[error("Backing file io error")]
|
||||||
BackingFileIo(#[source] io::Error),
|
BackingFileIo(#[source] io::Error),
|
||||||
#[error("Backing file open error: {0}")]
|
#[error("Backing file open error")]
|
||||||
BackingFileOpen(#[source] Box<Error>),
|
BackingFileOpen(#[source] Box<Error>),
|
||||||
#[error("Backing file name is too long: {0} bytes over")]
|
#[error("Backing file name is too long: {0} bytes over")]
|
||||||
BackingFileTooLong(usize),
|
BackingFileTooLong(usize),
|
||||||
#[error("Compressed blocks not supported")]
|
#[error("Compressed blocks not supported")]
|
||||||
CompressedBlocksNotSupported,
|
CompressedBlocksNotSupported,
|
||||||
#[error("Failed to evict cache: {0}")]
|
#[error("Failed to evict cache")]
|
||||||
EvictingCache(#[source] io::Error),
|
EvictingCache(#[source] io::Error),
|
||||||
#[error("File larger than max of {MAX_QCOW_FILE_SIZE}: {0}")]
|
#[error("File larger than max of {MAX_QCOW_FILE_SIZE}: {0}")]
|
||||||
FileTooBig(u64),
|
FileTooBig(u64),
|
||||||
#[error("Failed to get file size: {0}")]
|
#[error("Failed to get file size")]
|
||||||
GettingFileSize(#[source] io::Error),
|
GettingFileSize(#[source] io::Error),
|
||||||
#[error("Failed to get refcount: {0}")]
|
#[error("Failed to get refcount")]
|
||||||
GettingRefcount(#[source] refcount::Error),
|
GettingRefcount(#[source] refcount::Error),
|
||||||
#[error("Failed to parse filename: {0}")]
|
#[error("Failed to parse filename")]
|
||||||
InvalidBackingFileName(#[source] str::Utf8Error),
|
InvalidBackingFileName(#[source] str::Utf8Error),
|
||||||
#[error("Invalid cluster index")]
|
#[error("Invalid cluster index")]
|
||||||
InvalidClusterIndex,
|
InvalidClusterIndex,
|
||||||
@@ -82,27 +82,27 @@ pub enum Error {
|
|||||||
NotEnoughSpaceForRefcounts,
|
NotEnoughSpaceForRefcounts,
|
||||||
#[error("Failed to open file {0}")]
|
#[error("Failed to open file {0}")]
|
||||||
OpeningFile(#[source] io::Error),
|
OpeningFile(#[source] io::Error),
|
||||||
#[error("Failed to read data: {0}")]
|
#[error("Failed to read data")]
|
||||||
ReadingData(#[source] io::Error),
|
ReadingData(#[source] io::Error),
|
||||||
#[error("Failed to read header: {0}")]
|
#[error("Failed to read header")]
|
||||||
ReadingHeader(#[source] io::Error),
|
ReadingHeader(#[source] io::Error),
|
||||||
#[error("Failed to read pointers: {0}")]
|
#[error("Failed to read pointers")]
|
||||||
ReadingPointers(#[source] io::Error),
|
ReadingPointers(#[source] io::Error),
|
||||||
#[error("Failed to read ref count block: {0}")]
|
#[error("Failed to read ref count block")]
|
||||||
ReadingRefCountBlock(#[source] refcount::Error),
|
ReadingRefCountBlock(#[source] refcount::Error),
|
||||||
#[error("Failed to read ref counts: {0}")]
|
#[error("Failed to read ref counts")]
|
||||||
ReadingRefCounts(#[source] io::Error),
|
ReadingRefCounts(#[source] io::Error),
|
||||||
#[error("Failed to rebuild ref counts: {0}")]
|
#[error("Failed to rebuild ref counts")]
|
||||||
RebuildingRefCounts(#[source] io::Error),
|
RebuildingRefCounts(#[source] io::Error),
|
||||||
#[error("Refcount table offset past file end")]
|
#[error("Refcount table offset past file end")]
|
||||||
RefcountTableOffEnd,
|
RefcountTableOffEnd,
|
||||||
#[error("Too many clusters specified for refcount")]
|
#[error("Too many clusters specified for refcount")]
|
||||||
RefcountTableTooLarge,
|
RefcountTableTooLarge,
|
||||||
#[error("Failed to seek file: {0}")]
|
#[error("Failed to seek file")]
|
||||||
SeekingFile(#[source] io::Error),
|
SeekingFile(#[source] io::Error),
|
||||||
#[error("Failed to set file size: {0}")]
|
#[error("Failed to set file size")]
|
||||||
SettingFileSize(#[source] io::Error),
|
SettingFileSize(#[source] io::Error),
|
||||||
#[error("Failed to set refcount refcount: {0}")]
|
#[error("Failed to set refcount refcount")]
|
||||||
SettingRefcountRefcount(#[source] io::Error),
|
SettingRefcountRefcount(#[source] io::Error),
|
||||||
#[error("Size too small for number of clusters")]
|
#[error("Size too small for number of clusters")]
|
||||||
SizeTooSmallForNumberOfClusters,
|
SizeTooSmallForNumberOfClusters,
|
||||||
@@ -114,9 +114,9 @@ pub enum Error {
|
|||||||
UnsupportedRefcountOrder,
|
UnsupportedRefcountOrder,
|
||||||
#[error("Unsupported version: {0}")]
|
#[error("Unsupported version: {0}")]
|
||||||
UnsupportedVersion(u32),
|
UnsupportedVersion(u32),
|
||||||
#[error("Failed to write data: {0}")]
|
#[error("Failed to write data")]
|
||||||
WritingData(#[source] io::Error),
|
WritingData(#[source] io::Error),
|
||||||
#[error("Failed to write header: {0}")]
|
#[error("Failed to write header")]
|
||||||
WritingHeader(#[source] io::Error),
|
WritingHeader(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use crate::qcow::vec_cache::{CacheMap, Cacheable, VecCache};
|
|||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// `EvictingCache` - Error writing a refblock from the cache to disk.
|
/// `EvictingCache` - Error writing a refblock from the cache to disk.
|
||||||
#[error("Failed to write a refblock from the cache to disk: {0}")]
|
#[error("Failed to write a refblock from the cache to disk")]
|
||||||
EvictingRefCounts(#[source] io::Error),
|
EvictingRefCounts(#[source] io::Error),
|
||||||
/// `InvalidIndex` - Address requested isn't within the range of the disk.
|
/// `InvalidIndex` - Address requested isn't within the range of the disk.
|
||||||
#[error("Address requested is not within the range of the disk")]
|
#[error("Address requested is not within the range of the disk")]
|
||||||
@@ -27,7 +27,7 @@ pub enum Error {
|
|||||||
#[error("New cluster needs to be allocated for refcounts")]
|
#[error("New cluster needs to be allocated for refcounts")]
|
||||||
NeedNewCluster,
|
NeedNewCluster,
|
||||||
/// `ReadingRefCounts` - Error reading the file into the refcount cache.
|
/// `ReadingRefCounts` - Error reading the file into the refcount cache.
|
||||||
#[error("Failed to read the file into the refcount cache: {0}")]
|
#[error("Failed to read the file into the refcount cache")]
|
||||||
ReadingRefCounts(#[source] io::Error),
|
ReadingRefCounts(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,19 +26,19 @@ mod vhdx_metadata;
|
|||||||
#[sorted]
|
#[sorted]
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum VhdxError {
|
pub enum VhdxError {
|
||||||
#[error("Not a VHDx file: {0}")]
|
#[error("Not a VHDx file")]
|
||||||
NotVhdx(#[source] VhdxHeaderError),
|
NotVhdx(#[source] VhdxHeaderError),
|
||||||
#[error("Failed to parse VHDx header: {0}")]
|
#[error("Failed to parse VHDx header")]
|
||||||
ParseVhdxHeader(#[source] VhdxHeaderError),
|
ParseVhdxHeader(#[source] VhdxHeaderError),
|
||||||
#[error("Failed to parse VHDx metadata: {0}")]
|
#[error("Failed to parse VHDx metadata")]
|
||||||
ParseVhdxMetadata(#[source] VhdxMetadataError),
|
ParseVhdxMetadata(#[source] VhdxMetadataError),
|
||||||
#[error("Failed to parse VHDx region entries: {0}")]
|
#[error("Failed to parse VHDx region entries")]
|
||||||
ParseVhdxRegionEntry(#[source] VhdxHeaderError),
|
ParseVhdxRegionEntry(#[source] VhdxHeaderError),
|
||||||
#[error("Failed reading metadata: {0}")]
|
#[error("Failed reading metadata")]
|
||||||
ReadBatEntry(#[source] VhdxBatError),
|
ReadBatEntry(#[source] VhdxBatError),
|
||||||
#[error("Failed reading sector from disk: {0}")]
|
#[error("Failed reading sector from disk")]
|
||||||
ReadFailed(#[source] VhdxIoError),
|
ReadFailed(#[source] VhdxIoError),
|
||||||
#[error("Failed writing to sector on disk: {0}")]
|
#[error("Failed writing to sector on disk")]
|
||||||
WriteFailed(#[source] VhdxIoError),
|
WriteFailed(#[source] VhdxIoError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ pub enum VhdxBatError {
|
|||||||
InvalidBatEntry,
|
InvalidBatEntry,
|
||||||
#[error("Invalid BAT entry count")]
|
#[error("Invalid BAT entry count")]
|
||||||
InvalidEntryCount,
|
InvalidEntryCount,
|
||||||
#[error("Failed to read BAT entry: {0}")]
|
#[error("Failed to read BAT entry")]
|
||||||
ReadBat(#[source] io::Error),
|
ReadBat(#[source] io::Error),
|
||||||
#[error("Failed to write BAT entry: {0}")]
|
#[error("Failed to write BAT entry")]
|
||||||
WriteBat(#[source] io::Error),
|
WriteBat(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user