mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-21 20:15:21 +00:00
vmm: Use thiserror/anyhow for vmm::Error
This gives a nicer user experience and this error can now be used as the source for other errors based off this. See: #1910 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
6d4656c68f
commit
dfd21cbfc5
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1649,6 +1649,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"signal-hook",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"url",
|
||||
"vfio-ioctls",
|
||||
"virtio-devices",
|
||||
|
@ -13,13 +13,13 @@ kvm = ["hypervisor/kvm"]
|
||||
io_uring = ["virtio-devices/io_uring"]
|
||||
|
||||
[dependencies]
|
||||
arc-swap = ">=0.4.4"
|
||||
bitflags = ">=1.2.1"
|
||||
clap = "2.33.3"
|
||||
acpi_tables = { path = "../acpi_tables", optional = true }
|
||||
anyhow = "1.0"
|
||||
arc-swap = ">=0.4.4"
|
||||
arch = { path = "../arch" }
|
||||
bitflags = ">=1.2.1"
|
||||
block_util = { path = "../block_util" }
|
||||
clap = "2.33.3"
|
||||
devices = { path = "../devices" }
|
||||
epoll = ">=4.0.1"
|
||||
hypervisor = { path = "../hypervisor" }
|
||||
@ -35,6 +35,9 @@ seccomp = { git = "https://github.com/firecracker-microvm/firecracker", tag = "v
|
||||
serde = {version = ">=1.0.27", features = ["rc"] }
|
||||
serde_derive = ">=1.0.27"
|
||||
serde_json = ">=1.0.9"
|
||||
signal-hook = "0.1.16"
|
||||
tempfile = "3.1.0"
|
||||
thiserror = "1.0"
|
||||
url = "2.1.1"
|
||||
vfio-ioctls = { git = "https://github.com/cloud-hypervisor/vfio-ioctls", branch = "ch" }
|
||||
virtio-devices = { path = "../virtio-devices" }
|
||||
@ -44,8 +47,6 @@ vm-memory = { version = "0.3.0", features = ["backend-mmap", "backend-atomic"] }
|
||||
vm-migration = { path = "../vm-migration" }
|
||||
vm-virtio = { path = "../vm-virtio" }
|
||||
vmm-sys-util = { version = ">=0.5.0", features = ["with-serde"] }
|
||||
signal-hook = "0.1.16"
|
||||
tempfile = "3.1.0"
|
||||
|
||||
|
||||
[dependencies.linux-loader]
|
||||
|
@ -39,6 +39,7 @@ use std::path::PathBuf;
|
||||
use std::sync::mpsc::{Receiver, RecvError, SendError, Sender};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{result, thread};
|
||||
use thiserror::Error;
|
||||
use vm_migration::{Pausable, Snapshottable, Transportable};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
@ -57,55 +58,71 @@ pub mod vm;
|
||||
mod acpi;
|
||||
|
||||
/// Errors associated with VMM management
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Error)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum Error {
|
||||
/// API request receive error
|
||||
ApiRequestRecv(RecvError),
|
||||
#[error("Error receiving API request: {0}")]
|
||||
ApiRequestRecv(#[source] RecvError),
|
||||
|
||||
/// API response send error
|
||||
ApiResponseSend(SendError<ApiResponse>),
|
||||
#[error("Error sending API request: {0}")]
|
||||
ApiResponseSend(#[source] SendError<ApiResponse>),
|
||||
|
||||
/// Cannot bind to the UNIX domain socket path
|
||||
Bind(io::Error),
|
||||
#[error("Error binding to UNIX domain socket: {0}")]
|
||||
Bind(#[source] io::Error),
|
||||
|
||||
/// Cannot clone EventFd.
|
||||
EventFdClone(io::Error),
|
||||
#[error("Error cloning EventFd: {0}")]
|
||||
EventFdClone(#[source] io::Error),
|
||||
|
||||
/// Cannot create EventFd.
|
||||
EventFdCreate(io::Error),
|
||||
#[error("Error creating EventFd: {0}")]
|
||||
EventFdCreate(#[source] io::Error),
|
||||
|
||||
/// Cannot read from EventFd.
|
||||
EventFdRead(io::Error),
|
||||
#[error("Error reading from EventFd: {0}")]
|
||||
EventFdRead(#[source] io::Error),
|
||||
|
||||
/// Cannot create epoll context.
|
||||
Epoll(io::Error),
|
||||
#[error("Error creating epoll context: {0}")]
|
||||
Epoll(#[source] io::Error),
|
||||
|
||||
/// Cannot create HTTP thread
|
||||
HttpThreadSpawn(io::Error),
|
||||
#[error("Error spawning HTTP thread: {0}")]
|
||||
HttpThreadSpawn(#[source] io::Error),
|
||||
|
||||
/// Cannot handle the VM STDIN stream
|
||||
#[error("Error handling VM stdin: {0:?}")]
|
||||
Stdin(VmError),
|
||||
|
||||
/// Cannot reboot the VM
|
||||
#[error("Error rebooting VM: {0:?}")]
|
||||
VmReboot(VmError),
|
||||
|
||||
/// Cannot shut a VM down
|
||||
#[error("Error shutting down VM: {0:?}")]
|
||||
VmShutdown(VmError),
|
||||
|
||||
/// Cannot create VMM thread
|
||||
VmmThreadSpawn(io::Error),
|
||||
#[error("Error spawning VMM thread {0:?}")]
|
||||
VmmThreadSpawn(#[source] io::Error),
|
||||
|
||||
/// Cannot shut the VMM down
|
||||
#[error("Error shutting down VMM: {0:?}")]
|
||||
VmmShutdown(VmError),
|
||||
|
||||
// Error following "exe" link
|
||||
ExePathReadLink(io::Error),
|
||||
#[error("Error following \"exe\" link: {0}")]
|
||||
ExePathReadLink(#[source] io::Error),
|
||||
|
||||
/// Cannot create seccomp filter
|
||||
#[error("Error creating seccomp filter: {0}")]
|
||||
CreateSeccompFilter(seccomp::SeccompError),
|
||||
|
||||
/// Cannot apply seccomp filter
|
||||
#[error("Error applying seccomp filter: {0}")]
|
||||
ApplySeccompFilter(seccomp::Error),
|
||||
}
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user