Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into clippy-cast-possibl…
Browse files Browse the repository at this point in the history
…e-truncation
  • Loading branch information
JBYoshi committed Apr 3, 2023
2 parents 035a906 + d13be44 commit fa3a8cb
Show file tree
Hide file tree
Showing 24 changed files with 168 additions and 252 deletions.
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions src/arch_gen/Cargo.toml

This file was deleted.

4 changes: 2 additions & 2 deletions src/devices/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ event-manager = "0.3.0"
libc = "0.2.117"
thiserror = "1.0.32"
timerfd = "1.2.0"
versionize = "0.1.6"
versionize_derive = "0.1.4"
versionize = "0.1.10"
versionize_derive = "0.1.5"
vm-superio = "0.7.0"

dumbo = { path = "../dumbo" }
Expand Down
4 changes: 2 additions & 2 deletions src/mmds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ derive_more = { version = "0.99.17", default-features = false, features = ["from
serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.78"
thiserror = "1.0.32"
versionize = "0.1.6"
versionize_derive = "0.1.4"
versionize = "0.1.10"
versionize_derive = "0.1.5"

dumbo = { path = "../dumbo" }
logger = { path = "../logger" }
Expand Down
4 changes: 2 additions & 2 deletions src/rate_limiter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ license = "Apache-2.0"

[dependencies]
timerfd = "1.2.0"
versionize = "0.1.6"
versionize_derive = "0.1.4"
versionize = "0.1.10"
versionize_derive = "0.1.5"

logger = { path = "../logger" }
snapshot = { path = "../snapshot" }
Expand Down
4 changes: 2 additions & 2 deletions src/snapshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ license = "Apache-2.0"

[dependencies]
libc = "0.2.117"
versionize = "0.1.6"
versionize_derive = "0.1.4"
versionize = "0.1.10"
versionize_derive = "0.1.5"
thiserror = "1.0.32"

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions src/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ derive_more = { version = "0.99.17", default-features = false, features = ["from
libc = "0.2.117"
serde = { version = "1.0.136", features = ["derive"] }
thiserror = "1.0.32"
versionize = "0.1.6"
versionize_derive = "0.1.3"
versionize = "0.1.10"
versionize_derive = "0.1.5"
vmm-sys-util = "0.11.0"

net_gen = { path = "../net_gen" }
Expand Down
5 changes: 2 additions & 3 deletions src/vmm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.78"
thiserror = "1.0.32"
userfaultfd = "0.5.0"
versionize = "0.1.6"
versionize_derive = "0.1.4"
versionize = "0.1.10"
versionize_derive = "0.1.5"
vm-allocator = "0.1.0"
vm-superio = "0.7.0"
bitflags = "1.3.2"
Expand All @@ -33,7 +33,6 @@ snapshot = { path = "../snapshot"}
utils = { path = "../utils" }
virtio_gen = { path = "../virtio_gen" }
vm-memory = { path = "../vm-memory" }
arch_gen = { path = "../arch_gen" }

[dev-dependencies]
criterion = "0.4.0"
Expand Down
2 changes: 1 addition & 1 deletion src/vmm/src/arch/x86_64/mptable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use std::convert::TryFrom;
use std::{io, mem, result, slice};

use arch_gen::x86::mpspec;
use libc::c_char;
use vm_memory::{Address, ByteValued, Bytes, GuestAddress, GuestMemory, GuestMemoryMmap};

use crate::arch::IRQ_MAX;
use crate::arch_gen::x86::mpspec;

// This is a workaround to the Rust enforcement specifying that any implementation of a foreign
// trait (in this case `ByteValued`) where:
Expand Down
3 changes: 2 additions & 1 deletion src/vmm/src/arch/x86_64/msr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/// Model Specific Registers (MSRs) related functionality.
use std::result;

use arch_gen::x86::msr_index::*;
use bitflags::bitflags;
use kvm_bindings::{kvm_msr_entry, MsrList, Msrs};
use kvm_ioctls::{Kvm, VcpuFd};

use crate::arch_gen::x86::msr_index::*;

#[derive(Debug)]
/// MSR related errors.
pub enum Error {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/vmm/src/cpuid/template/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ pub mod amd;

use std::collections::HashSet;

use arch_gen::x86::msr_index::*;
use kvm_bindings::CpuId;

use crate::arch_gen::x86::msr_index::*;
use crate::cpuid::common::{get_vendor_id_from_cpuid, VENDOR_ID_AMD, VENDOR_ID_INTEL};
use crate::cpuid::transformer::Error;

Expand Down
16 changes: 3 additions & 13 deletions src/vmm/src/device_manager/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// found in the THIRD-PARTY file.
#![cfg(target_arch = "x86_64")]

use std::fmt;
use std::sync::{Arc, Mutex};

use devices::legacy::{EventFdTrigger, SerialDevice, SerialEventsWrapper};
Expand All @@ -17,25 +16,16 @@ use utils::eventfd::EventFd;
use vm_superio::Serial;

/// Errors corresponding to the `PortIODeviceManager`.
#[derive(Debug, derive_more::From)]
#[derive(Debug, derive_more::From, thiserror::Error)]
pub enum Error {
/// Cannot add legacy device to Bus.
#[error("Failed to add legacy device to Bus: {0}")]
BusError(devices::BusError),
/// Cannot create EventFd.
#[error("Failed to create EventFd: {0}")]
EventFd(std::io::Error),
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::Error::*;

match *self {
BusError(ref err) => write!(f, "Failed to add legacy device to Bus: {}", err),
EventFd(ref err) => write!(f, "Failed to create EventFd: {}", err),
}
}
}

type Result<T> = ::std::result::Result<T, Error>;

fn create_serial(com_event: EventFdTrigger) -> Result<Arc<Mutex<SerialDevice>>> {
Expand Down
4 changes: 4 additions & 0 deletions src/vmm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
//! machine (microVM).
#![deny(missing_docs)]

/// Architecture specific bindings.
#[allow(missing_docs)]
pub mod arch_gen;

/// Implements platform specific functionality.
/// Supported platforms: x86_64 and aarch64.
pub mod arch;
Expand Down
43 changes: 14 additions & 29 deletions src/vmm/src/vstate/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the THIRD-PARTY file.

use std::fmt::{Display, Formatter};
use std::result;

use kvm_bindings::KVM_API_VERSION;
use kvm_ioctls::{Error as KvmIoctlsError, Kvm};

/// Errors associated with the wrappers over KVM ioctls.
#[derive(Debug, derive_more::From)]
#[derive(Debug, derive_more::From, thiserror::Error)]
pub enum Error {
/// The host kernel reports an invalid KVM API version.
#[error("The host kernel reports an invalid KVM API version: {0}")]
ApiVersion(i32),
/// Cannot initialize the KVM context due to missing capabilities.
#[error("Missing KVM capabilities: {0:?}")]
Capabilities(kvm_ioctls::Cap),
/// Cannot initialize the KVM context.
Initialization(KvmIoctlsError),
}

impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
use self::Error::*;

match self {
ApiVersion(v) => write!(
f,
"The host kernel reports an invalid KVM API version: {}",
v
),
Capabilities(cap) => write!(f, "Missing KVM capabilities: {:?}", cap),
Initialization(err) => {
if err.errno() == libc::EACCES {
write!(
f,
"Error creating KVM object. [{}]\nMake sure the user launching the \
firecracker process is configured on the /dev/kvm file's ACL.",
err
)
} else {
write!(f, "Error creating KVM object. [{}]", err)
}
}
#[error("{}", ({
if .0.errno() == libc::EACCES {
format!(
"Error creating KVM object. [{}]\nMake sure the user \
launching the firecracker process is configured on the /dev/kvm file's ACL.",
.0
)
} else {
format!("Error creating KVM object. [{}]", .0)
}
}
}))]
Initialization(KvmIoctlsError),
}

type Result<T> = result::Result<T, Error>;
Expand Down
Loading

0 comments on commit fa3a8cb

Please sign in to comment.