From 34bc37796caddeebd73ecb9db8fa166bc8154a64 Mon Sep 17 00:00:00 2001 From: Jake Correnti Date: Mon, 2 Dec 2024 17:43:04 -0500 Subject: [PATCH 1/5] Fix Code Quality failure Fix a "needless lifetimes" linting failure. Signed-off-by: Jake Correnti --- src/hvf/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hvf/src/lib.rs b/src/hvf/src/lib.rs index caa00a900..67af35f70 100644 --- a/src/hvf/src/lib.rs +++ b/src/hvf/src/lib.rs @@ -247,7 +247,7 @@ pub struct HvfVcpu<'a> { pending_advance_pc: bool, } -impl<'a> HvfVcpu<'a> { +impl HvfVcpu<'_> { pub fn new() -> Result { let mut vcpuid: hv_vcpu_t = 0; let vcpu_exit_ptr: *mut hv_vcpu_exit_t = std::ptr::null_mut(); From ce5eac8d352c9e924ac1e6127dc358bedddb9f8e Mon Sep 17 00:00:00 2001 From: Sergio Lopez Date: Thu, 5 Dec 2024 19:26:23 +0100 Subject: [PATCH 2/5] Remove the remaning unneeded lifetimes clippy has started complainig about unneeded lifetimes, so remove them. Signed-off-by: Sergio Lopez --- src/devices/src/virtio/descriptor_utils.rs | 4 ++-- src/devices/src/virtio/file_traits.rs | 4 ++-- src/devices/src/virtio/fs/filesystem.rs | 4 ++-- src/devices/src/virtio/fs/server.rs | 8 ++++---- src/devices/src/virtio/queue.rs | 1 - 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/devices/src/virtio/descriptor_utils.rs b/src/devices/src/virtio/descriptor_utils.rs index 8af40cece..a43e66f83 100644 --- a/src/devices/src/virtio/descriptor_utils.rs +++ b/src/devices/src/virtio/descriptor_utils.rs @@ -307,7 +307,7 @@ impl<'a> Reader<'a> { } } -impl<'a> io::Read for Reader<'a> { +impl io::Read for Reader<'_> { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.buffer.consume(buf.len(), |bufs| { let mut rem = buf; @@ -448,7 +448,7 @@ impl<'a> Writer<'a> { } } -impl<'a> io::Write for Writer<'a> { +impl io::Write for Writer<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { self.buffer.consume(buf.len(), |bufs| { let mut rem = buf; diff --git a/src/devices/src/virtio/file_traits.rs b/src/devices/src/virtio/file_traits.rs index 2e13eb677..72ab0e315 100644 --- a/src/devices/src/virtio/file_traits.rs +++ b/src/devices/src/virtio/file_traits.rs @@ -97,7 +97,7 @@ pub trait FileReadWriteVolatile { } } -impl<'a, T: FileReadWriteVolatile + ?Sized> FileReadWriteVolatile for &'a mut T { +impl FileReadWriteVolatile for &mut T { fn read_volatile(&mut self, slice: VolatileSlice) -> Result { (**self).read_volatile(slice) } @@ -194,7 +194,7 @@ pub trait FileReadWriteAtVolatile { } } -impl<'a, T: FileReadWriteAtVolatile + ?Sized> FileReadWriteAtVolatile for &'a T { +impl FileReadWriteAtVolatile for &T { fn read_at_volatile(&self, slice: VolatileSlice, offset: u64) -> Result { (**self).read_at_volatile(slice, offset) } diff --git a/src/devices/src/virtio/fs/filesystem.rs b/src/devices/src/virtio/fs/filesystem.rs index 4d032cf8d..ed1284d8b 100644 --- a/src/devices/src/virtio/fs/filesystem.rs +++ b/src/devices/src/virtio/fs/filesystem.rs @@ -198,7 +198,7 @@ pub trait ZeroCopyReader { } } -impl<'a, R: ZeroCopyReader> ZeroCopyReader for &'a mut R { +impl ZeroCopyReader for &mut R { fn read_to(&mut self, f: &File, count: usize, off: u64) -> io::Result { (**self).read_to(f, count, off) } @@ -291,7 +291,7 @@ pub trait ZeroCopyWriter { } } -impl<'a, W: ZeroCopyWriter> ZeroCopyWriter for &'a mut W { +impl ZeroCopyWriter for &mut W { fn write_from(&mut self, f: &File, count: usize, off: u64) -> io::Result { (**self).write_from(f, count, off) } diff --git a/src/devices/src/virtio/fs/server.rs b/src/devices/src/virtio/fs/server.rs index 5efb1f3bf..b477a099e 100644 --- a/src/devices/src/virtio/fs/server.rs +++ b/src/devices/src/virtio/fs/server.rs @@ -34,13 +34,13 @@ const DIRENT_PADDING: [u8; 8] = [0; 8]; struct ZCReader<'a>(Reader<'a>); -impl<'a> ZeroCopyReader for ZCReader<'a> { +impl ZeroCopyReader for ZCReader<'_> { fn read_to(&mut self, f: &File, count: usize, off: u64) -> io::Result { self.0.read_to_at(f, count, off) } } -impl<'a> io::Read for ZCReader<'a> { +impl io::Read for ZCReader<'_> { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.0.read(buf) } @@ -48,13 +48,13 @@ impl<'a> io::Read for ZCReader<'a> { struct ZCWriter<'a>(Writer<'a>); -impl<'a> ZeroCopyWriter for ZCWriter<'a> { +impl ZeroCopyWriter for ZCWriter<'_> { fn write_from(&mut self, f: &File, count: usize, off: u64) -> io::Result { self.0.write_from_at(f, count, off) } } -impl<'a> io::Write for ZCWriter<'a> { +impl io::Write for ZCWriter<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { self.0.write(buf) } diff --git a/src/devices/src/virtio/queue.rs b/src/devices/src/virtio/queue.rs index 954d415f9..a0bdc04aa 100644 --- a/src/devices/src/virtio/queue.rs +++ b/src/devices/src/virtio/queue.rs @@ -151,7 +151,6 @@ unsafe impl ByteValued for VirtqUsedElem {} /// An iterator over a single descriptor chain. Not to be confused with AvailIter, /// which iterates over the descriptor chain heads in a queue. - pub struct DescIter<'a> { next: Option>, } From 3f2adc51399293dc3d7d109ae2fd0d132c15ee03 Mon Sep 17 00:00:00 2001 From: Sergio Lopez Date: Thu, 5 Dec 2024 19:33:35 +0100 Subject: [PATCH 3/5] virtio/net: remove unnecessary closure Let's make clippy happy again. Signed-off-by: Sergio Lopez --- src/devices/src/virtio/net/worker.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/devices/src/virtio/net/worker.rs b/src/devices/src/virtio/net/worker.rs index fb6690582..d07f905e0 100644 --- a/src/devices/src/virtio/net/worker.rs +++ b/src/devices/src/virtio/net/worker.rs @@ -398,9 +398,7 @@ impl NetWorker { let mut result: std::result::Result<(), FrontendError> = Ok(()); let queue = &mut self.queues[RX_INDEX]; - let head_descriptor = queue - .pop(&self.mem) - .ok_or_else(|| FrontendError::EmptyQueue)?; + let head_descriptor = queue.pop(&self.mem).ok_or(FrontendError::EmptyQueue)?; let head_index = head_descriptor.index; let mut frame_slice = &self.rx_frame_buf[..self.rx_frame_buf_len]; From 8652b1673397f036be46775eb5a19b51a1708592 Mon Sep 17 00:00:00 2001 From: Sergio Lopez Date: Thu, 5 Dec 2024 19:41:52 +0100 Subject: [PATCH 4/5] arch/x86_64: fix module doc comment Signed-off-by: Sergio Lopez --- src/arch/src/x86_64/layout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arch/src/x86_64/layout.rs b/src/arch/src/x86_64/layout.rs index fd5b2ef43..ca92736b0 100644 --- a/src/arch/src/x86_64/layout.rs +++ b/src/arch/src/x86_64/layout.rs @@ -5,7 +5,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the THIRD-PARTY file. -/// Magic addresses externally used to lay out x86_64 VMs. +//! Magic addresses externally used to lay out x86_64 VMs. /// Initial stack for the boot CPU. pub const BOOT_STACK_POINTER: u64 = 0x8ff0; From 8b6112e0e65095cd408550fe692249f5b6513919 Mon Sep 17 00:00:00 2001 From: Sergio Lopez Date: Thu, 5 Dec 2024 20:17:48 +0100 Subject: [PATCH 5/5] vmm/boot_source: remove obsolete doc comments Signed-off-by: Sergio Lopez --- src/vmm/src/vmm_config/boot_source.rs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/vmm/src/vmm_config/boot_source.rs b/src/vmm/src/vmm_config/boot_source.rs index 9c70d5b16..bb6d2cb24 100644 --- a/src/vmm/src/vmm_config/boot_source.rs +++ b/src/vmm/src/vmm_config/boot_source.rs @@ -3,23 +3,9 @@ use std::fmt::{Display, Formatter, Result}; -/// Default guest kernel command line: -/// - `reboot=k` shut down the guest on reboot, instead of well... rebooting; -/// - `panic=1` on panic, reboot after 1 second; -/// - `pci=off` do not scan for PCI devices (save boot time); -/// - `nomodule` disable loadable kernel module support; -/// - `8250.nr_uarts=0` disable 8250 serial interface; -/// - `i8042.noaux` do not probe the i8042 controller for an attached mouse (save boot time); -/// - `i8042.nomux` do not probe i8042 for a multiplexing controller (save boot time); -/// - `i8042.nopnp` do not use ACPIPnP to discover KBD/AUX controllers (save boot time); -/// - `i8042.dumbkbd` do not attempt to control kbd state via the i8042 (save boot time). -//pub const DEFAULT_KERNEL_CMDLINE: &str = "reboot=k panic=1 pci=off nomodule 8250.nr_uarts=0 \ -// i8042.noaux i8042.nomux i8042.nopnp i8042.dumbkbd"; - #[cfg(all(target_os = "linux", not(feature = "tee")))] pub const DEFAULT_KERNEL_CMDLINE: &str = "reboot=k panic=-1 panic_print=0 nomodule console=hvc0 \ rootfstype=virtiofs rw quiet no-kvmapf"; - #[cfg(feature = "amd-sev")] pub const DEFAULT_KERNEL_CMDLINE: &str = "reboot=k panic=-1 panic_print=0 nomodule console=hvc0 \ root=/dev/vda rw quiet no-kvmapf"; @@ -27,9 +13,6 @@ pub const DEFAULT_KERNEL_CMDLINE: &str = "reboot=k panic=-1 panic_print=0 nomodu pub const DEFAULT_KERNEL_CMDLINE: &str = "reboot=k panic=-1 panic_print=0 nomodule console=hvc0 \ rootfstype=virtiofs rw quiet no-kvmapf"; -//pub const DEFAULT_KERNEL_CMDLINE: &str = "reboot=k panic=1 pci=off nomodule earlyprintk=ttyS0 \ -// console=ttyS0"; - /// Strongly typed data structure used to configure the boot source of the /// microvm. #[derive(Debug, Default, Eq, PartialEq)]