mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Error for PciDeviceError and PciRootError
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
b2993fb2fa
commit
a007b750ff
@@ -5,49 +5,35 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
|
||||
use std::any::Any;
|
||||
use std::fmt::{self, Display};
|
||||
use std::sync::{Arc, Barrier, Mutex};
|
||||
use std::{io, result};
|
||||
|
||||
use thiserror::Error;
|
||||
use vm_allocator::{AddressAllocator, SystemAllocator};
|
||||
use vm_device::Resource;
|
||||
|
||||
use crate::configuration::{self, PciBarRegionType};
|
||||
use crate::PciBarConfiguration;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
/// Setup of the device capabilities failed.
|
||||
CapabilitiesSetup(configuration::Error),
|
||||
#[error("Setup of the device capabilities failed: {0}")]
|
||||
CapabilitiesSetup(#[source] configuration::Error),
|
||||
/// Allocating space for an IO BAR failed.
|
||||
#[error("Allocating space for an IO BAR failed")]
|
||||
IoAllocationFailed(u64),
|
||||
/// Registering an IO BAR failed.
|
||||
IoRegistrationFailed(u64, configuration::Error),
|
||||
#[error("Registering an IO BAR failed: {0}")]
|
||||
IoRegistrationFailed(u64, #[source] configuration::Error),
|
||||
/// Expected resource not found.
|
||||
#[error("Expected resource not found")]
|
||||
MissingResource,
|
||||
/// Invalid resource.
|
||||
#[error("Invalid resource: {0:?}")]
|
||||
InvalidResource(Resource),
|
||||
}
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use self::Error::*;
|
||||
|
||||
match self {
|
||||
CapabilitiesSetup(e) => write!(f, "failed to add capability {e}"),
|
||||
IoAllocationFailed(size) => {
|
||||
write!(f, "failed to allocate space for an IO BAR, size={size}")
|
||||
}
|
||||
IoRegistrationFailed(addr, e) => {
|
||||
write!(f, "failed to register an IO BAR, addr={addr} err={e}")
|
||||
}
|
||||
MissingResource => write!(f, "failed to find expected resource"),
|
||||
InvalidResource(r) => write!(f, "invalid resource {r:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct BarReprogrammingParams {
|
||||
pub old_base: u64,
|
||||
|
||||
Reference in New Issue
Block a user