diff --git a/arch/src/serial.rs b/arch/src/serial.rs index 53860e1b15..b272d2493d 100644 --- a/arch/src/serial.rs +++ b/arch/src/serial.rs @@ -96,7 +96,7 @@ pub fn add_serial_devices( com_evt_1_3: &Event, com_evt_2_4: &Event, serial_parameters: &BTreeMap<(SerialHardware, u8), SerialParameters>, - serial_jail: Option, + #[cfg_attr(windows, allow(unused_variables))] serial_jail: Option, ) -> std::result::Result<(), DeviceRegistrationError> { for com_num in 0..=3 { let com_evt = match com_num { diff --git a/hypervisor/src/haxm.rs b/hypervisor/src/haxm.rs index d61adc242b..b7a5226eec 100644 --- a/hypervisor/src/haxm.rs +++ b/hypervisor/src/haxm.rs @@ -73,13 +73,12 @@ impl Haxm { impl Hypervisor for Haxm { fn check_capability(&self, cap: HypervisorCap) -> bool { - match cap { - HypervisorCap::UserMemory => true, - // under haxm, guests rely on this leaf to calibrate their - // clocksource. - HypervisorCap::CalibratedTscLeafRequired => true, - _ => false, - } + // under haxm, guests rely on this leaf to calibrate their + // clocksource. + matches!( + cap, + HypervisorCap::UserMemory | HypervisorCap::CalibratedTscLeafRequired + ) } /// Makes a shallow clone of this `Hypervisor`. diff --git a/hypervisor/src/haxm/vcpu.rs b/hypervisor/src/haxm/vcpu.rs index 424e7fef38..d643e4c14a 100644 --- a/hypervisor/src/haxm/vcpu.rs +++ b/hypervisor/src/haxm/vcpu.rs @@ -531,8 +531,8 @@ impl VcpuX86_64 for HaxmVcpu { } // copy values we got from kernel - for i in 0..chunk_size { - chunk[i].value = msr_data.entries[i].value; + for (i, item) in chunk.iter_mut().enumerate().take(chunk_size) { + item.value = msr_data.entries[i].value; } } diff --git a/hypervisor/src/lib.rs b/hypervisor/src/lib.rs index c8ff612b93..44fa317ec1 100644 --- a/hypervisor/src/lib.rs +++ b/hypervisor/src/lib.rs @@ -390,7 +390,7 @@ pub enum Datamatch { } /// A reason why a VCPU exited. One of these returns every time `Vcpu::run` is called. -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub enum VcpuExit { /// An io instruction needs to be emulated. /// vcpu handle_io should be called to handle the io operation diff --git a/hypervisor/src/whpx/vcpu.rs b/hypervisor/src/whpx/vcpu.rs index 907f600e99..e7d803f458 100644 --- a/hypervisor/src/whpx/vcpu.rs +++ b/hypervisor/src/whpx/vcpu.rs @@ -349,7 +349,7 @@ impl WhpxVcpu { index, safe_virtual_processor: Arc::new(safe_virtual_processor), vcpu_run_handle_fingerprint: Default::default(), - vm_partition: vm_partition.clone(), + vm_partition, last_exit_context: Arc::new(Default::default()), instruction_emulator: Arc::new(instruction_emulator), tsc_frequency: None, @@ -425,11 +425,8 @@ impl WhpxVcpu { return Err(Error::new(EINVAL)); } - let success = match id { - // Do nothing, we assume TSC is always invariant - HV_X64_MSR_TSC_INVARIANT_CONTROL => true, - _ => false, - }; + // Do nothing, we assume TSC is always invariant + let success = matches!(id, HV_X64_MSR_TSC_INVARIANT_CONTROL); if !success { return self.inject_gp_fault(); @@ -522,8 +519,8 @@ impl Vcpu for WhpxVcpu { vm_partition: self.vm_partition.clone(), last_exit_context: self.last_exit_context.clone(), instruction_emulator: self.instruction_emulator.clone(), - tsc_frequency: self.tsc_frequency.clone(), - apic_frequency: self.apic_frequency.clone(), + tsc_frequency: self.tsc_frequency, + apic_frequency: self.apic_frequency, }) } diff --git a/hypervisor/src/whpx/vm.rs b/hypervisor/src/whpx/vm.rs index 284c282cde..666795c1d0 100644 --- a/hypervisor/src/whpx/vm.rs +++ b/hypervisor/src/whpx/vm.rs @@ -114,9 +114,9 @@ impl WhpxVm { Reserved: [0u32; 3], // HYPERV_CPUID_MIN is the minimum leaf that we need to support returning to the guest Eax: HYPERV_CPUID_MIN, - Ebx: u32::from_le_bytes(['M' as u8, 'i' as u8, 'c' as u8, 'r' as u8]), - Ecx: u32::from_le_bytes(['o' as u8, 's' as u8, 'o' as u8, 'f' as u8]), - Edx: u32::from_le_bytes(['t' as u8, ' ' as u8, 'H' as u8, 'v' as u8]), + Ebx: u32::from_le_bytes([b'M', b'i', b'c', b'r']), + Ecx: u32::from_le_bytes([b'o', b's', b'o', b'f']), + Edx: u32::from_le_bytes([b't', b' ', b'H', b'v']), }); // HYPERV_CPUID_FEATURES leaf tells linux which Hyper-V features we support @@ -283,9 +283,11 @@ impl WhpxVm { delivery: DeliveryMode, ) -> Result<()> { // The WHV_INTERRUPT_CONTROL does not seem to support the dest_shorthand - let mut interrupt = WHV_INTERRUPT_CONTROL::default(); - interrupt.Destination = dest_id as u32; - interrupt.Vector = vector as u32; + let mut interrupt = WHV_INTERRUPT_CONTROL { + Destination: dest_id as u32, + Vector: vector as u32, + ..Default::default() + }; interrupt.set_DestinationMode(match dest_mode { DestinationMode::Physical => { WHV_INTERRUPT_DESTINATION_MODE_WHvX64InterruptDestinationModePhysical diff --git a/net_util/src/slirp/sys/windows/handler.rs b/net_util/src/slirp/sys/windows/handler.rs index 0e905e1767..cdbfecfa22 100644 --- a/net_util/src/slirp/sys/windows/handler.rs +++ b/net_util/src/slirp/sys/windows/handler.rs @@ -195,7 +195,7 @@ impl CallbackHandler for Handler { } } - fn end_read_from_guest<'a>(&'a mut self) -> io::Result<&'a [u8]> { + fn end_read_from_guest(&mut self) -> io::Result<&[u8]> { #[cfg(any(feature = "slirp-ring-capture", feature = "slirp-debug"))] let d = self.start.elapsed(); match self @@ -399,7 +399,7 @@ fn poll<'a>( ) -> Result<(Vec<&'a dyn AsRawDescriptor>, Vec)> { let mut selected_sockets = Vec::with_capacity(sockets.len()); for socket in sockets.iter() { - selected_sockets.push(EventSelectedSocket::new(*socket, &socket_event_handle)?); + selected_sockets.push(EventSelectedSocket::new(*socket, socket_event_handle)?); } wait_ctx.clear().map_err(Error::SlirpPollError)?; diff --git a/third_party/libslirp-rs/src/context.rs b/third_party/libslirp-rs/src/context.rs index 2965b2d2c9..a8c610693e 100644 --- a/third_party/libslirp-rs/src/context.rs +++ b/third_party/libslirp-rs/src/context.rs @@ -151,7 +151,7 @@ pub trait CallbackHandler { fn begin_read_from_guest(&mut self) -> io::Result<()>; - fn end_read_from_guest<'a>(&'a mut self) -> io::Result<&'a [u8]>; + fn end_read_from_guest(&mut self) -> io::Result<&[u8]>; } extern "C" fn write_handler_callback(buf: *const c_void, len: usize, opaque: *mut c_void) -> isize { diff --git a/third_party/vmm_vhost/src/connection/tube.rs b/third_party/vmm_vhost/src/connection/tube.rs index e9b7197bed..f6378ea899 100644 --- a/third_party/vmm_vhost/src/connection/tube.rs +++ b/third_party/vmm_vhost/src/connection/tube.rs @@ -143,7 +143,7 @@ impl Endpoint for TubeEndpoint { fn create_slave_request_endpoint( &mut self, - files: Option>, + _files: Option>, ) -> Result>> { unimplemented!("SET_SLAVE_REQ_FD not supported"); }