From 59d99f292748687a7892ae6a2f16d37e4e5ef6a6 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 12:18:00 +0100 Subject: [PATCH 01/13] hypervisor: Fix clippy: for_kv_map Fix use of a paired map iterator when only the values are cared about. Signed-off-by: Rob Bradford (cherry picked from commit 673d4a441c3ee324113f609609c3874a2864ca77) --- hypervisor/src/kvm/mod.rs | 4 ++-- hypervisor/src/mshv/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index a8c516c51f..2560283dbd 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -1318,7 +1318,7 @@ impl vm::Vm for KvmVm { /// fn start_dirty_log(&self) -> vm::Result<()> { let dirty_log_slots = self.dirty_log_slots.read().unwrap(); - for (_, s) in dirty_log_slots.iter() { + for s in dirty_log_slots.values() { let region = kvm_userspace_memory_region2 { slot: s.slot, guest_phys_addr: s.guest_phys_addr, @@ -1344,7 +1344,7 @@ impl vm::Vm for KvmVm { /// fn stop_dirty_log(&self) -> vm::Result<()> { let dirty_log_slots = self.dirty_log_slots.read().unwrap(); - for (_, s) in dirty_log_slots.iter() { + for s in dirty_log_slots.values() { let region = kvm_userspace_memory_region2 { slot: s.slot, guest_phys_addr: s.guest_phys_addr, diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index de98c256e9..089a28ce23 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -2229,7 +2229,7 @@ impl vm::Vm for MshvVm { // Before disabling the dirty page tracking we need // to set the dirty bits in the Hypervisor // This is a requirement from Microsoft Hypervisor - for (_, s) in dirty_log_slots.iter() { + for s in dirty_log_slots.values() { self.fd .get_dirty_log( s.guest_pfn, From acda2df4b3ad47dbf9e9003891cd1bb60b5bb0a2 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 12:18:00 +0100 Subject: [PATCH 02/13] virtio-devices: Fix clippy: for_kv_map Fix use of a paired map iterator when only the values are cared about. Signed-off-by: Rob Bradford (cherry picked from commit c78497c31473ccf5faa5a9669fac5b1053dc11cc) --- virtio-devices/src/mem.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virtio-devices/src/mem.rs b/virtio-devices/src/mem.rs index 49ff680959..0cf477a317 100644 --- a/virtio-devices/src/mem.rs +++ b/virtio-devices/src/mem.rs @@ -514,7 +514,7 @@ impl MemEpollHandler { if plug { let mut gpa = addr; for _ in 0..nb_blocks { - for (_, handler) in handlers.iter() { + for handler in handlers.values() { if let Err(e) = handler.map(gpa, gpa, config.block_size) { error!( "failed DMA mapping addr 0x{:x} size 0x{:x}: {}", @@ -529,7 +529,7 @@ impl MemEpollHandler { config.plugged_size += size; } else { - for (_, handler) in handlers.iter() { + for handler in handlers.values() { if let Err(e) = handler.unmap(addr, size) { error!("failed DMA unmapping addr 0x{addr:x} size 0x{size:x}: {e}"); return VIRTIO_MEM_RESP_ERROR; @@ -555,7 +555,7 @@ impl MemEpollHandler { for (idx, plugged) in self.blocks_state.lock().unwrap().inner().iter().enumerate() { if *plugged { let gpa = config.addr + (idx as u64 * config.block_size); - for (_, handler) in handlers.iter() { + for handler in handlers.values() { if let Err(e) = handler.unmap(gpa, config.block_size) { error!( "failed DMA unmapping addr 0x{:x} size 0x{:x}: {}", From d005723e04fe23c2e468df9c50c0d3b025678dcd Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 12:18:00 +0100 Subject: [PATCH 03/13] vmm: Fix clippy: for_kv_map Fix use of a paired map iterator when only the values are cared about. Signed-off-by: Rob Bradford (cherry picked from commit 2a20f570b251a6f21d95e5b0dc87ad620acf6fd5) --- vmm/src/device_manager.rs | 10 +++++----- vmm/src/device_tree.rs | 2 +- vmm/src/interrupt.rs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 60e07f0029..c160728be5 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -3940,7 +3940,7 @@ impl DeviceManager { // Register DMA mapping in IOMMU. // Do not register virtio-mem regions, as they are handled directly by // virtio-mem device itself. - for (_, zone) in self.memory_manager.lock().unwrap().memory_zones().iter() { + for zone in self.memory_manager.lock().unwrap().memory_zones().values() { for region in zone.regions() { // vfio_dma_map is unsound and ought to be marked as unsafe #[allow(unused_unsafe)] @@ -4209,7 +4209,7 @@ impl DeviceManager { .map_err(DeviceManagerError::AddDmaMappingHandlerVirtioMem)?; } - for (_, zone) in self.memory_manager.lock().unwrap().memory_zones().iter() { + for zone in self.memory_manager.lock().unwrap().memory_zones().values() { for region in zone.regions() { vfio_user_pci_device .dma_map(region) @@ -4350,7 +4350,7 @@ impl DeviceManager { // Do not register virtio-mem regions, as they are handled directly by // virtio-mem devices. - for (_, zone) in self.memory_manager.lock().unwrap().memory_zones().iter() { + for zone in self.memory_manager.lock().unwrap().memory_zones().values() { for region in zone.regions() { let gpa = region.start_addr().0; let size = region.len(); @@ -4935,7 +4935,7 @@ impl DeviceManager { if let Some(dma_handler) = dev.dma_handler() && !iommu_attached { - for (_, zone) in self.memory_manager.lock().unwrap().memory_zones().iter() { + for zone in self.memory_manager.lock().unwrap().memory_zones().values() { for region in zone.regions() { let iova = region.start_addr().0; let size = region.len(); @@ -4955,7 +4955,7 @@ impl DeviceManager { } PciDeviceHandle::VfioUser(vfio_user_pci_device) => { let mut dev = vfio_user_pci_device.lock().unwrap(); - for (_, zone) in self.memory_manager.lock().unwrap().memory_zones().iter() { + for zone in self.memory_manager.lock().unwrap().memory_zones().values() { for region in zone.regions() { // On error, log, but continue so the loop below removing the mapping from // the devices runs. diff --git a/vmm/src/device_tree.rs b/vmm/src/device_tree.rs index e84cb524de..c1cb000df8 100644 --- a/vmm/src/device_tree.rs +++ b/vmm/src/device_tree.rs @@ -114,7 +114,7 @@ impl<'a> BftIter<'a> { let mut nodes = Vec::with_capacity(hash_map.len()); let mut i = 0; - for (_, node) in hash_map.iter() { + for node in hash_map.values() { if node.parent.is_none() { nodes.push(node); } diff --git a/vmm/src/interrupt.rs b/vmm/src/interrupt.rs index 7fe5aa966d..bf99578233 100644 --- a/vmm/src/interrupt.rs +++ b/vmm/src/interrupt.rs @@ -191,7 +191,7 @@ impl MsiInterruptGroup { fn set_gsi_routes(&self, routes: &HashMap) -> Result<()> { let mut entry_vec: Vec = Vec::new(); - for (_, entry) in routes.iter() { + for entry in routes.values() { if entry.masked { continue; } @@ -207,7 +207,7 @@ impl MsiInterruptGroup { impl InterruptSourceGroup for MsiInterruptGroup { fn enable(&self) -> Result<()> { - for (_, route) in self.irq_routes.iter() { + for route in self.irq_routes.values() { route.lock().unwrap().enable(self.vm.as_ref())?; } @@ -215,7 +215,7 @@ impl InterruptSourceGroup for MsiInterruptGroup { } fn disable(&self) -> Result<()> { - for (_, route) in self.irq_routes.iter() { + for route in self.irq_routes.values() { route.lock().unwrap().disable(self.vm.as_ref())?; } From fa43242974fa45864747db485f17bebf5cd933e5 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 12:27:00 +0100 Subject: [PATCH 04/13] test_infra: Fix clippy: useless_borrows_in_formatting Replace & in formatting arguments where it is already a reference (avoiding &&). Signed-off-by: Rob Bradford (cherry picked from commit c10f237529e82ffa0ac82a382b6d5fc2b995de8e) --- test_infra/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index 6c1d9529b2..6a9addcef8 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -2097,7 +2097,7 @@ pub fn remote_command(api_socket: &str, command: &str, arg: Option<&str>) -> boo if output.status.success() { true } else { - eprintln!("Error running ch-remote command: {:?}", &cmd); + eprintln!("Error running ch-remote command: {:?}", cmd); let stderr = String::from_utf8_lossy(&output.stderr); eprintln!("stderr: {stderr}"); false From a2d252f4d9f5f68230c73c5602dfc930f8a45738 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 12:27:00 +0100 Subject: [PATCH 05/13] virtio-devices: Fix clippy: useless_borrows_in_formatting Replace & in formatting arguments where it is already a reference (avoiding &&). Signed-off-by: Rob Bradford (cherry picked from commit c93677c4267466999e02f0fd99a9d8bd89266ee2) --- virtio-devices/src/net.rs | 2 +- virtio-devices/src/vhost_user/net.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/virtio-devices/src/net.rs b/virtio-devices/src/net.rs index f1fba651fe..0b17fc67f4 100644 --- a/virtio-devices/src/net.rs +++ b/virtio-devices/src/net.rs @@ -885,7 +885,7 @@ impl VirtioDevice for Net { let mut epoll_threads = Vec::new(); spawn_virtio_thread( - &format!("{}_ctrl", &self.id), + &format!("{}_ctrl", self.id), &self.seccomp_action, Thread::VirtioNetCtl, &mut epoll_threads, diff --git a/virtio-devices/src/vhost_user/net.rs b/virtio-devices/src/vhost_user/net.rs index 1017df21da..a1a665650b 100644 --- a/virtio-devices/src/vhost_user/net.rs +++ b/virtio-devices/src/vhost_user/net.rs @@ -403,7 +403,7 @@ impl VirtioDevice for Net { let mut epoll_threads = Vec::new(); spawn_virtio_thread( - &format!("{}_ctrl", &self.id), + &format!("{}_ctrl", self.id), &self.seccomp_action, Thread::VirtioVhostNetCtl, &mut epoll_threads, From 3a7b7fdc1c9c77facbe03974c82702e460e60cdd Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 12:27:00 +0100 Subject: [PATCH 06/13] vmm: Fix clippy: useless_borrows_in_formatting Replace & in formatting arguments where it is already a reference (avoiding &&). Signed-off-by: Rob Bradford (cherry picked from commit 7a386eca4ad1b596630e960554257e122fd32110) --- vmm/src/vm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 27ae3a3023..d2ec15db65 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -598,7 +598,7 @@ impl Vm { .validate() .map_err(Error::ConfigValidation)?; - info!("Booting VM from config: {:?}", &config); + info!("Booting VM from config: {:?}", config); // Create NUMA nodes based on NumaConfig. let numa_nodes = From 0aa0832cc32d1ff259b4f3e8066160c81ef7dea9 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 12:33:35 +0100 Subject: [PATCH 07/13] arch: Fix clippy: unused_format_specs When formatting as hex the minimum format size is 4 not 2. Signed-off-by: Rob Bradford (cherry picked from commit ead1094629315c37f7d0bb6764c0fcdb809ae404) --- arch/src/x86_64/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/src/x86_64/mod.rs b/arch/src/x86_64/mod.rs index b8c10d9e0e..ab785911c1 100644 --- a/arch/src/x86_64/mod.rs +++ b/arch/src/x86_64/mod.rs @@ -640,7 +640,7 @@ impl CpuidFeatureEntry { }; if !entry_compatible { error!( - "Detected incompatible CPUID entry: leaf={:#02x} (subleaf={:#02x}), register='{:?}', \ + "Detected incompatible CPUID entry: leaf={:#04x} (subleaf={:#04x}), register='{:?}', \ compatible_check='{:?}', source VM feature='{:#04x}', destination VM feature'{:#04x}'.", entry.function, entry.index, From f36f3360560dd56bc6eb2afe15709088c0bf8c95 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 12:44:20 +0100 Subject: [PATCH 08/13] test_infra: Fix clippy: uninlined_format_args Inline the format argument rather than provide it as a parameter. Signed-off-by: Rob Bradford (cherry picked from commit 85415cd05b66ce9df7ad10d44aeccf169508c6ab) --- test_infra/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index 6a9addcef8..e4f42a658a 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -2097,7 +2097,7 @@ pub fn remote_command(api_socket: &str, command: &str, arg: Option<&str>) -> boo if output.status.success() { true } else { - eprintln!("Error running ch-remote command: {:?}", cmd); + eprintln!("Error running ch-remote command: {cmd:?}"); let stderr = String::from_utf8_lossy(&output.stderr); eprintln!("stderr: {stderr}"); false From 0c260b57c4e8c2d90fddf52128b94d8a436ef0cb Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 12:44:20 +0100 Subject: [PATCH 09/13] vmm: Fix clippy: uninlined_format_args Inline the format argument rather than provide it as a parameter. Signed-off-by: Rob Bradford (cherry picked from commit 4d27640d08e304e3653e0798d65e596744a6f2c8) --- vmm/src/vm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index d2ec15db65..2f73adaccc 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -598,7 +598,7 @@ impl Vm { .validate() .map_err(Error::ConfigValidation)?; - info!("Booting VM from config: {:?}", config); + info!("Booting VM from config: {config:?}"); // Create NUMA nodes based on NumaConfig. let numa_nodes = From e31edca4cdbd1772b110df4481658805156e59bb Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 13:09:44 +0100 Subject: [PATCH 10/13] tests: Fix clippy: useless_borrows_in_formatting Replace use of redundant & (leading to &&) in format strings. Signed-off-by: Rob Bradford (cherry picked from commit eca621c4e6d78a31510ab1ee43b1c7f82062ec2e) --- cloud-hypervisor/tests/integration.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cloud-hypervisor/tests/integration.rs b/cloud-hypervisor/tests/integration.rs index 21f34487b4..d67d5faaac 100644 --- a/cloud-hypervisor/tests/integration.rs +++ b/cloud-hypervisor/tests/integration.rs @@ -1350,7 +1350,7 @@ mod common_parallel { assert!( exec_host_command_output(&format!( "mount {} {}", - &loop_dev_path, + loop_dev_path, mnt_dir.to_str().unwrap() )) .status @@ -1363,7 +1363,7 @@ mod common_parallel { assert!( exec_host_command_output(&format!( "cp {} {}", - &src_qcow2, + src_qcow2, dest_qcow2.to_str().unwrap() )) .status @@ -3467,7 +3467,7 @@ mod common_parallel { guest.disk_config.disk(DiskType::CloudInit).unwrap() ) .as_str(), - format!("path={},direct=on,image_type=raw", &loop_dev).as_str(), + format!("path={},direct=on,image_type=raw", loop_dev).as_str(), ]) .default_net() .capture_output() @@ -3543,7 +3543,7 @@ mod common_parallel { assert!( exec_host_command_output(&format!( "mount {} {}", - &loop_dev_path, + loop_dev_path, mnt_dir.to_str().unwrap() )) .status @@ -4108,7 +4108,7 @@ mod common_parallel { guest.disk_config.disk(DiskType::CloudInit).unwrap() ) .as_str(), - format!("path={},image_type=raw", &loop_dev).as_str(), + format!("path={},image_type=raw", loop_dev).as_str(), ]) .default_net() .capture_output() @@ -4284,7 +4284,7 @@ mod common_parallel { guest.disk_config.disk(DiskType::CloudInit).unwrap() ) .as_str(), - format!("path={},image_type=raw", &dm_dev).as_str(), + format!("path={},image_type=raw", dm_dev).as_str(), ]) .default_net() .capture_output() From b883e941941ad65cf7c69bc64a196a0d97b8d5e0 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 27 May 2026 13:12:28 +0100 Subject: [PATCH 11/13] tests: Fix clippy: uninlined_format_args Replace format arguments with inlined versions. Signed-off-by: Rob Bradford (cherry picked from commit 29f392f8d458b619fa950ed9ea0da45cf6994637) --- cloud-hypervisor/tests/common/utils.rs | 4 ++-- cloud-hypervisor/tests/integration.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cloud-hypervisor/tests/common/utils.rs b/cloud-hypervisor/tests/common/utils.rs index f5747f3106..5e2967c7a4 100644 --- a/cloud-hypervisor/tests/common/utils.rs +++ b/cloud-hypervisor/tests/common/utils.rs @@ -80,7 +80,7 @@ impl TargetApi { if output.status.success() { true } else { - eprintln!("Error running ch-remote command: {:?}", &cmd); + eprintln!("Error running ch-remote command: {cmd:?}"); let stderr = String::from_utf8_lossy(&output.stderr); eprintln!("stderr: {stderr}"); false @@ -1154,7 +1154,7 @@ pub(crate) fn start_live_migration( // Start to send migration from the source VM let args = [ - format!("--api-socket={}", &src_api_socket), + format!("--api-socket={src_api_socket}"), "send-migration".to_string(), format!( "destination_url=unix:{migration_socket},local={}", diff --git a/cloud-hypervisor/tests/integration.rs b/cloud-hypervisor/tests/integration.rs index d67d5faaac..087418b843 100644 --- a/cloud-hypervisor/tests/integration.rs +++ b/cloud-hypervisor/tests/integration.rs @@ -3467,7 +3467,7 @@ mod common_parallel { guest.disk_config.disk(DiskType::CloudInit).unwrap() ) .as_str(), - format!("path={},direct=on,image_type=raw", loop_dev).as_str(), + format!("path={loop_dev},direct=on,image_type=raw").as_str(), ]) .default_net() .capture_output() @@ -4108,7 +4108,7 @@ mod common_parallel { guest.disk_config.disk(DiskType::CloudInit).unwrap() ) .as_str(), - format!("path={},image_type=raw", loop_dev).as_str(), + format!("path={loop_dev},image_type=raw").as_str(), ]) .default_net() .capture_output() @@ -4284,7 +4284,7 @@ mod common_parallel { guest.disk_config.disk(DiskType::CloudInit).unwrap() ) .as_str(), - format!("path={},image_type=raw", dm_dev).as_str(), + format!("path={dm_dev},image_type=raw").as_str(), ]) .default_net() .capture_output() From ad8af5d9a3a5c4174e23942c5e3fe171b15aa9b8 Mon Sep 17 00:00:00 2001 From: Julian Schindel Date: Thu, 9 Jul 2026 15:47:42 +0200 Subject: [PATCH 12/13] arch: Fix clippy: unused_format_specs When formatting as hex the minimum format size is 4 not 2. On-behalf-of: SAP julian.schindel@sap.com Signed-off-by: Julian Schindel --- arch/src/x86_64/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/src/x86_64/mod.rs b/arch/src/x86_64/mod.rs index ab785911c1..0e2e539a5d 100644 --- a/arch/src/x86_64/mod.rs +++ b/arch/src/x86_64/mod.rs @@ -608,7 +608,7 @@ impl CpuidFeatureEntry { }; if !is_compatible { info!( - "CPUID incompatibility for value definition='{:?}' detected in leaf={:#02x}, sub-leaf={:#02x}, register={:?}, compatibility_check={:?}, source VM value='{:#04x}' destination VM value='{:#04x}'", + "CPUID incompatibility for value definition='{:?}' detected in leaf={:#04x}, sub-leaf={:#04x}, register={:?}, compatibility_check={:?}, source VM value='{:#04x}' destination VM value='{:#04x}'", def, entry.function, entry.index, From c1c56398c72d938c30c9eb3070d0d597e3feabb7 Mon Sep 17 00:00:00 2001 From: Julian Schindel Date: Thu, 9 Jul 2026 15:49:01 +0200 Subject: [PATCH 13/13] vmm: Fix clippy: useless_borrows_in_formatting Replace use of redundant & (leading to &&) in format strings. On-behalf-of: SAP julian.schindel@sap.com Signed-off-by: Julian Schindel --- vmm/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 07454a0b18..aa0df78082 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -3275,9 +3275,9 @@ impl RequestHandler for Vmm { "Receiving migration: receiver_url={},tls={},net_fds={:?}, tcp_url={:?}, zones={:?}", receive_data_migration.receiver_url, receive_data_migration.tls_dir.is_some(), - &receive_data_migration.net_fds, - &receive_data_migration.tcp_serial_url, - &receive_data_migration.zones, + receive_data_migration.net_fds, + receive_data_migration.tcp_serial_url, + receive_data_migration.zones, ); let mut listener = migration_transport::receive_migration_listener(