From b059475dfbe70f62fbc50ab5b946da5d4229e0eb Mon Sep 17 00:00:00 2001 From: Tushar Khatri Date: Thu, 11 Jun 2026 15:39:51 +0000 Subject: [PATCH] vmm: reevaluate #[allow] attributes Remove stale #[allow]s whose lints no longer fire, convert the unconditionally-firing ones to #[expect], and keep the arch/feature-conditional ones as #[allow]. Verified across kvm/mshv, x86_64/aarch64, and --all-features. Part of #8326. Signed-off-by: Tushar Khatri --- vmm/src/api/http/mod.rs | 2 +- vmm/src/api/mod.rs | 2 +- vmm/src/clone3.rs | 1 - vmm/src/config.rs | 3 +-- vmm/src/cpu.rs | 4 ++-- vmm/src/device_manager.rs | 7 +++---- vmm/src/igvm/igvm_loader.rs | 2 +- vmm/src/lib.rs | 5 ++--- vmm/src/memory_manager.rs | 9 ++++----- vmm/src/vm.rs | 20 ++++++++++---------- 10 files changed, 25 insertions(+), 30 deletions(-) diff --git a/vmm/src/api/http/mod.rs b/vmm/src/api/http/mod.rs index 9175cb8a0..5a06e1d76 100644 --- a/vmm/src/api/http/mod.rs +++ b/vmm/src/api/http/mod.rs @@ -98,7 +98,7 @@ const HTTP_ROOT: &str = "/api/v1"; /// The error message contained in the response is supposed to be user-facing, /// thus insightful and helpful while balancing technical accuracy and /// simplicity. -#[allow(clippy::needless_pass_by_value)] +#[expect(clippy::needless_pass_by_value)] pub fn error_response(error: HttpError) -> Response { let mut response = Response::new(Version::Http11, error.status_code()); diff --git a/vmm/src/api/mod.rs b/vmm/src/api/mod.rs index 8e1c2b406..5cefbbddc 100644 --- a/vmm/src/api/mod.rs +++ b/vmm/src/api/mod.rs @@ -603,7 +603,7 @@ pub trait RequestHandler { pub type ApiRequest = Box Result + Send + 'static>; -#[allow(clippy::needless_pass_by_value)] +#[expect(clippy::needless_pass_by_value)] fn get_response( action: &Action, api_evt: EventFd, diff --git a/vmm/src/clone3.rs b/vmm/src/clone3.rs index eca0d9063..4736520f8 100644 --- a/vmm/src/clone3.rs +++ b/vmm/src/clone3.rs @@ -7,7 +7,6 @@ pub const CLONE_CLEAR_SIGHAND: u64 = 0x100000000; #[repr(C)] #[derive(Default)] -#[allow(non_camel_case_types)] pub struct clone_args { pub flags: u64, pub pidfd: u64, diff --git a/vmm/src/config.rs b/vmm/src/config.rs index ea1ecb109..d4d7c8a92 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -1046,7 +1046,7 @@ impl PlatformConfig { } impl MemoryConfig { - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn parse(memory: &str, memory_zones: Option>) -> Result { let mut parser = OptionParser::new(); parser @@ -4517,7 +4517,6 @@ mod unit_tests { } #[track_caller] - #[allow(clippy::too_many_arguments)] fn make_vhost_user_config( socket: &str, virtio_id: u64, diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 74c798bef..d1adc613f 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -842,8 +842,8 @@ impl VcpuState { } impl CpuManager { - #[allow(unused_variables)] - #[allow(clippy::too_many_arguments)] + #[expect(unused_variables)] + #[expect(clippy::too_many_arguments)] pub fn new( config: &CpusConfig, vm: Arc, diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 93a9c4b68..d36c49320 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -1197,7 +1197,7 @@ fn use_64bit_bar_for_virtio_device( } impl DeviceManager { - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn new( io_bus: Arc, mmio_bus: Arc, @@ -1465,7 +1465,7 @@ impl DeviceManager { self.add_interrupt_controller(snapshot) } - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] pub fn create_devices( &mut self, console_info: Option, @@ -4305,7 +4305,7 @@ impl DeviceManager { Ok(vec![]) } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] fn add_virtio_pci_device( &mut self, virtio_device: Arc>, @@ -4842,7 +4842,6 @@ impl DeviceManager { .pci_device_handle .as_ref() .ok_or(DeviceManagerError::MissingPciDevice)?; - #[allow(irrefutable_let_patterns)] if let PciDeviceHandle::Virtio(virtio_pci_device) = pci_device_handle { let device_type = VirtioDeviceType::from( virtio_pci_device diff --git a/vmm/src/igvm/igvm_loader.rs b/vmm/src/igvm/igvm_loader.rs index ea9c7e69e..f4582ba94 100644 --- a/vmm/src/igvm/igvm_loader.rs +++ b/vmm/src/igvm/igvm_loader.rs @@ -273,7 +273,7 @@ pub fn extract_sev_features(igvm_file: &IgvmFile) -> u64 { /// NOTE: KVM and MSHV have different page type values and CPUID/VMSA handling. /// Hypervisor-specific code paths are gated by runtime type checks. A future /// refactor could split these into separate KVM/MSHV loader implementations. -#[allow(clippy::needless_pass_by_value)] +#[expect(clippy::needless_pass_by_value)] pub fn load_igvm( igvm_file: IgvmFile, memory_manager: Arc>, diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 267c1ef34..11e9aa497 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -447,8 +447,7 @@ pub fn start_event_monitor_thread( .map_err(Error::EventMonitorThreadSpawn) } -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] pub fn start_vmm_thread( vmm_version: VmmVersionInfo, http_path: &Option, @@ -717,7 +716,7 @@ impl Vmm { for signal in signals.forever() { match signal { - #[allow(clippy::collapsible_match)] + #[expect(clippy::collapsible_match)] SIGTERM | SIGINT => { if exit_evt.write(1).is_err() { // Resetting the terminal is usually done as the VMM exits diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 8919e601c..b081b9941 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -1140,7 +1140,7 @@ impl MemoryManager { /// snapshot file followed by a `UFFDIO_COPY` to resolve the fault and /// wake the faulting thread. When no fault is pending, one prefault /// page is copied per loop iteration. - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] fn uffd_handler_loop( uffd_fd: OwnedFd, stop_event: EventFd, @@ -1643,7 +1643,6 @@ impl MemoryManager { Ok(()) } - #[allow(clippy::too_many_arguments)] pub fn new( vm: Arc, config: &MemoryConfig, @@ -1899,7 +1898,7 @@ impl MemoryManager { Ok(Arc::new(Mutex::new(memory_manager))) } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn new_from_snapshot( snapshot: &Snapshot, vm: Arc, @@ -2042,7 +2041,7 @@ impl MemoryManager { } } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn create_ram_region_raw( backing_file: &Option, file_offset: u64, @@ -2179,7 +2178,7 @@ impl MemoryManager { Ok(region) } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn create_ram_region( backing_file: &Option, file_offset: u64, diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 3843b65e1..05594a601 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -560,8 +560,8 @@ impl Vm { .with_migrate_ma(0) } - #[allow(clippy::needless_pass_by_value)] - #[allow(clippy::too_many_arguments)] + #[expect(clippy::needless_pass_by_value)] + #[expect(clippy::too_many_arguments)] pub fn new_from_memory_manager( config: Arc>, memory_manager: Arc>, @@ -751,7 +751,7 @@ impl Vm { } /// Create and configure the CPU manager. - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] fn create_cpu_manager( config: &Arc>, vm: Arc, @@ -828,7 +828,7 @@ impl Vm { } /// Create and configure the device manager. - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] fn create_device_manager( io_bus: Arc, mmio_bus: Arc, @@ -881,7 +881,7 @@ impl Vm { /// - KVM (x86_64, aarch64, riscv64) /// - MSHV (x86_64, aarch64) /// - SEV-SNP (MSHV with confidential computing) - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] fn hypervisor_specific_init( vm: &Arc, memory_manager: &Arc>, @@ -995,7 +995,7 @@ impl Vm { /// Initialize SEV-SNP specific components. #[cfg(feature = "sev_snp")] - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] fn init_sev_snp( vm: &Arc, memory_manager: &Arc>, @@ -1325,7 +1325,7 @@ impl Vm { Ok(numa_nodes) } - #[allow(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments)] pub fn new( vm_config: Arc>, exit_evt: EventFd, @@ -1496,7 +1496,7 @@ impl Vm { Ok(cmdline) } - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] fn load_firmware( mut firmware: &File, @@ -1561,7 +1561,7 @@ impl Vm { } #[cfg(feature = "igvm")] - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] fn load_igvm( igvm_file: IgvmFile, memory_manager: Arc>, @@ -1619,7 +1619,7 @@ impl Vm { /// /// For x86_64, the boot path is the same. #[cfg(target_arch = "x86_64")] - #[allow(clippy::needless_pass_by_value)] + #[expect(clippy::needless_pass_by_value)] fn load_kernel( mut kernel: File, cmdline: Option,