From d7edd9d51fbe16067f06ccb3014a012861a0c52b Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Wed, 21 May 2025 12:30:47 +0200 Subject: [PATCH] misc: vmm: streamline error Display::fmt() The changes were mostly automatically applied using the following Python script: ```python import os, re for root, _, files in os.walk("."): for f in files: if not f.endswith(".rs"): continue p = os.path.join(root, f) with open(p, "r", encoding="utf-8") as file: lines = file.readlines() changed = False for i in range(len(lines) - 1): if re.search(r'#\[error\(".*: \{0[^}]*\}"\)\]', lines[i]) and "#[source]" in lines[i + 1].strip(): lines[i] = re.sub(r': \{0[^}]*\}"\)\]', '")]', lines[i]) changed = True if changed: with open(p, "w", encoding="utf-8") as file: file.writelines(lines) print("Fixed:", p) ``` Signed-off-by: Philipp Schuster On-behalf-of: SAP philipp.schuster@sap.com # Conflicts: # vmm/src/api/http/mod.rs --- vmm/src/api/http/mod.rs | 4 +- vmm/src/api/mod.rs | 64 ++++++------- vmm/src/console_devices.rs | 8 +- vmm/src/coredump.rs | 8 +- vmm/src/cpu.rs | 40 ++++---- vmm/src/device_manager.rs | 180 ++++++++++++++++++------------------ vmm/src/gdb.rs | 24 ++--- vmm/src/igvm/igvm_loader.rs | 6 +- vmm/src/landlock.rs | 4 +- vmm/src/lib.rs | 57 ++++++------ vmm/src/memory_manager.rs | 40 ++++---- vmm/src/serial_manager.rs | 28 +++--- vmm/src/vm.rs | 98 ++++++++++---------- 13 files changed, 281 insertions(+), 280 deletions(-) diff --git a/vmm/src/api/http/mod.rs b/vmm/src/api/http/mod.rs index 49df05a96..3493a3134 100644 --- a/vmm/src/api/http/mod.rs +++ b/vmm/src/api/http/mod.rs @@ -43,7 +43,7 @@ pub type HttpApiHandle = (thread::JoinHandle>, EventFd); #[derive(Error, Debug)] pub enum HttpError { /// API request receive error - #[error("Failed to deserialize JSON: {0}")] + #[error("Failed to deserialize JSON")] SerdeJsonDeserialize(#[from] SerdeError), /// Attempt to access unsupported HTTP method @@ -63,7 +63,7 @@ pub enum HttpError { InternalServerError, /// Error from internal API - #[error("Error from API: {0}")] + #[error("Error from API")] ApiError(#[source] ApiError), } diff --git a/vmm/src/api/mod.rs b/vmm/src/api/mod.rs index f1fdc5bb0..95c4019b4 100644 --- a/vmm/src/api/mod.rs +++ b/vmm/src/api/mod.rs @@ -58,11 +58,11 @@ use crate::Error as VmmError; #[derive(Error, Debug)] pub enum ApiError { /// Cannot write to EventFd. - #[error("Cannot write to EventFd: {0}")] + #[error("Cannot write to EventFd")] EventFdWrite(#[source] io::Error), /// API request send error - #[error("API request send error: {0}")] + #[error("API request send error")] RequestSend(#[source] SendError), /// Wrong response payload type @@ -70,31 +70,31 @@ pub enum ApiError { ResponsePayloadType, /// API response receive error - #[error("API response receive error: {0}")] + #[error("API response receive error")] ResponseRecv(#[source] RecvError), /// The VM could not boot. - #[error("The VM could not boot: {0}")] + #[error("The VM could not boot")] VmBoot(#[source] VmError), /// The VM could not be created. - #[error("The VM could not be created: {0}")] + #[error("The VM could not be created")] VmCreate(#[source] VmError), /// The VM could not be deleted. - #[error("The VM could not be deleted: {0}")] + #[error("The VM could not be deleted")] VmDelete(#[source] VmError), /// The VM info is not available. - #[error("The VM info is not available: {0}")] + #[error("The VM info is not available")] VmInfo(#[source] VmError), /// The VM could not be paused. - #[error("The VM could not be paused: {0}")] + #[error("The VM could not be paused")] VmPause(#[source] VmError), /// The VM could not resume. - #[error("The VM could not resume: {0}")] + #[error("The VM could not resume")] VmResume(#[source] VmError), /// The VM is not booted. @@ -106,95 +106,95 @@ pub enum ApiError { VmNotCreated, /// The VM could not shutdown. - #[error("The VM could not shutdown: {0}")] + #[error("The VM could not shutdown")] VmShutdown(#[source] VmError), /// The VM could not reboot. - #[error("The VM could not reboot: {0}")] + #[error("The VM could not reboot")] VmReboot(#[source] VmError), /// The VM could not be snapshotted. - #[error("The VM could not be snapshotted: {0}")] + #[error("The VM could not be snapshotted")] VmSnapshot(#[source] VmError), /// The VM could not restored. - #[error("The VM could not restored: {0}")] + #[error("The VM could not restored")] VmRestore(#[source] VmError), /// The VM could not be coredumped. - #[error("The VM could not be coredumped: {0}")] + #[error("The VM could not be coredumped")] VmCoredump(#[source] VmError), /// The VMM could not shutdown. - #[error("The VMM could not shutdown: {0}")] + #[error("The VMM could not shutdown")] VmmShutdown(#[source] VmError), /// The VM could not be resized - #[error("The VM could not be resized: {0}")] + #[error("The VM could not be resized")] VmResize(#[source] VmError), /// The memory zone could not be resized. - #[error("The memory zone could not be resized: {0}")] + #[error("The memory zone could not be resized")] VmResizeZone(#[source] VmError), /// The device could not be added to the VM. - #[error("The device could not be added to the VM: {0}")] + #[error("The device could not be added to the VM")] VmAddDevice(#[source] VmError), /// The user device could not be added to the VM. - #[error("The user device could not be added to the VM: {0}")] + #[error("The user device could not be added to the VM")] VmAddUserDevice(#[source] VmError), /// The device could not be removed from the VM. - #[error("The device could not be removed from the VM: {0}")] + #[error("The device could not be removed from the VM")] VmRemoveDevice(#[source] VmError), /// Cannot create seccomp filter - #[error("Cannot create seccomp filter: {0}")] + #[error("Cannot create seccomp filter")] CreateSeccompFilter(#[source] seccompiler::Error), /// Cannot apply seccomp filter - #[error("Cannot apply seccomp filter: {0}")] + #[error("Cannot apply seccomp filter")] ApplySeccompFilter(#[source] seccompiler::Error), /// The disk could not be added to the VM. - #[error("The disk could not be added to the VM: {0}")] + #[error("The disk could not be added to the VM")] VmAddDisk(#[source] VmError), /// The fs could not be added to the VM. - #[error("The fs could not be added to the VM: {0}")] + #[error("The fs could not be added to the VM")] VmAddFs(#[source] VmError), /// The pmem device could not be added to the VM. - #[error("The pmem device could not be added to the VM: {0}")] + #[error("The pmem device could not be added to the VM")] VmAddPmem(#[source] VmError), /// The network device could not be added to the VM. - #[error("The network device could not be added to the VM: {0}")] + #[error("The network device could not be added to the VM")] VmAddNet(#[source] VmError), /// The vDPA device could not be added to the VM. - #[error("The vDPA device could not be added to the VM: {0}")] + #[error("The vDPA device could not be added to the VM")] VmAddVdpa(#[source] VmError), /// The vsock device could not be added to the VM. - #[error("The vsock device could not be added to the VM: {0}")] + #[error("The vsock device could not be added to the VM")] VmAddVsock(#[source] VmError), /// Error starting migration receiver - #[error("Error starting migration receiver: {0}")] + #[error("Error starting migration receiver")] VmReceiveMigration(#[source] MigratableError), /// Error starting migration sender - #[error("Error starting migration sender: {0}")] + #[error("Error starting migration sender")] VmSendMigration(#[source] MigratableError), /// Error triggering power button - #[error("Error triggering power button: {0}")] + #[error("Error triggering power button")] VmPowerButton(#[source] VmError), /// Error triggering NMI - #[error("Error triggering NMI: {0}")] + #[error("Error triggering NMI")] VmNmi(#[source] VmError), } pub type ApiResult = Result; diff --git a/vmm/src/console_devices.rs b/vmm/src/console_devices.rs index 6484e3945..c4137733b 100644 --- a/vmm/src/console_devices.rs +++ b/vmm/src/console_devices.rs @@ -33,7 +33,7 @@ const TIOCGPTPEER: libc::c_int = 0x5441; #[derive(Debug, Error)] pub enum ConsoleDeviceError { /// Error creating console device - #[error("Error creating console device: {0}")] + #[error("Error creating console device")] CreateConsoleDevice(#[source] io::Error), /// No socket option support for console device @@ -41,15 +41,15 @@ pub enum ConsoleDeviceError { NoSocketOptionSupportForConsoleDevice, /// Error setting pty raw mode - #[error("Error setting pty raw mode: {0}")] + #[error("Error setting pty raw mode")] SetPtyRaw(#[source] vmm_sys_util::errno::Error), /// Cannot duplicate file descriptor - #[error("Cannot duplicate file descriptor: {0}")] + #[error("Cannot duplicate file descriptor")] DupFd(#[source] vmm_sys_util::errno::Error), /// Error starting sigwinch listener - #[error("Error starting sigwinch listener: {0}")] + #[error("Error starting sigwinch listener")] StartSigwinchListener(#[source] std::io::Error), } diff --git a/vmm/src/coredump.rs b/vmm/src/coredump.rs index 3ff02e97c..711fda289 100644 --- a/vmm/src/coredump.rs +++ b/vmm/src/coredump.rs @@ -36,13 +36,13 @@ pub struct DumpState { #[derive(Error, Debug)] pub enum GuestDebuggableError { - #[error("coredump: {0}")] + #[error("coredump")] Coredump(#[source] anyhow::Error), - #[error("coredump file: {0}")] + #[error("coredump file")] CoredumpFile(#[source] std::io::Error), - #[error("Failed to pause: {0}")] + #[error("Failed to pause")] Pause(#[source] vm_migration::MigratableError), - #[error("Failed to resume: {0}")] + #[error("Failed to resume")] Resume(#[source] vm_migration::MigratableError), } diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 002f819a3..e26946538 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -113,48 +113,48 @@ pub const CPU_MANAGER_ACPI_SIZE: usize = 0xc; #[derive(Debug, Error)] pub enum Error { - #[error("Error creating vCPU: {0}")] + #[error("Error creating vCPU")] VcpuCreate(#[source] anyhow::Error), - #[error("Error running vCPU: {0}")] + #[error("Error running vCPU")] VcpuRun(#[source] anyhow::Error), - #[error("Error spawning vCPU thread: {0}")] + #[error("Error spawning vCPU thread")] VcpuSpawn(#[source] io::Error), - #[error("Error generating common CPUID: {0}")] + #[error("Error generating common CPUID")] CommonCpuId(#[source] arch::Error), - #[error("Error configuring vCPU: {0}")] + #[error("Error configuring vCPU")] VcpuConfiguration(#[source] arch::Error), #[error("Still pending removed vCPU")] VcpuPendingRemovedVcpu, #[cfg(target_arch = "aarch64")] - #[error("Error fetching preferred target: {0}")] + #[error("Error fetching preferred target")] VcpuArmPreferredTarget(#[source] hypervisor::HypervisorVmError), #[cfg(target_arch = "aarch64")] - #[error("Error setting vCPU processor features: {0}")] + #[error("Error setting vCPU processor features")] VcpuSetProcessorFeatures(#[source] hypervisor::HypervisorCpuError), #[cfg(target_arch = "aarch64")] - #[error("Error initialising vCPU: {0}")] + #[error("Error initialising vCPU")] VcpuArmInit(#[source] hypervisor::HypervisorCpuError), #[cfg(target_arch = "aarch64")] - #[error("Error finalising vCPU: {0}")] + #[error("Error finalising vCPU")] VcpuArmFinalize(#[source] hypervisor::HypervisorCpuError), #[cfg(target_arch = "aarch64")] - #[error("Error initialising GICR base address: {0}")] + #[error("Error initialising GICR base address")] VcpuSetGicrBaseAddr(#[source] hypervisor::HypervisorCpuError), #[error("Failed to join on vCPU threads: {0:?}")] ThreadCleanup(std::boxed::Box), - #[error("Error adding CpuManager to MMIO bus: {0}")] + #[error("Error adding CpuManager to MMIO bus")] BusError(#[source] vm_device::BusError), #[error("Requested zero vCPUs")] @@ -163,13 +163,13 @@ pub enum Error { #[error("Requested vCPUs exceed maximum")] DesiredVCpuCountExceedsMax, - #[error("Cannot create seccomp filter: {0}")] + #[error("Cannot create seccomp filter")] CreateSeccompFilter(#[source] seccompiler::Error), - #[error("Cannot apply seccomp filter: {0}")] + #[error("Cannot apply seccomp filter")] ApplySeccompFilter(#[source] seccompiler::Error), - #[error("Error starting vCPU after restore: {0}")] + #[error("Error starting vCPU after restore")] StartRestoreVcpu(#[source] anyhow::Error), #[error("Unexpected VmExit")] @@ -179,30 +179,30 @@ pub enum Error { AllocateMmmioAddress, #[cfg(feature = "tdx")] - #[error("Error initializing TDX: {0}")] + #[error("Error initializing TDX")] InitializeTdx(#[source] hypervisor::HypervisorCpuError), #[cfg(target_arch = "aarch64")] - #[error("Error initializing PMU: {0}")] + #[error("Error initializing PMU")] InitPmu(#[source] hypervisor::HypervisorCpuError), #[cfg(feature = "guest_debug")] - #[error("Error during CPU debug: {0}")] + #[error("Error during CPU debug")] CpuDebug(#[source] hypervisor::HypervisorCpuError), #[cfg(feature = "guest_debug")] - #[error("Error translating virtual address: {0}")] + #[error("Error translating virtual address")] TranslateVirtualAddress(#[source] anyhow::Error), #[cfg(target_arch = "x86_64")] - #[error("Error setting up AMX: {0}")] + #[error("Error setting up AMX")] AmxEnable(#[source] anyhow::Error), #[error("Maximum number of vCPUs exceeds host limit")] MaximumVcpusExceeded, #[cfg(feature = "sev_snp")] - #[error("Failed to set sev control register: {0}")] + #[error("Failed to set sev control register")] SetSevControlRegister(#[source] hypervisor::HypervisorCpuError), #[cfg(target_arch = "x86_64")] diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index d228010c0..fccdd75bf 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -151,35 +151,35 @@ const VIRTIO_PCI_DEVICE_NAME_PREFIX: &str = "_virtio-pci"; #[derive(Error, Debug)] pub enum DeviceManagerError { /// Cannot create EventFd. - #[error("Cannot create EventFd: {0}")] + #[error("Cannot create EventFd")] EventFd(#[source] io::Error), /// Cannot open disk path - #[error("Cannot open disk path: {0}")] + #[error("Cannot open disk path")] Disk(#[source] io::Error), /// Cannot create vhost-user-net device - #[error("Cannot create vhost-user-net device: {0}")] + #[error("Cannot create vhost-user-net device")] CreateVhostUserNet(#[source] virtio_devices::vhost_user::Error), /// Cannot create virtio-blk device - #[error("Cannot create virtio-blk device: {0}")] + #[error("Cannot create virtio-blk device")] CreateVirtioBlock(#[source] io::Error), /// Cannot create virtio-net device - #[error("Cannot create virtio-net device: {0}")] + #[error("Cannot create virtio-net device")] CreateVirtioNet(#[source] virtio_devices::net::Error), /// Cannot create virtio-console device - #[error("Cannot create virtio-console device: {0}")] + #[error("Cannot create virtio-console device")] CreateVirtioConsole(#[source] io::Error), /// Cannot create virtio-rng device - #[error("Cannot create virtio-rng device: {0}")] + #[error("Cannot create virtio-rng device")] CreateVirtioRng(#[source] io::Error), /// Cannot create virtio-fs device - #[error("Cannot create virtio-fs device: {0}")] + #[error("Cannot create virtio-fs device")] CreateVirtioFs(#[source] virtio_devices::vhost_user::Error), /// Virtio-fs device was created without a socket. @@ -187,23 +187,23 @@ pub enum DeviceManagerError { NoVirtioFsSock, /// Cannot create vhost-user-blk device - #[error("Cannot create vhost-user-blk device: {0}")] + #[error("Cannot create vhost-user-blk device")] CreateVhostUserBlk(#[source] virtio_devices::vhost_user::Error), /// Cannot create virtio-pmem device - #[error("Cannot create virtio-pmem device: {0}")] + #[error("Cannot create virtio-pmem device")] CreateVirtioPmem(#[source] io::Error), /// Cannot create vDPA device - #[error("Cannot create vdpa device: {0}")] + #[error("Cannot create vdpa device")] CreateVdpa(#[source] virtio_devices::vdpa::Error), /// Cannot create virtio-vsock device - #[error("Cannot create virtio-vsock device: {0}")] + #[error("Cannot create virtio-vsock device")] CreateVirtioVsock(#[source] io::Error), /// Cannot create tpm device - #[error("Cannot create tmp device: {0}")] + #[error("Cannot create tmp device")] CreateTpmDevice(#[source] anyhow::Error), /// Failed to convert Path to &str for the vDPA device. @@ -215,44 +215,44 @@ pub enum DeviceManagerError { CreateVsockConvertPath, /// Cannot create virtio-vsock backend - #[error("Cannot create virtio-vsock backend: {0}")] + #[error("Cannot create virtio-vsock backend")] CreateVsockBackend(#[source] virtio_devices::vsock::VsockUnixError), /// Cannot create virtio-iommu device - #[error("Cannot create virtio-iommu device: {0}")] + #[error("Cannot create virtio-iommu device")] CreateVirtioIommu(#[source] io::Error), /// Cannot create virtio-balloon device - #[error("Cannot create virtio-balloon device: {0}")] + #[error("Cannot create virtio-balloon device")] CreateVirtioBalloon(#[source] io::Error), /// Cannot create pvmemcontrol device #[cfg(feature = "pvmemcontrol")] - #[error("Cannot create pvmemcontrol device: {0}")] + #[error("Cannot create pvmemcontrol device")] CreatePvmemcontrol(#[source] io::Error), /// Cannot create virtio-watchdog device - #[error("Cannot create virtio-watchdog device: {0}")] + #[error("Cannot create virtio-watchdog device")] CreateVirtioWatchdog(#[source] io::Error), /// Failed to parse disk image format - #[error("Failed to parse disk image format: {0}")] + #[error("Failed to parse disk image format")] DetectImageType(#[source] io::Error), /// Cannot open qcow disk path - #[error("Cannot open qcow disk path: {0}")] + #[error("Cannot open qcow disk path")] QcowDeviceCreate(#[source] qcow::Error), /// Cannot create serial manager - #[error("Cannot create serial manager: {0}")] + #[error("Cannot create serial manager")] CreateSerialManager(#[source] SerialManagerError), /// Cannot spawn the serial manager thread - #[error("Cannot spawn serial manager thread: {0}")] + #[error("Cannot spawn serial manager thread")] SpawnSerialManager(#[source] SerialManagerError), /// Cannot open tap interface - #[error("Cannot open tap interface: {0}")] + #[error("Cannot open tap interface")] OpenTap(#[source] net_util::TapError), /// Cannot allocate IRQ. @@ -260,39 +260,39 @@ pub enum DeviceManagerError { AllocateIrq, /// Cannot configure the IRQ. - #[error("Cannot configure the IRQ: {0}")] + #[error("Cannot configure the IRQ")] Irq(#[source] vmm_sys_util::errno::Error), /// Cannot allocate PCI BARs - #[error("Cannot allocate PCI BARs: {0}")] + #[error("Cannot allocate PCI BARs")] AllocateBars(#[source] pci::PciDeviceError), /// Could not free the BARs associated with a PCI device. - #[error("Could not free the BARs associated with a PCI device: {0}")] + #[error("Could not free the BARs associated with a PCI device")] FreePciBars(#[source] pci::PciDeviceError), /// Cannot register ioevent. - #[error("Cannot register ioevent: {0}")] + #[error("Cannot register ioevent")] RegisterIoevent(#[source] anyhow::Error), /// Cannot unregister ioevent. - #[error("Cannot unregister ioevent: {0}")] + #[error("Cannot unregister ioevent")] UnRegisterIoevent(#[source] anyhow::Error), /// Cannot create virtio device - #[error("Cannot create virtio device: {0}")] + #[error("Cannot create virtio device")] VirtioDevice(#[source] virtio_devices::transport::VirtioPciDeviceError), /// Cannot add PCI device - #[error("Cannot add PCI device: {0}")] + #[error("Cannot add PCI device")] AddPciDevice(#[source] pci::PciRootError), /// Cannot open persistent memory file - #[error("Cannot open persistent memory file: {0}")] + #[error("Cannot open persistent memory file")] PmemFileOpen(#[source] io::Error), /// Cannot set persistent memory file size - #[error("Cannot set persistent memory file size: {0}")] + #[error("Cannot set persistent memory file size")] PmemFileSetLen(#[source] io::Error), /// Cannot find a memory range for persistent memory @@ -304,68 +304,68 @@ pub enum DeviceManagerError { FsRangeAllocation, /// Error creating serial output file - #[error("Error creating serial output file: {0}")] + #[error("Error creating serial output file")] SerialOutputFileOpen(#[source] io::Error), /// Error creating debug-console output file #[cfg(target_arch = "x86_64")] - #[error("Error creating debug-console output file: {0}")] + #[error("Error creating debug-console output file")] DebugconOutputFileOpen(#[source] io::Error), /// Error creating console output file - #[error("Error creating console output file: {0}")] + #[error("Error creating console output file")] ConsoleOutputFileOpen(#[source] io::Error), /// Error creating serial pty - #[error("Error creating serial pty: {0}")] + #[error("Error creating serial pty")] SerialPtyOpen(#[source] io::Error), /// Error creating console pty - #[error("Error creating console pty: {0}")] + #[error("Error creating console pty")] ConsolePtyOpen(#[source] io::Error), /// Error creating debugcon pty - #[error("Error creating console pty: {0}")] + #[error("Error creating console pty")] DebugconPtyOpen(#[source] io::Error), /// Error setting pty raw mode - #[error("Error setting pty raw mode: {0}")] + #[error("Error setting pty raw mode")] SetPtyRaw(#[source] ConsoleDeviceError), /// Error getting pty peer - #[error("Error getting pty peer: {0}")] + #[error("Error getting pty peer")] GetPtyPeer(#[source] vmm_sys_util::errno::Error), /// Cannot create a VFIO device - #[error("Cannot create a VFIO device: {0}")] + #[error("Cannot create a VFIO device")] VfioCreate(#[source] vfio_ioctls::VfioError), /// Cannot create a VFIO PCI device - #[error("Cannot create a VFIO PCI device: {0}")] + #[error("Cannot create a VFIO PCI device")] VfioPciCreate(#[source] pci::VfioPciError), /// Failed to map VFIO MMIO region. - #[error("Failed to map VFIO MMIO region: {0}")] + #[error("Failed to map VFIO MMIO region")] VfioMapRegion(#[source] pci::VfioPciError), /// Failed to DMA map VFIO device. - #[error("Failed to DMA map VFIO device: {0}")] + #[error("Failed to DMA map VFIO device")] VfioDmaMap(#[source] vfio_ioctls::VfioError), /// Failed to DMA unmap VFIO device. - #[error("Failed to DMA unmap VFIO device: {0}")] + #[error("Failed to DMA unmap VFIO device")] VfioDmaUnmap(#[source] pci::VfioPciError), /// Failed to create the passthrough device. - #[error("Failed to create the passthrough device: {0}")] + #[error("Failed to create the passthrough device")] CreatePassthroughDevice(#[source] anyhow::Error), /// Failed to memory map. - #[error("Failed to memory map: {0}")] + #[error("Failed to memory map")] Mmap(#[source] io::Error), /// Cannot add legacy device to Bus. - #[error("Cannot add legacy device to Bus: {0}")] + #[error("Cannot add legacy device to Bus")] BusError(#[source] vm_device::BusError), /// Failed to allocate IO port @@ -377,27 +377,27 @@ pub enum DeviceManagerError { AllocateMmioAddress, /// Failed to make hotplug notification - #[error("Failed to make hotplug notification: {0}")] + #[error("Failed to make hotplug notification")] HotPlugNotification(#[source] io::Error), /// Error from a memory manager operation - #[error("Error from a memory manager operation: {0}")] + #[error("Error from a memory manager operation")] MemoryManager(#[source] MemoryManagerError), /// Failed to create new interrupt source group. - #[error("Failed to create new interrupt source group: {0}")] + #[error("Failed to create new interrupt source group")] CreateInterruptGroup(#[source] io::Error), /// Failed to update interrupt source group. - #[error("Failed to update interrupt source group: {0}")] + #[error("Failed to update interrupt source group")] UpdateInterruptGroup(#[source] io::Error), /// Failed to create interrupt controller. - #[error("Failed to create interrupt controller: {0}")] + #[error("Failed to create interrupt controller")] CreateInterruptController(#[source] interrupt_controller::Error), /// Failed to create a new MmapRegion instance. - #[error("Failed to create a new MmapRegion instance: {0}")] + #[error("Failed to create a new MmapRegion instance")] NewMmapRegion(#[source] vm_memory::mmap::MmapRegionError), /// Failed to clone a File. @@ -405,15 +405,15 @@ pub enum DeviceManagerError { CloneFile(#[source] io::Error), /// Failed to create socket file - #[error("Failed to create socket file: {0}")] + #[error("Failed to create socket file")] CreateSocketFile(#[source] io::Error), /// Failed to spawn the network backend - #[error("Failed to spawn the network backend: {0}")] + #[error("Failed to spawn the network backend")] SpawnNetBackend(#[source] io::Error), /// Failed to spawn the block backend - #[error("Failed to spawn the block backend: {0}")] + #[error("Failed to spawn the block backend")] SpawnBlockBackend(#[source] io::Error), /// Missing PCI bus. @@ -429,15 +429,15 @@ pub enum DeviceManagerError { MissingPciDevice, /// Failed to remove a PCI device from the PCI bus. - #[error("Failed to remove a PCI device from the PCI bus: {0}")] + #[error("Failed to remove a PCI device from the PCI bus")] RemoveDeviceFromPciBus(#[source] pci::PciRootError), /// Failed to remove a bus device from the IO bus. - #[error("Failed to remove a bus device from the IO bus: {0}")] + #[error("Failed to remove a bus device from the IO bus")] RemoveDeviceFromIoBus(#[source] vm_device::BusError), /// Failed to remove a bus device from the MMIO bus. - #[error("Failed to remove a bus device from the MMIO bus: {0}")] + #[error("Failed to remove a bus device from the MMIO bus")] RemoveDeviceFromMmioBus(#[source] vm_device::BusError), /// Failed to find the device corresponding to a specific PCI b/d/f. @@ -453,15 +453,15 @@ pub enum DeviceManagerError { UnknownDeviceId(String), /// Failed to find an available PCI device ID. - #[error("Failed to find an available PCI device ID: {0}")] + #[error("Failed to find an available PCI device ID")] NextPciDeviceId(#[source] pci::PciRootError), /// Could not reserve the PCI device ID. - #[error("Could not reserve the PCI device ID: {0}")] + #[error("Could not reserve the PCI device ID")] GetPciDeviceId(#[source] pci::PciRootError), /// Could not give the PCI device ID back. - #[error("Could not give the PCI device ID back: {0}")] + #[error("Could not give the PCI device ID back")] PutPciDeviceId(#[source] pci::PciRootError), /// No disk path was specified when one was expected @@ -469,11 +469,11 @@ pub enum DeviceManagerError { NoDiskPath, /// Failed to update guest memory for virtio device. - #[error("Failed to update guest memory for virtio device: {0}")] + #[error("Failed to update guest memory for virtio device")] UpdateMemoryForVirtioDevice(#[source] virtio_devices::Error), /// Cannot create virtio-mem device - #[error("Cannot create virtio-mem device: {0}")] + #[error("Cannot create virtio-mem device")] CreateVirtioMem(#[source] io::Error), /// Cannot find a memory range for virtio-mem memory @@ -481,7 +481,7 @@ pub enum DeviceManagerError { VirtioMemRangeAllocation, /// Failed to update guest memory for VFIO PCI device. - #[error("Failed to update guest memory for VFIO PCI device: {0}")] + #[error("Failed to update guest memory for VFIO PCI device")] UpdateMemoryForVfioPciDevice(#[source] vfio_ioctls::VfioError), /// Trying to use a directory for pmem but no size specified @@ -517,7 +517,7 @@ pub enum DeviceManagerError { NoSocketOptionSupportForConsoleDevice, /// Failed to resize virtio-balloon - #[error("Failed to resize virtio-balloon: {0}")] + #[error("Failed to resize virtio-balloon")] VirtioBalloonResize(#[source] virtio_devices::balloon::Error), /// Missing virtio-balloon, can't proceed as expected. @@ -529,12 +529,12 @@ pub enum DeviceManagerError { MissingVirtualIommu, /// Failed to do power button notification - #[error("Failed to do power button notification: {0}")] + #[error("Failed to do power button notification")] PowerButtonNotification(#[source] io::Error), /// Failed to do AArch64 GPIO power button notification #[cfg(target_arch = "aarch64")] - #[error("Failed to do AArch64 GPIO power button notification: {0}")] + #[error("Failed to do AArch64 GPIO power button notification")] AArch64PowerButtonNotification(#[source] devices::legacy::GpioDeviceError), /// Failed to set O_DIRECT flag to file descriptor @@ -542,63 +542,63 @@ pub enum DeviceManagerError { SetDirectIo, /// Failed to create FixedVhdDiskAsync - #[error("Failed to create FixedVhdDiskAsync: {0}")] + #[error("Failed to create FixedVhdDiskAsync")] CreateFixedVhdDiskAsync(#[source] io::Error), /// Failed to create FixedVhdDiskSync - #[error("Failed to create FixedVhdDiskSync: {0}")] + #[error("Failed to create FixedVhdDiskSync")] CreateFixedVhdDiskSync(#[source] io::Error), /// Failed to create QcowDiskSync - #[error("Failed to create QcowDiskSync: {0}")] + #[error("Failed to create QcowDiskSync")] CreateQcowDiskSync(#[source] qcow::Error), /// Failed to create FixedVhdxDiskSync - #[error("Failed to create FixedVhdxDiskSync: {0}")] + #[error("Failed to create FixedVhdxDiskSync")] CreateFixedVhdxDiskSync(#[source] vhdx::VhdxError), /// Failed to add DMA mapping handler to virtio-mem device. - #[error("Failed to add DMA mapping handler to virtio-mem device: {0}")] + #[error("Failed to add DMA mapping handler to virtio-mem device")] AddDmaMappingHandlerVirtioMem(#[source] virtio_devices::mem::Error), /// Failed to remove DMA mapping handler from virtio-mem device. - #[error("Failed to remove DMA mapping handler from virtio-mem device: {0}")] + #[error("Failed to remove DMA mapping handler from virtio-mem device")] RemoveDmaMappingHandlerVirtioMem(#[source] virtio_devices::mem::Error), /// Failed to create vfio-user client - #[error("Failed to create vfio-user client: {0}")] + #[error("Failed to create vfio-user client")] VfioUserCreateClient(#[source] vfio_user::Error), /// Failed to create VFIO user device - #[error("Failed to create VFIO user device: {0}")] + #[error("Failed to create VFIO user device")] VfioUserCreate(#[source] VfioUserPciDeviceError), /// Failed to map region from VFIO user device into guest - #[error("Failed to map region from VFIO user device into guest: {0}")] + #[error("Failed to map region from VFIO user device into guest")] VfioUserMapRegion(#[source] VfioUserPciDeviceError), /// Failed to DMA map VFIO user device. - #[error("Failed to DMA map VFIO user device: {0}")] + #[error("Failed to DMA map VFIO user device")] VfioUserDmaMap(#[source] VfioUserPciDeviceError), /// Failed to DMA unmap VFIO user device. - #[error("Failed to DMA unmap VFIO user device: {0}")] + #[error("Failed to DMA unmap VFIO user device")] VfioUserDmaUnmap(#[source] VfioUserPciDeviceError), /// Failed to update memory mappings for VFIO user device - #[error("Failed to update memory mappings for VFIO user device: {0}")] + #[error("Failed to update memory mappings for VFIO user device")] UpdateMemoryForVfioUserPciDevice(#[source] VfioUserPciDeviceError), /// Cannot duplicate file descriptor - #[error("Cannot duplicate file descriptor: {0}")] + #[error("Cannot duplicate file descriptor")] DupFd(#[source] vmm_sys_util::errno::Error), /// Failed to DMA map virtio device. - #[error("Failed to DMA map virtio device: {0}")] + #[error("Failed to DMA map virtio device")] VirtioDmaMap(#[source] std::io::Error), /// Failed to DMA unmap virtio device. - #[error("Failed to DMA unmap virtio device: {0}")] + #[error("Failed to DMA unmap virtio device")] VirtioDmaUnmap(#[source] std::io::Error), /// Cannot hotplug device behind vIOMMU @@ -614,23 +614,23 @@ pub enum DeviceManagerError { InvalidIdentifier(String), /// Error activating virtio device - #[error("Error activating virtio device: {0}")] + #[error("Error activating virtio device")] VirtioActivate(#[source] ActivateError), /// Failed retrieving device state from snapshot - #[error("Failed retrieving device state from snapshot: {0}")] + #[error("Failed retrieving device state from snapshot")] RestoreGetState(#[source] MigratableError), /// Cannot create a PvPanic device - #[error("Cannot create a PvPanic device: {0}")] + #[error("Cannot create a PvPanic device")] PvPanicCreate(#[source] devices::pvpanic::PvPanicError), /// Cannot create a RateLimiterGroup - #[error("Cannot create a RateLimiterGroup: {0}")] + #[error("Cannot create a RateLimiterGroup")] RateLimiterGroupCreate(#[source] rate_limiter::group::Error), /// Cannot start sigwinch listener - #[error("Cannot start sigwinch listener: {0}")] + #[error("Cannot start sigwinch listener")] StartSigwinchListener(#[source] std::io::Error), // Invalid console info @@ -642,7 +642,7 @@ pub enum DeviceManagerError { InvalidConsoleFd, /// Cannot lock images of all block devices. - #[error("Cannot lock images of all block devices: {0}")] + #[error("Cannot lock images of all block devices")] DiskLockError(#[source] virtio_devices::block::Error), } diff --git a/vmm/src/gdb.rs b/vmm/src/gdb.rs index 955372aee..16c9f64d9 100644 --- a/vmm/src/gdb.rs +++ b/vmm/src/gdb.rs @@ -38,21 +38,21 @@ type ArchUsize = u64; #[derive(Error, Debug)] pub enum DebuggableError { - #[error("Setting debug failed: {0}")] + #[error("Setting debug failed")] SetDebug(#[source] hypervisor::HypervisorCpuError), - #[error("Pausing failed: {0}")] + #[error("Pausing failed")] Pause(#[source] vm_migration::MigratableError), - #[error("Resuming failed: {0}")] + #[error("Resuming failed")] Resume(#[source] vm_migration::MigratableError), - #[error("Reading registers failed: {0}")] + #[error("Reading registers failed")] ReadRegs(#[source] crate::cpu::Error), - #[error("Writing registers failed: {0}")] + #[error("Writing registers failed")] WriteRegs(#[source] crate::cpu::Error), - #[error("Reading memory failed: {0}")] + #[error("Reading memory failed")] ReadMem(#[source] GuestMemoryError), - #[error("Writing memory failed: {0}")] + #[error("Writing memory failed")] WriteMem(#[source] GuestMemoryError), - #[error("Translating GVA failed: {0}")] + #[error("Translating GVA failed")] TranslateGva(#[source] crate::cpu::Error), #[error("The lock is poisened")] PoisonedState, @@ -92,15 +92,15 @@ pub trait Debuggable: vm_migration::Pausable { #[derive(Error, Debug)] pub enum Error { - #[error("VM failed: {0}")] + #[error("VM failed")] Vm(#[source] crate::vm::Error), #[error("GDB request failed")] GdbRequest, - #[error("GDB couldn't be notified: {0}")] + #[error("GDB couldn't be notified")] GdbResponseNotify(#[source] std::io::Error), - #[error("GDB response failed: {0}")] + #[error("GDB response failed")] GdbResponse(#[source] mpsc::RecvError), - #[error("GDB response timeout: {0}")] + #[error("GDB response timeout")] GdbResponseTimeout(#[source] mpsc::RecvTimeoutError), } type GdbResult = std::result::Result; diff --git a/vmm/src/igvm/igvm_loader.rs b/vmm/src/igvm/igvm_loader.rs index 46ccfa7bd..75eeb3358 100644 --- a/vmm/src/igvm/igvm_loader.rs +++ b/vmm/src/igvm/igvm_loader.rs @@ -40,11 +40,11 @@ pub enum Error { Loader(#[source] crate::igvm::loader::Error), #[error("parameter too large for parameter area")] ParameterTooLarge, - #[error("Error importing isolated pages: {0}")] + #[error("Error importing isolated pages")] ImportIsolatedPages(#[source] hypervisor::HypervisorVmError), - #[error("Error completing importing isolated pages: {0}")] + #[error("Error completing importing isolated pages")] CompleteIsolatedImport(#[source] hypervisor::HypervisorVmError), - #[error("Error decoding host data: {0}")] + #[error("Error decoding host data")] FailedToDecodeHostData(#[source] hex::FromHexError), } diff --git a/vmm/src/landlock.rs b/vmm/src/landlock.rs index 913723899..3defeaefb 100644 --- a/vmm/src/landlock.rs +++ b/vmm/src/landlock.rs @@ -17,11 +17,11 @@ use thiserror::Error; #[derive(Debug, Error)] pub enum LandlockError { /// All RulesetErrors from Landlock library are wrapped in this error - #[error("Error creating/adding/restricting ruleset: {0}")] + #[error("Error creating/adding/restricting ruleset")] ManageRuleset(#[source] RulesetError), /// Error opening path - #[error("Error opening path: {0}")] + #[error("Error opening path")] OpenPath(#[source] IoError), /// Invalid Landlock access diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index cfb81509e..2cf1cb6e9 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -98,118 +98,119 @@ type GuestRegionMmap = vm_memory::GuestRegionMmap; #[derive(Debug, Error)] pub enum Error { /// API request receive error - #[error("Error receiving API request: {0}")] + #[error("Error receiving API request")] ApiRequestRecv(#[source] RecvError), /// API response send error - #[error("Error sending API request: {0}")] + #[error("Error sending API request")] ApiResponseSend(#[source] SendError), /// Cannot bind to the UNIX domain socket path - #[error("Error binding to UNIX domain socket: {0}")] + #[error("Error binding to UNIX domain socket")] Bind(#[source] io::Error), /// Cannot clone EventFd. - #[error("Error cloning EventFd: {0}")] + #[error("Error cloning EventFd")] EventFdClone(#[source] io::Error), /// Cannot create EventFd. - #[error("Error creating EventFd: {0}")] + #[error("Error creating EventFd")] EventFdCreate(#[source] io::Error), /// Cannot read from EventFd. - #[error("Error reading from EventFd: {0}")] + #[error("Error reading from EventFd")] EventFdRead(#[source] io::Error), /// Cannot create epoll context. - #[error("Error creating epoll context: {0}")] + #[error("Error creating epoll context")] Epoll(#[source] io::Error), /// Cannot create HTTP thread - #[error("Error spawning HTTP thread: {0}")] + #[error("Error spawning HTTP thread")] HttpThreadSpawn(#[source] io::Error), /// Cannot create D-Bus thread #[cfg(feature = "dbus_api")] - #[error("Error spawning D-Bus thread: {0}")] + #[error("Error spawning D-Bus thread")] DBusThreadSpawn(#[source] io::Error), /// Cannot start D-Bus session #[cfg(feature = "dbus_api")] - #[error("Error starting D-Bus session: {0}")] + #[error("Error starting D-Bus session")] CreateDBusSession(#[source] zbus::Error), /// Cannot create `event-monitor` thread - #[error("Error spawning `event-monitor` thread: {0}")] + #[error("Error spawning `event-monitor` thread")] EventMonitorThreadSpawn(#[source] io::Error), /// Cannot handle the VM STDIN stream - #[error("Error handling VM stdin: {0:?}")] + #[error("Error handling VM stdin")] Stdin(#[source] VmError), /// Cannot handle the VM pty stream - #[error("Error handling VM pty: {0:?}")] + #[error("Error handling VM pty")] Pty(#[source] VmError), /// Cannot reboot the VM - #[error("Error rebooting VM: {0:?}")] + #[error("Error rebooting VM")] VmReboot(#[source] VmError), /// Cannot create VMM thread - #[error("Error spawning VMM thread {0:?}")] + #[error("Error spawning VMM thread")] VmmThreadSpawn(#[source] io::Error), /// Cannot shut the VMM down - #[error("Error shutting down VMM: {0:?}")] + #[error("Error shutting down VMM")] VmmShutdown(#[source] VmError), /// Cannot create seccomp filter - #[error("Error creating seccomp filter: {0}")] + #[error("Error creating seccomp filter")] CreateSeccompFilter(#[source] seccompiler::Error), /// Cannot apply seccomp filter - #[error("Error applying seccomp filter: {0}")] + #[error("Error applying seccomp filter")] ApplySeccompFilter(#[source] seccompiler::Error), /// Error activating virtio devices - #[error("Error activating virtio devices: {0:?}")] + #[error("Error activating virtio devices")] ActivateVirtioDevices(#[source] VmError), /// Error creating API server - #[error("Error creating API server {0:?}")] - // TODO #[source] once the type implements Error + // TODO We should add #[source] here once the type implements Error. + // Then we also can remove the `: {}` to align with the other errors. + #[error("Error creating API server: {0}")] CreateApiServer(micro_http::ServerError), /// Error binding API server socket - #[error("Error creation API server's socket {0:?}")] + #[error("Error creation API server's socket")] CreateApiServerSocket(#[source] io::Error), #[cfg(feature = "guest_debug")] - #[error("Failed to start the GDB thread: {0}")] + #[error("Failed to start the GDB thread")] GdbThreadSpawn(#[source] io::Error), /// GDB request receive error #[cfg(feature = "guest_debug")] - #[error("Error receiving GDB request: {0}")] + #[error("Error receiving GDB request")] GdbRequestRecv(#[source] RecvError), /// GDB response send error #[cfg(feature = "guest_debug")] - #[error("Error sending GDB request: {0}")] + #[error("Error sending GDB request")] GdbResponseSend(#[source] SendError), - #[error("Cannot spawn a signal handler thread: {0}")] + #[error("Cannot spawn a signal handler thread")] SignalHandlerSpawn(#[source] io::Error), #[error("Failed to join on threads: {0:?}")] ThreadCleanup(std::boxed::Box), /// Cannot create Landlock object - #[error("Error creating landlock object: {0}")] + #[error("Error creating landlock object")] CreateLandlock(#[source] LandlockError), /// Cannot apply landlock based sandboxing - #[error("Error applying landlock: {0}")] + #[error("Error applying landlock")] ApplyLandlock(#[source] LandlockError), } pub type Result = result::Result; diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 26897a5f1..a3bdea7db 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -206,15 +206,15 @@ pub struct MemoryManager { #[derive(Error, Debug)] pub enum Error { /// Failed to create shared file. - #[error("Failed to create shared file: {0}")] + #[error("Failed to create shared file")] SharedFileCreate(#[source] io::Error), /// Failed to set shared file length. - #[error("Failed to set shared file length: {0}")] + #[error("Failed to set shared file length")] SharedFileSetLen(#[source] io::Error), /// Mmap backed guest memory error - #[error("Mmap backed guest memory error: {0}")] + #[error("Mmap backed guest memory error")] GuestMemory(#[source] MmapError), /// Failed to allocate a memory range. @@ -222,7 +222,7 @@ pub enum Error { MemoryRangeAllocation, /// Error from region creation - #[error("Error from region creation: {0}")] + #[error("Error from region creation")] GuestMemoryRegion(#[source] MmapRegionError), /// No ACPI slot available @@ -238,27 +238,27 @@ pub enum Error { InvalidSize, /// Failed to create the user memory region. - #[error("Failed to create the user memory region: {0}")] + #[error("Failed to create the user memory region")] CreateUserMemoryRegion(#[source] hypervisor::HypervisorVmError), /// Failed to remove the user memory region. - #[error("Failed to remove the user memory region: {0}")] + #[error("Failed to remove the user memory region")] RemoveUserMemoryRegion(#[source] hypervisor::HypervisorVmError), /// Failed to EventFd. - #[error("Failed to EventFd: {0}")] + #[error("Failed to EventFd")] EventFdFail(#[source] io::Error), /// Eventfd write error - #[error("Eventfd write error: {0}")] + #[error("Eventfd write error")] EventfdError(#[source] io::Error), /// Failed to virtio-mem resize - #[error("Failed to virtio-mem resize: {0}")] + #[error("Failed to virtio-mem resize")] VirtioMemResizeFail(#[source] virtio_devices::mem::Error), /// Cannot restore VM - #[error("Cannot restore VM: {0}")] + #[error("Cannot restore VM")] Restore(#[source] MigratableError), /// Cannot restore VM because source URL is missing @@ -281,27 +281,27 @@ pub enum Error { /// Failed opening SGX virtual EPC device #[cfg(target_arch = "x86_64")] - #[error("Failed opening SGX virtual EPC device: {0}")] + #[error("Failed opening SGX virtual EPC device")] SgxVirtEpcOpen(#[source] io::Error), /// Failed setting the SGX virtual EPC section size #[cfg(target_arch = "x86_64")] - #[error("Failed setting the SGX virtual EPC section size: {0}")] + #[error("Failed setting the SGX virtual EPC section size")] SgxVirtEpcFileSetLen(#[source] io::Error), /// Failed opening SGX provisioning device #[cfg(target_arch = "x86_64")] - #[error("Failed opening SGX provisioning device: {0}")] + #[error("Failed opening SGX provisioning device")] SgxProvisionOpen(#[source] io::Error), /// Failed enabling SGX provisioning #[cfg(target_arch = "x86_64")] - #[error("Failed enabling SGX provisioning: {0}")] + #[error("Failed enabling SGX provisioning")] SgxEnableProvisioning(#[source] hypervisor::HypervisorVmError), /// Failed creating a new MmapRegion instance. #[cfg(target_arch = "x86_64")] - #[error("Failed creating a new MmapRegion instance: {0}")] + #[error("Failed creating a new MmapRegion instance")] NewMmapRegion(#[source] vm_memory::mmap::MmapRegionError), /// No memory zones found. @@ -323,7 +323,7 @@ pub enum Error { InvalidSharedMemoryZoneWithHostNuma, /// Failed applying NUMA memory policy. - #[error("Failed applying NUMA memory policy: {0}")] + #[error("Failed applying NUMA memory policy")] ApplyNumaPolicy(#[source] io::Error), /// Memory zone identifier is not unique. @@ -359,11 +359,11 @@ pub enum Error { GuestAddressOverFlow, /// Error opening snapshot file - #[error("Error opening snapshot file: {0}")] + #[error("Error opening snapshot file")] SnapshotOpen(#[source] io::Error), // Error copying snapshot into region - #[error("Error copying snapshot into region: {0}")] + #[error("Error copying snapshot into region")] SnapshotCopy(#[source] GuestMemoryError), /// Failed to allocate MMIO address @@ -372,7 +372,7 @@ pub enum Error { #[cfg(target_arch = "aarch64")] /// Failed to create UEFI flash - #[error("Failed to create UEFI flash: {0}")] + #[error("Failed to create UEFI flash")] CreateUefiFlash(#[source] HypervisorVmError), /// Using a directory as a backing file for memory is not supported @@ -380,7 +380,7 @@ pub enum Error { DirectoryAsBackingFileForMemory, /// Failed to stat filesystem - #[error("Failed to stat filesystem: {0}")] + #[error("Failed to stat filesystem")] GetFileSystemBlockSize(#[source] io::Error), /// Memory size is misaligned with default page size or its hugepage size diff --git a/vmm/src/serial_manager.rs b/vmm/src/serial_manager.rs index 30aeefc0a..f05100b46 100644 --- a/vmm/src/serial_manager.rs +++ b/vmm/src/serial_manager.rs @@ -28,59 +28,59 @@ use crate::console_devices::ConsoleOutput; #[derive(Debug, Error)] pub enum Error { /// Cannot clone File. - #[error("Error cloning File: {0}")] + #[error("Error cloning File")] FileClone(#[source] io::Error), /// Cannot create epoll context. - #[error("Error creating epoll context: {0}")] + #[error("Error creating epoll context")] Epoll(#[source] io::Error), /// Cannot handle the VM input stream. - #[error("Error handling VM input: {0:?}")] + #[error("Error handling VM input")] ReadInput(#[source] io::Error), /// Cannot queue input to the serial device. - #[error("Error queuing input to the serial device: {0}")] + #[error("Error queuing input to the serial device")] QueueInput(#[source] vmm_sys_util::errno::Error), /// Cannot flush output on the serial buffer. - #[error("Error flushing serial device's output buffer: {0}")] + #[error("Error flushing serial device's output buffer")] FlushOutput(#[source] io::Error), /// Cannot make the file descriptor non-blocking. - #[error("Error making input file descriptor non-blocking: {0}")] + #[error("Error making input file descriptor non-blocking")] SetNonBlocking(#[source] io::Error), /// Cannot create EventFd. - #[error("Error creating EventFd: {0}")] + #[error("Error creating EventFd")] EventFd(#[source] io::Error), /// Cannot spawn SerialManager thread. - #[error("Error spawning SerialManager thread: {0}")] + #[error("Error spawning SerialManager thread")] SpawnSerialManager(#[source] io::Error), /// Cannot bind to Unix socket - #[error("Error binding to socket: {0}")] + #[error("Error binding to socket")] BindUnixSocket(#[source] io::Error), /// Cannot accept connection from Unix socket - #[error("Error accepting connection: {0}")] + #[error("Error accepting connection")] AcceptConnection(#[source] io::Error), /// Cannot clone the UnixStream - #[error("Error cloning UnixStream: {0}")] + #[error("Error cloning UnixStream")] CloneUnixStream(#[source] io::Error), /// Cannot shutdown the connection - #[error("Error shutting down a connection: {0}")] + #[error("Error shutting down a connection")] ShutdownConnection(#[source] io::Error), /// Cannot remove the serial socket - #[error("Error removing serial socket: {0}")] + #[error("Error removing serial socket")] RemoveUnixSocket(#[source] io::Error), /// Cannot duplicate file descriptor - #[error("Error duplicating file descriptor: {0}")] + #[error("Error duplicating file descriptor")] DupFd(#[source] io::Error), } pub type Result = result::Result; diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 8db238e30..d7bba25cc 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -103,54 +103,54 @@ use crate::{ /// Errors associated with VM management #[derive(Debug, Error)] pub enum Error { - #[error("Cannot open kernel file: {0}")] + #[error("Cannot open kernel file")] KernelFile(#[source] io::Error), - #[error("Cannot open initramfs file: {0}")] + #[error("Cannot open initramfs file")] InitramfsFile(#[source] io::Error), - #[error("Cannot load the kernel into memory: {0}")] + #[error("Cannot load the kernel into memory")] KernelLoad(#[source] linux_loader::loader::Error), #[cfg(target_arch = "aarch64")] - #[error("Cannot load the UEFI binary in memory: {0:?}")] + #[error("Cannot load the UEFI binary in memory")] UefiLoad(#[source] arch::aarch64::uefi::Error), #[error("Cannot load the initramfs into memory")] InitramfsLoad, - #[error("Cannot load the kernel command line in memory: {0}")] + #[error("Cannot load the kernel command line in memory")] LoadCmdLine(#[source] linux_loader::loader::Error), - #[error("Failed to apply landlock config during vm_create: {0}")] + #[error("Failed to apply landlock config during vm_create")] ApplyLandlock(#[source] LandlockError), - #[error("Cannot modify the kernel command line: {0}")] + #[error("Cannot modify the kernel command line")] CmdLineInsertStr(#[source] linux_loader::cmdline::Error), - #[error("Cannot create the kernel command line: {0}")] + #[error("Cannot create the kernel command line")] CmdLineCreate(#[source] linux_loader::cmdline::Error), - #[error("Cannot configure system: {0}")] + #[error("Cannot configure system")] ConfigureSystem(#[source] arch::Error), #[cfg(target_arch = "aarch64")] - #[error("Cannot enable interrupt controller: {0:?}")] + #[error("Cannot enable interrupt controller")] EnableInterruptController(#[source] interrupt_controller::Error), #[error("VM state is poisoned")] PoisonedState, - #[error("Error from device manager: {0:?}")] + #[error("Error from device manager")] DeviceManager(#[source] DeviceManagerError), - #[error("Error initializing VM: {0:?}")] + #[error("Error initializing VM")] InitializeVm(#[source] hypervisor::HypervisorVmError), #[error("No device with id {0:?} to remove")] NoDeviceToRemove(String), - #[error("Cannot spawn a signal handler thread: {0}")] + #[error("Cannot spawn a signal handler thread")] SignalHandlerSpawn(#[source] io::Error), #[error("Failed to join on threads: {0:?}")] @@ -168,127 +168,127 @@ pub enum Error { #[error("VM is not running")] VmNotRunning, - #[error("Cannot clone EventFd: {0}")] + #[error("Cannot clone EventFd")] EventFdClone(#[source] io::Error), #[error("invalid VM state transition: {0:?} to {1:?}")] InvalidStateTransition(VmState, VmState), - #[error("Error from CPU manager: {0}")] + #[error("Error from CPU manager")] CpuManager(#[source] cpu::Error), - #[error("Cannot pause devices: {0}")] + #[error("Cannot pause devices")] PauseDevices(#[source] MigratableError), - #[error("Cannot resume devices: {0}")] + #[error("Cannot resume devices")] ResumeDevices(#[source] MigratableError), - #[error("Cannot pause CPUs: {0}")] + #[error("Cannot pause CPUs")] PauseCpus(#[source] MigratableError), - #[error("Cannot resume cpus: {0}")] + #[error("Cannot resume cpus")] ResumeCpus(#[source] MigratableError), - #[error("Cannot pause VM: {0}")] + #[error("Cannot pause VM")] Pause(#[source] MigratableError), - #[error("Cannot resume VM: {0}")] + #[error("Cannot resume VM")] Resume(#[source] MigratableError), - #[error("Memory manager error: {0:?}")] + #[error("Memory manager error")] MemoryManager(#[source] MemoryManagerError), - #[error("Eventfd write error: {0}")] + #[error("Eventfd write error")] EventfdError(#[source] std::io::Error), - #[error("Cannot snapshot VM: {0}")] + #[error("Cannot snapshot VM")] Snapshot(#[source] MigratableError), - #[error("Cannot restore VM: {0}")] + #[error("Cannot restore VM")] Restore(#[source] MigratableError), - #[error("Cannot send VM snapshot: {0}")] + #[error("Cannot send VM snapshot")] SnapshotSend(#[source] MigratableError), #[error("Invalid restore source URL")] InvalidRestoreSourceUrl, - #[error("Failed to validate config: {0}")] + #[error("Failed to validate config")] ConfigValidation(#[source] ValidationError), #[error("Too many virtio-vsock devices")] TooManyVsockDevices, - #[error("Failed serializing into JSON: {0}")] + #[error("Failed serializing into JSON")] SerializeJson(#[source] serde_json::Error), #[error("Invalid NUMA configuration")] InvalidNumaConfig, - #[error("Cannot create seccomp filter: {0}")] + #[error("Cannot create seccomp filter")] CreateSeccompFilter(#[source] seccompiler::Error), - #[error("Cannot apply seccomp filter: {0}")] + #[error("Cannot apply seccomp filter")] ApplySeccompFilter(#[source] seccompiler::Error), #[error("Failed resizing a memory zone")] ResizeZone, - #[error("Cannot activate virtio devices: {0:?}")] + #[error("Cannot activate virtio devices")] ActivateVirtioDevices(#[source] DeviceManagerError), - #[error("Error triggering power button: {0:?}")] + #[error("Error triggering power button")] PowerButton(#[source] DeviceManagerError), #[error("Kernel lacks PVH header")] KernelMissingPvhHeader, - #[error("Failed to allocate firmware RAM: {0:?}")] + #[error("Failed to allocate firmware RAM")] AllocateFirmwareMemory(#[source] MemoryManagerError), - #[error("Error manipulating firmware file: {0}")] + #[error("Error manipulating firmware file")] FirmwareFile(#[source] std::io::Error), #[error("Firmware too big")] FirmwareTooLarge, - #[error("Failed to copy firmware to memory: {0}")] + #[error("Failed to copy firmware to memory")] FirmwareLoad(#[source] vm_memory::GuestMemoryError), #[cfg(feature = "sev_snp")] - #[error("Error enabling SEV-SNP VM: {0}")] + #[error("Error enabling SEV-SNP VM")] InitializeSevSnpVm(#[source] hypervisor::HypervisorVmError), #[cfg(feature = "tdx")] - #[error("Error performing I/O on TDX firmware file: {0}")] + #[error("Error performing I/O on TDX firmware file")] LoadTdvf(#[source] std::io::Error), #[cfg(feature = "tdx")] - #[error("Error performing I/O on the TDX payload file: {0}")] + #[error("Error performing I/O on the TDX payload file")] LoadPayload(#[source] std::io::Error), #[cfg(feature = "tdx")] - #[error("Error parsing TDVF: {0}")] + #[error("Error parsing TDVF")] ParseTdvf(#[source] arch::x86_64::tdx::TdvfError), #[cfg(feature = "tdx")] - #[error("Error populating TDX HOB: {0}")] + #[error("Error populating TDX HOB")] PopulateHob(#[source] arch::x86_64::tdx::TdvfError), #[cfg(feature = "tdx")] - #[error("Error allocating TDVF memory: {0:?}")] + #[error("Error allocating TDVF memory")] AllocatingTdvfMemory(#[source] crate::memory_manager::Error), #[cfg(feature = "tdx")] - #[error("Error enabling TDX VM: {0}")] + #[error("Error enabling TDX VM")] InitializeTdxVm(#[source] hypervisor::HypervisorVmError), #[cfg(feature = "tdx")] - #[error("Error enabling TDX memory region: {0}")] + #[error("Error enabling TDX memory region")] InitializeTdxMemoryRegion(#[source] hypervisor::HypervisorVmError), #[cfg(feature = "tdx")] - #[error("Error finalizing TDX VM: {0}")] + #[error("Error finalizing TDX VM")] FinalizeTdx(#[source] hypervisor::HypervisorVmError), #[cfg(feature = "tdx")] @@ -300,7 +300,7 @@ pub enum Error { InvalidPayloadType, #[cfg(feature = "guest_debug")] - #[error("Error debugging VM: {0:?}")] + #[error("Error debugging VM")] Debug(#[source] DebuggableError), #[error("Error spawning kernel loading thread")] @@ -313,21 +313,21 @@ pub enum Error { InvalidPayload, #[cfg(all(target_arch = "x86_64", feature = "guest_debug"))] - #[error("Error coredumping VM: {0:?}")] + #[error("Error coredumping VM")] Coredump(#[source] GuestDebuggableError), #[cfg(feature = "igvm")] - #[error("Cannot open igvm file: {0}")] + #[error("Cannot open igvm file")] IgvmFile(#[source] io::Error), #[cfg(feature = "igvm")] - #[error("Cannot load the igvm into memory: {0}")] + #[error("Cannot load the igvm into memory")] IgvmLoad(#[source] igvm_loader::Error), #[error("Error injecting NMI")] ErrorNmi, - #[error("Error resuming the VM: {0}")] + #[error("Error resuming the VM")] ResumeVm(#[source] hypervisor::HypervisorVmError), #[error("Error creating console devices")]