diff --git a/src/dragonball/dbs_address_space/src/memory/hybrid.rs b/src/dragonball/dbs_address_space/src/memory/hybrid.rs index 87a09749e8..7c253a55b6 100644 --- a/src/dragonball/dbs_address_space/src/memory/hybrid.rs +++ b/src/dragonball/dbs_address_space/src/memory/hybrid.rs @@ -207,7 +207,7 @@ impl GuestMemoryRegion for GuestRegionHybrid { &self, offset: MemoryRegionAddress, count: usize, - ) -> guest_memory::Result>> { + ) -> guest_memory::Result>> { match self { GuestRegionHybrid::Mmap(region) => region.get_slice(offset, count), GuestRegionHybrid::Raw(region) => region.get_slice(offset, count), @@ -359,7 +359,7 @@ impl GuestMemory for GuestMemoryHybrid { index.map(|x| self.regions[x].as_ref()) } - fn iter(&self) -> Iter { + fn iter(&self) -> Iter<'_, B> { Iter(self.regions.iter()) } } diff --git a/src/dragonball/dbs_address_space/src/memory/raw_region.rs b/src/dragonball/dbs_address_space/src/memory/raw_region.rs index 5af21ca3e6..cff4312917 100644 --- a/src/dragonball/dbs_address_space/src/memory/raw_region.rs +++ b/src/dragonball/dbs_address_space/src/memory/raw_region.rs @@ -202,7 +202,7 @@ impl GuestMemoryRegion for GuestRegionRaw { &self, offset: MemoryRegionAddress, count: usize, - ) -> guest_memory::Result>> { + ) -> guest_memory::Result>> { let offset = offset.raw_value() as usize; let end = compute_offset(offset, count)?; if end > self.size { diff --git a/src/dragonball/dbs_pci/src/vfio.rs b/src/dragonball/dbs_pci/src/vfio.rs index f12572233c..f6feff84b5 100644 --- a/src/dragonball/dbs_pci/src/vfio.rs +++ b/src/dragonball/dbs_pci/src/vfio.rs @@ -1640,7 +1640,7 @@ impl VfioPciDevice { ); let _ = state.unregister_regions(&self.vm_fd).map_err(|e| { // If unregistering regions goes wrong, the memory region in Dragonball will be in a mess, - // so we panic here to avoid more serious problem. + // so we panic here to avoid more serious problem. panic!("failed to rollback changes of VfioPciDevice::register_regions() because error {:?}", e); }); } @@ -1656,7 +1656,7 @@ impl VfioPciDevice { Ok(()) } - pub fn state(&self) -> MutexGuard> { + pub fn state(&self) -> MutexGuard<'_, VfioPciDeviceState> { // Don't expect poisoned lock self.state .lock() diff --git a/src/dragonball/dbs_pci/src/virtio_pci.rs b/src/dragonball/dbs_pci/src/virtio_pci.rs index 942798d5ae..245f8f9fd3 100644 --- a/src/dragonball/dbs_pci/src/virtio_pci.rs +++ b/src/dragonball/dbs_pci/src/virtio_pci.rs @@ -669,7 +669,7 @@ where Ok(()) } - pub fn device(&self) -> MutexGuard>> { + pub fn device(&self) -> MutexGuard<'_, Box>> { self.device.lock().expect("Poisoned lock of device") } @@ -677,21 +677,21 @@ where self.device.clone() } - pub fn common_config(&self) -> MutexGuard { + pub fn common_config(&self) -> MutexGuard<'_, VirtioPciCommonConfig> { self.common_config .lock() .expect("Poisoned lock of common_config") } - pub fn state(&self) -> MutexGuard> { + pub fn state(&self) -> MutexGuard<'_, VirtioPciDeviceState> { self.state.lock().expect("Poisoned lock of state") } - pub fn msix_state(&self) -> MutexGuard { + pub fn msix_state(&self) -> MutexGuard<'_, MsixState> { self.msix_state.lock().expect("Poisoned lock of msix_state") } - pub fn intr_mgr(&self) -> MutexGuard>> { + pub fn intr_mgr(&self) -> MutexGuard<'_, DeviceInterruptManager>> { // Safe to unwrap() because we don't expect poisoned lock here. self.intr_mgr.lock().expect("Poisoned lock of intr_mgr") } diff --git a/src/dragonball/dbs_virtio_devices/src/mmio/mmio_v2.rs b/src/dragonball/dbs_virtio_devices/src/mmio/mmio_v2.rs index ea12fbe5ba..b915e62b93 100644 --- a/src/dragonball/dbs_virtio_devices/src/mmio/mmio_v2.rs +++ b/src/dragonball/dbs_virtio_devices/src/mmio/mmio_v2.rs @@ -136,7 +136,7 @@ where } /// Acquires the state while holding the lock. - pub fn state(&self) -> MutexGuard> { + pub fn state(&self) -> MutexGuard<'_, MmioV2DeviceState> { // Safe to unwrap() because we don't expect poisoned lock here. self.state.lock().unwrap() } diff --git a/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/block.rs b/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/block.rs index 9ca57e0840..3c3a464b3d 100644 --- a/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/block.rs +++ b/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/block.rs @@ -444,7 +444,7 @@ where }) } - fn device(&self) -> MutexGuard { + fn device(&self) -> MutexGuard<'_, VhostUserBlockDevice> { self.device.lock().unwrap() } } diff --git a/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/fs.rs b/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/fs.rs index 813b0c294d..da52385772 100644 --- a/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/fs.rs +++ b/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/fs.rs @@ -560,7 +560,7 @@ impl VhostUserFs { self.device.clone() } - fn device(&self) -> MutexGuard { + fn device(&self) -> MutexGuard<'_, VhostUserFsDevice> { // Do not expect poisoned lock. self.device.lock().unwrap() } diff --git a/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/net.rs b/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/net.rs index 920ab0cce0..7eca357bf1 100644 --- a/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/net.rs +++ b/src/dragonball/dbs_virtio_devices/src/vhost/vhost_user/net.rs @@ -198,7 +198,7 @@ impl VhostUserNetDevice { // recreate it again. let (master, avail_features) = self.listener.accept()?; if !avail_features & self.device_info.acked_features() != 0 { - error!("{}: Virtio features changed when reconnecting, avail features: 0x{:X}, acked features: 0x{:X}.", + error!("{}: Virtio features changed when reconnecting, avail features: 0x{:X}, acked features: 0x{:X}.", self.id, avail_features, self.device_info.acked_features()); return Err(VhostError::VhostUserProtocol(VhostUserError::FeatureMismatch).into()); } @@ -304,7 +304,7 @@ impl VhostUserNetDevice { // recreate it again. let (master, avail_features) = self.listener.accept()?; if !avail_features & self.device_info.acked_features() != 0 { - error!("{}: Virtio features changed when reconnecting, avail features: 0x{:X}, acked features: 0x{:X}.", + error!("{}: Virtio features changed when reconnecting, avail features: 0x{:X}, acked features: 0x{:X}.", self.id, avail_features, self.device_info.acked_features()); return Err(VhostError::VhostUserProtocol(VhostUserError::FeatureMismatch).into()); } @@ -360,7 +360,7 @@ where }) } - fn device(&self) -> MutexGuard { + fn device(&self) -> MutexGuard<'_, VhostUserNetDevice> { // Do not expect poisoned lock. self.device.lock().unwrap() } @@ -466,7 +466,7 @@ where Q: QueueT + Send + 'static, R: GuestMemoryRegion + Sync + Send + 'static, { - fn device(&self) -> MutexGuard { + fn device(&self) -> MutexGuard<'_, VhostUserNetDevice> { // Do not expect poisoned lock here self.device.lock().unwrap() } diff --git a/src/dragonball/src/config_manager.rs b/src/dragonball/src/config_manager.rs index 428ccecbf4..f61c294a5f 100644 --- a/src/dragonball/src/config_manager.rs +++ b/src/dragonball/src/config_manager.rs @@ -122,7 +122,7 @@ where } /// Returns an immutable iterator over the config items - pub fn iter(&self) -> ::std::slice::Iter { + pub fn iter(&self) -> ::std::slice::Iter<'_, T> { self.configs.iter() } @@ -269,12 +269,12 @@ where } /// Iterator for configuration information objects. - pub fn iter(&self) -> std::slice::Iter> { + pub fn iter(&self) -> std::slice::Iter<'_, DeviceConfigInfo> { self.info_list.iter() } /// Mutable iterator for configuration information objects. - pub fn iter_mut(&mut self) -> std::slice::IterMut> { + pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, DeviceConfigInfo> { self.info_list.iter_mut() } diff --git a/src/dragonball/src/device_manager/blk_dev_mgr.rs b/src/dragonball/src/device_manager/blk_dev_mgr.rs index e5f7bada15..be81c69a96 100644 --- a/src/dragonball/src/device_manager/blk_dev_mgr.rs +++ b/src/dragonball/src/device_manager/blk_dev_mgr.rs @@ -316,7 +316,7 @@ pub struct BlockDeviceMgr { impl BlockDeviceMgr { /// returns a front-to-back iterator. - pub fn iter(&self) -> vec_deque::Iter { + pub fn iter(&self) -> vec_deque::Iter<'_, BlockDeviceInfo> { self.info_list.iter() } diff --git a/src/dragonball/src/vm/aarch64.rs b/src/dragonball/src/vm/aarch64.rs index 4b9509fa15..7102767ec7 100644 --- a/src/dragonball/src/vm/aarch64.rs +++ b/src/dragonball/src/vm/aarch64.rs @@ -142,7 +142,7 @@ impl Vm { } /// Generate fdt information about devices - fn get_fdt_device_info(&self) -> FdtDeviceInfo { + fn get_fdt_device_info(&self) -> FdtDeviceInfo<'_, MMIODeviceInfo> { FdtDeviceInfo::new( self.device_manager().get_mmio_device_info(), self.get_irqchip(),