Skip to content

Commit c52f1a7

Browse files
committed
refactor: move StartMicrovmError::AllocateResources into VmmError
This means that `create_vmm_and_vcpus` now does not use any variants of `StartMicrovmError` directly, and as a next step can be converted to return `VmmError` directly, which will eliminate all the `map_err` inside. Signed-off-by: Patrick Roy <[email protected]>
1 parent 4181e98 commit c52f1a7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/vmm/src/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ pub enum StartMicrovmError {
130130
SetVmResources(MachineConfigError),
131131
/// Cannot create the entropy device: {0}
132132
CreateEntropyDevice(crate::devices::virtio::rng::EntropyError),
133-
/// Failed to allocate guest resource: {0}
134-
AllocateResources(#[from] vm_allocator::Error),
135133
/// Error configuring ACPI: {0}
136134
#[cfg(target_arch = "x86_64")]
137135
Acpi(#[from] crate::acpi::AcpiError),
@@ -177,7 +175,9 @@ fn create_vmm_and_vcpus(
177175
.map_err(VmmError::Vm)
178176
.map_err(StartMicrovmError::Internal)?;
179177

180-
let resource_allocator = ResourceAllocator::new()?;
178+
let resource_allocator = ResourceAllocator::new()
179+
.map_err(VmmError::AllocateResources)
180+
.map_err(StartMicrovmError::Internal)?;
181181

182182
// Instantiate the MMIO device manager.
183183
let mmio_device_manager = MMIODeviceManager::new();

src/vmm/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ pub const HTTP_MAX_PAYLOAD_SIZE: usize = 51200;
205205
/// have permissions to open the KVM fd).
206206
#[derive(Debug, thiserror::Error, displaydoc::Display)]
207207
pub enum VmmError {
208+
/// Failed to allocate guest resource: {0}
209+
AllocateResources(#[from] vm_allocator::Error),
208210
#[cfg(target_arch = "aarch64")]
209211
/// Invalid command line error.
210212
Cmdline,

0 commit comments

Comments
 (0)