Skip to content

Commit

Permalink
Merge branch 'main' into the-big-ab-ification
Browse files Browse the repository at this point in the history
  • Loading branch information
roypat authored Oct 20, 2023
2 parents 932dc87 + 54caed2 commit e966b7f
Show file tree
Hide file tree
Showing 64 changed files with 535 additions and 954 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
defaults_for_performance,
{
# Kani runs fastest on m6i.metal
"instances": ["m6i.metal"],
"instances": ["m6a.metal"],
"platforms": [("al2", "linux_5.10")],
"timeout_in_minutes": 300,
},
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@
- Simplified and clarified the removal policy of deprecated API elements
to follow semantic versioning 2.0.0. For more information, please refer to
[this GitHub discussion](https://github.com/firecracker-microvm/firecracker/discussions/4135).
- [#4180](https://github.com/firecracker-microvm/firecracker/pull/4180):
Refactored error propagation to avoid logging and printing an error on
exits with a zero exit code. Now, on successful exit
"Firecracker exited successfully" is logged.

### Deprecated

### Fixed

- Fixed a bug that ignored the `--show-log-origin` option, preventing it from
printing the source code file of the log messages.
- [#4178](https://github.com/firecracker-microvm/firecracker/pull/4178):
Fixed a bug reporting a non-zero exit code on successful shutdown when
starting Firecracker with `--no-api`.

## [1.5.0]

Expand Down
42 changes: 21 additions & 21 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion src/cpu-template-helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bench = false
clap = { version = "4.4.6", features = ["derive", "string"] }
displaydoc = "0.2.4"
libc = "0.2.149"
serde = { version = "1.0.188", features = ["derive"] }
serde = { version = "1.0.189", features = ["derive"] }
serde_json = "1.0.107"
thiserror = "1.0.49"

Expand Down
6 changes: 3 additions & 3 deletions src/firecracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ vmm = { path = "../vmm" }

[dev-dependencies]
cargo_toml = "0.16.3"
regex = { version = "1.10.0", default-features = false, features = ["std", "unicode-perl"] }
regex = { version = "1.10.2", default-features = false, features = ["std", "unicode-perl"] }

# Dev-Dependencies for uffd examples
serde = { version = "1.0.188", features = ["derive"] }
serde = { version = "1.0.189", features = ["derive"] }
userfaultfd = "0.7.0"

[build-dependencies]
bincode = "1.2.1"
seccompiler = { path = "../seccompiler" }
serde = { version = "1.0.188" }
serde = { version = "1.0.189" }
serde_json = "1.0.107"

[[example]]
Expand Down
13 changes: 9 additions & 4 deletions src/firecracker/src/api_server_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl ApiServerAdapter {
vm_resources: VmResources,
vmm: Arc<Mutex<Vmm>>,
event_manager: &mut EventManager,
) -> FcExitCode {
) -> Result<(), FcExitCode> {
let api_adapter = Arc::new(Mutex::new(Self {
api_event_fd,
from_api,
Expand All @@ -64,10 +64,14 @@ impl ApiServerAdapter {
event_manager
.run()
.expect("EventManager events driver fatal error");
if let Some(exit_code) = vmm.lock().unwrap().shutdown_exit_code() {
return exit_code;

match vmm.lock().unwrap().shutdown_exit_code() {
Some(FcExitCode::Ok) => break,
Some(exit_code) => return Err(exit_code),
None => continue,
}
}
Ok(())
}

fn handle_request(&mut self, req_action: VmmAction) {
Expand Down Expand Up @@ -245,7 +249,8 @@ pub(crate) fn run_with_api(
api_thread.join().expect("Api thread should join");

match result {
Ok(exit_code) => Err(ApiServerError::MicroVMStoppedWithoutError(exit_code)),
Ok(Ok(())) => Ok(()),
Ok(Err(exit_code)) => Err(ApiServerError::MicroVMStoppedWithoutError(exit_code)),
Err(exit_error) => Err(exit_error),
}
}
9 changes: 7 additions & 2 deletions src/firecracker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl From<MainError> for ExitCode {
MainError::InvalidLogLevel(_) => FcExitCode::BadConfiguration,
MainError::RunWithApi(ApiServerError::MicroVMStoppedWithoutError(code)) => code,
MainError::RunWithApi(ApiServerError::MicroVMStoppedWithError(code)) => code,
MainError::RunWithoutApiError(RunWithoutApiError::Shutdown(code)) => code,
_ => FcExitCode::GenericError,
};

Expand All @@ -97,6 +98,7 @@ fn main() -> ExitCode {
eprintln!("Error: {err:?}");
ExitCode::from(err)
} else {
info!("Firecracker exited successfully");
ExitCode::SUCCESS
}
}
Expand Down Expand Up @@ -630,8 +632,11 @@ fn run_without_api(
.run()
.expect("Failed to start the event manager");

if let Some(exit_code) = vmm.lock().unwrap().shutdown_exit_code() {
return Err(RunWithoutApiError::Shutdown(exit_code));
match vmm.lock().unwrap().shutdown_exit_code() {
Some(FcExitCode::Ok) => break,
Some(exit_code) => return Err(RunWithoutApiError::Shutdown(exit_code)),
None => continue,
}
}
Ok(())
}
2 changes: 1 addition & 1 deletion src/jailer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bench = false
[dependencies]
libc = "0.2.149"
nix = { version = "0.27.1", default-features = false, features = ["dir"] }
regex = { version = "1.10.0", default-features = false, features = ["std"] }
regex = { version = "1.10.2", default-features = false, features = ["std"] }
thiserror = "1.0.49"

utils = { path = "../utils" }
2 changes: 1 addition & 1 deletion src/seccompiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bench = false
bincode = "1.2.1"
displaydoc = "0.2.4"
libc = "0.2.149"
serde = { version = "1.0.188", features = ["derive"] }
serde = { version = "1.0.189", features = ["derive"] }
serde_json = "1.0.107"
thiserror = "1.0.49"

Expand Down
2 changes: 1 addition & 1 deletion src/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ displaydoc = "0.2.4"
versionize = "0.1.10"
versionize_derive = "0.1.6"
vmm-sys-util = "0.11.2"
vm-memory = { version = "0.12.0", features = ["backend-mmap", "backend-bitmap"] }
vm-memory = { version = "0.13.0", features = ["backend-mmap", "backend-bitmap"] }

[dev-dependencies]
serde_json = "1.0.99"
4 changes: 2 additions & 2 deletions src/vmm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ kvm-bindings = { version = "0.6.0", features = ["fam-wrappers"] }
kvm-ioctls = "0.15.0"
lazy_static = "1.4.0"
libc = "0.2.117"
linux-loader = "0.9.0"
memfd = "0.6.3"
linux-loader = "0.10.0"
serde = { version = "1.0.136", features = ["derive", "rc"] }
semver = { version = "1.0.17", features = ["serde"] }
serde_json = "1.0.78"
Expand All @@ -30,7 +30,7 @@ versionize = "0.1.10"
versionize_derive = "0.1.6"
vm-allocator = "0.1.0"
vm-superio = "0.7.0"
vm-memory = { version = "0.12.0", features = ["backend-mmap", "backend-bitmap"] }
vm-memory = { version = "0.13.1", features = ["backend-mmap", "backend-bitmap"] }
log = { version = "0.4.17", features = ["std", "serde"] }
aes-gcm = { version = "0.10.1", default-features = false, features = ["aes"] }
base64 = "0.13.0"
Expand Down
29 changes: 10 additions & 19 deletions src/vmm/src/arch/x86_64/mptable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use std::convert::TryFrom;
use std::fmt::Debug;
use std::{io, mem};
use std::mem;

use libc::c_char;

Expand Down Expand Up @@ -135,7 +135,7 @@ pub fn setup_mptable(mem: &GuestMemoryMmap, num_cpus: u8) -> Result<(), MptableE
return Err(MptableError::AddressOverflow);
}

mem.read_from(base_mp, &mut io::repeat(0), mp_size)
mem.write_slice(&vec![0; mp_size], base_mp)
.map_err(|_| MptableError::Clear)?;

{
Expand Down Expand Up @@ -358,24 +358,15 @@ mod tests {
let mpc_offset = GuestAddress(u64::from(mpf_intel.physptr));
let mpc_table: mpspec::mpc_table = mem.read_obj(mpc_offset).unwrap();

#[derive(Debug)]
struct Sum(u8);
impl io::Write for Sum {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
for v in buf.iter() {
self.0 = self.0.wrapping_add(*v);
}
Ok(buf.len())
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}

let mut sum = Sum(0);
mem.write_to(mpc_offset, &mut sum, mpc_table.length as usize)
let mut buffer = Vec::new();
mem.write_volatile_to(mpc_offset, &mut buffer, mpc_table.length as usize)
.unwrap();
assert_eq!(sum.0, 0);
assert_eq!(
buffer
.iter()
.fold(0u8, |accum, &item| accum.wrapping_add(item)),
0
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/vmm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use userfaultfd::Uffd;
use utils::eventfd::EventFd;
use utils::time::TimestampUs;
use utils::u64_to_usize;
use vm_memory::ReadVolatile;
#[cfg(target_arch = "aarch64")]
use vm_superio::Rtc;
use vm_superio::Serial;
Expand Down Expand Up @@ -54,7 +55,6 @@ use crate::resources::VmResources;
use crate::vmm_config::boot_source::BootConfig;
use crate::vmm_config::instance_info::InstanceInfo;
use crate::vmm_config::machine_config::{MachineConfigUpdate, VmConfig, VmConfigError};
use crate::volatile::ReadVolatile;
use crate::vstate::memory::{
create_memfd, GuestAddress, GuestMemory, GuestMemoryExtension, GuestMemoryMmap,
};
Expand Down
3 changes: 1 addition & 2 deletions src/vmm/src/devices/virtio/block/io/sync_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
use std::fs::File;
use std::io::{Seek, SeekFrom, Write};

use vm_memory::GuestMemoryError;
use vm_memory::{GuestMemoryError, ReadVolatile, WriteVolatile};

use crate::volatile::{ReadVolatile, WriteVolatile};
use crate::vstate::memory::{GuestAddress, GuestMemory, GuestMemoryMmap};

#[derive(Debug)]
Expand Down
6 changes: 3 additions & 3 deletions src/vmm/src/devices/virtio/iovec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ mod verification {
// to 256 entries which is the theoretical maximum length of a `DescriptorChain`, but in reality
// our code does not make any assumption about the length of the chain, apart from it being
// >= 1.
const MAX_DESC_LENGTH: usize = 5;
const MAX_DESC_LENGTH: usize = 4;

fn create_iovecs(mem: *mut u8, size: usize) -> (Vec<iovec>, usize) {
let nr_descs: usize = kani::any_where(|&n| n <= MAX_DESC_LENGTH);
Expand Down Expand Up @@ -588,7 +588,7 @@ mod verification {
}

#[kani::proof]
#[kani::unwind(6)]
#[kani::unwind(5)]
#[kani::solver(cadical)]
fn verify_read_from_iovec() {
let iov: IoVecBuffer = kani::any();
Expand All @@ -612,7 +612,7 @@ mod verification {
}

#[kani::proof]
#[kani::unwind(6)]
#[kani::unwind(5)]
#[kani::solver(cadical)]
fn verify_write_to_iovec() {
let mut iov_mut: IoVecBufferMut = kani::any();
Expand Down
Loading

0 comments on commit e966b7f

Please sign in to comment.