pub mod cdev;
pub mod container;
pub mod device;
pub mod group;
pub mod iommu;
pub mod pci;
use std::path::Path;
use serde::Deserialize;
use serde_aco::Help;
use snafu::Snafu;
use crate::errors::{DebugTrace, trace_error};
use crate::sys::vfio::VfioIommu;
#[trace_error]
#[derive(Snafu, DebugTrace)]
#[snafu(module, context(suffix(false)))]
pub enum Error {
#[snafu(display("Hypervisor internal error"), context(false))]
HvError { source: Box<crate::hv::Error> },
#[snafu(display("Failed to access guest memory"), context(false))]
Memory { source: Box<crate::mem::Error> },
#[snafu(display("Error from OS"), context(false))]
System { error: std::io::Error },
#[snafu(display("Cannot access device {path:?}"))]
AccessDevice {
path: Box<Path>,
error: std::io::Error,
},
#[snafu(display("Not supported PCI header type {ty:#x}"))]
NotSupportedHeader { ty: u8 },
#[snafu(display("Setting container iommu to {new:?}, but it already has {current:?}"))]
SetContainerIommu { current: VfioIommu, new: VfioIommu },
}
pub type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Debug, PartialEq, Eq, Deserialize, Help)]
pub struct CdevParam {
pub path: Box<Path>,
pub ioas: Option<Box<str>>,
}
#[derive(Debug, PartialEq, Eq, Deserialize, Help)]
pub struct IoasParam {
pub name: Box<str>,
pub dev_iommu: Option<Box<Path>>,
}
#[derive(Debug, PartialEq, Eq, Deserialize, Help)]
pub struct GroupParam {
pub path: Box<Path>,
#[serde(default)]
pub devices: Vec<Box<str>>,
pub container: Option<Box<str>>,
}
#[derive(Debug, PartialEq, Eq, Deserialize, Help)]
pub struct ContainerParam {
pub name: Box<str>,
pub dev_vfio: Option<Box<Path>>,
}