From 3e0614cdf0e0b91eaf855f2ad69bb353b0138d8c Mon Sep 17 00:00:00 2001 From: Xuewei Niu Date: Tue, 5 Sep 2023 16:50:55 +0800 Subject: [PATCH] dragonball: Minor changes to comments Changes include: - Merge `VhostNetDeviceError` import item. - Replace if with match in `add_vhost_net_device()` Signed-off-by: Xuewei Niu --- src/dragonball/src/api/v1/vmm_action.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/dragonball/src/api/v1/vmm_action.rs b/src/dragonball/src/api/v1/vmm_action.rs index 48260bda2..63db56cb2 100644 --- a/src/dragonball/src/api/v1/vmm_action.rs +++ b/src/dragonball/src/api/v1/vmm_action.rs @@ -37,9 +37,9 @@ pub use crate::device_manager::fs_dev_mgr::{ #[cfg(feature = "virtio-mem")] pub use crate::device_manager::mem_dev_mgr::{MemDeviceConfigInfo, MemDeviceError}; #[cfg(feature = "vhost-net")] -use crate::device_manager::vhost_net_dev_mgr::VhostNetDeviceError; -#[cfg(feature = "vhost-net")] -pub use crate::device_manager::vhost_net_dev_mgr::{VhostNetDeviceConfigInfo, VhostNetDeviceMgr}; +pub use crate::device_manager::vhost_net_dev_mgr::{ + VhostNetDeviceConfigInfo, VhostNetDeviceError, VhostNetDeviceMgr, +}; #[cfg(feature = "virtio-net")] pub use crate::device_manager::virtio_net_dev_mgr::{ VirtioNetDeviceConfigInfo, VirtioNetDeviceConfigUpdateInfo, VirtioNetDeviceError, @@ -706,14 +706,12 @@ impl VmmService { let vm = vmm.get_vm_mut().ok_or(VmmActionError::InvalidVMID)?; let ctx = vm .create_device_op_context(Some(event_mgr.epoll_manager())) - .map_err(|err| { - if let StartMicroVmError::MicroVMAlreadyRunning = err { + .map_err(|err| match err { + StartMicroVmError::MicroVMAlreadyRunning => { VmmActionError::VhostNet(VhostNetDeviceError::UpdateNotAllowedPostBoot) - } else if let StartMicroVmError::UpcallServerNotReady = err { - VmmActionError::UpcallServerNotReady - } else { - VmmActionError::StartMicroVm(err) } + StartMicroVmError::UpcallServerNotReady => VmmActionError::UpcallServerNotReady, + _ => VmmActionError::StartMicroVm(err), })?; VhostNetDeviceMgr::insert_device(vm.device_manager_mut(), ctx, config) .map(|_| VmmData::Empty)