Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Code Quality failure #241

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/arch/src/x86_64/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/devices/src/virtio/descriptor_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<usize> {
self.buffer.consume(buf.len(), |bufs| {
let mut rem = buf;
Expand Down Expand Up @@ -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<usize> {
self.buffer.consume(buf.len(), |bufs| {
let mut rem = buf;
Expand Down
4 changes: 2 additions & 2 deletions src/devices/src/virtio/file_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub trait FileReadWriteVolatile {
}
}

impl<'a, T: FileReadWriteVolatile + ?Sized> FileReadWriteVolatile for &'a mut T {
impl<T: FileReadWriteVolatile + ?Sized> FileReadWriteVolatile for &mut T {
fn read_volatile(&mut self, slice: VolatileSlice) -> Result<usize> {
(**self).read_volatile(slice)
}
Expand Down Expand Up @@ -194,7 +194,7 @@ pub trait FileReadWriteAtVolatile {
}
}

impl<'a, T: FileReadWriteAtVolatile + ?Sized> FileReadWriteAtVolatile for &'a T {
impl<T: FileReadWriteAtVolatile + ?Sized> FileReadWriteAtVolatile for &T {
fn read_at_volatile(&self, slice: VolatileSlice, offset: u64) -> Result<usize> {
(**self).read_at_volatile(slice, offset)
}
Expand Down
4 changes: 2 additions & 2 deletions src/devices/src/virtio/fs/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub trait ZeroCopyReader {
}
}

impl<'a, R: ZeroCopyReader> ZeroCopyReader for &'a mut R {
impl<R: ZeroCopyReader> ZeroCopyReader for &mut R {
fn read_to(&mut self, f: &File, count: usize, off: u64) -> io::Result<usize> {
(**self).read_to(f, count, off)
}
Expand Down Expand Up @@ -291,7 +291,7 @@ pub trait ZeroCopyWriter {
}
}

impl<'a, W: ZeroCopyWriter> ZeroCopyWriter for &'a mut W {
impl<W: ZeroCopyWriter> ZeroCopyWriter for &mut W {
fn write_from(&mut self, f: &File, count: usize, off: u64) -> io::Result<usize> {
(**self).write_from(f, count, off)
}
Expand Down
8 changes: 4 additions & 4 deletions src/devices/src/virtio/fs/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,27 @@ 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<usize> {
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<usize> {
self.0.read(buf)
}
}

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<usize> {
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<usize> {
self.0.write(buf)
}
Expand Down
4 changes: 1 addition & 3 deletions src/devices/src/virtio/net/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 0 additions & 1 deletion src/devices/src/virtio/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DescriptorChain<'a>>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/hvf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub struct HvfVcpu<'a> {
pending_advance_pc: bool,
}

impl<'a> HvfVcpu<'a> {
impl HvfVcpu<'_> {
pub fn new() -> Result<Self, Error> {
let mut vcpuid: hv_vcpu_t = 0;
let vcpu_exit_ptr: *mut hv_vcpu_exit_t = std::ptr::null_mut();
Expand Down
17 changes: 0 additions & 17 deletions src/vmm/src/vmm_config/boot_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,16 @@

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";
#[cfg(target_os = "macos")]
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)]
Expand Down
Loading