1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use std::io;

use crate::pci::PciBdf;

#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error("io issue encountered: {0}")]
    Io(#[from] io::Error),
    #[error("xenstore issue encountered: {0}")]
    XenStore(#[from] xenstore::error::Error),
    #[error("xencall issue encountered: {0}")]
    XenCall(#[from] xencall::error::Error),
    #[error("domain does not have a tty")]
    TtyNotFound,
    #[error("introducing the domain failed")]
    IntroduceDomainFailed,
    #[error("string conversion of a path failed")]
    PathStringConversion,
    #[error("parent of path not found")]
    PathParentNotFound,
    #[error("domain does not exist")]
    DomainNonExistent,
    #[error("memory setup failed: {0}")]
    MemorySetupFailed(&'static str),
    #[error("populate physmap failed: wanted={0}, received={1}, input_extents={2}")]
    PopulatePhysmapFailed(usize, usize, usize),
    #[error("unknown elf compression method")]
    ElfCompressionUnknown,
    #[error("expected elf image format not found")]
    ElfInvalidImage,
    #[error("provided elf image does not contain xen support")]
    ElfXenSupportMissing,
    #[error("regex error: {0}")]
    RegexError(#[from] regex::Error),
    #[error("error: {0}")]
    GenericError(String),
    #[error("failed to parse int: {0}")]
    ParseIntError(#[from] std::num::ParseIntError),
    #[error("invalid pci bdf string")]
    InvalidPciBdfString,
    #[error("pci device {0} is not assignable")]
    PciDeviceNotAssignable(PciBdf),
    #[error("xen platform error: {0}")]
    XenPlatform(#[from] xenplatform::error::Error),
}

pub type Result<T> = std::result::Result<T, Error>;