diff --git a/Cargo.lock b/Cargo.lock index 0dc5227ae28..aba98cf7804 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,20 +82,11 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -[[package]] -name = "c2-chacha" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" -dependencies = [ - "ppv-lite86", -] - [[package]] name = "cc" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" +checksum = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" [[package]] name = "cfg-if" @@ -141,7 +132,6 @@ dependencies = [ "memory_model", "net_gen", "rate_limiter", - "tempfile", "utils", "virtio_gen", ] @@ -180,22 +170,10 @@ dependencies = [ "logger", "mmds", "seccomp", - "tempfile", "utils", "vmm", ] -[[package]] -name = "getrandom" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "itoa" version = "0.4.4" @@ -209,7 +187,6 @@ dependencies = [ "clap", "libc", "regex", - "tempfile", "utils", ] @@ -249,9 +226,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.65" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" [[package]] name = "log" @@ -272,7 +249,6 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "tempfile", "utils", ] @@ -287,7 +263,6 @@ name = "memory_model" version = "0.1.0" dependencies = [ "libc", - "tempfile", "utils", ] @@ -311,12 +286,6 @@ dependencies = [ name = "net_gen" version = "0.1.0" -[[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" - [[package]] name = "proc-macro2" version = "1.0.6" @@ -335,47 +304,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" -dependencies = [ - "getrandom", - "libc", - "rand_chacha", - "rand_core", - "rand_hc", -] - -[[package]] -name = "rand_chacha" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" -dependencies = [ - "c2-chacha", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - [[package]] name = "rate_limiter" version = "0.1.0" @@ -386,12 +314,6 @@ dependencies = [ "utils", ] -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" - [[package]] name = "regex" version = "1.3.1" @@ -410,15 +332,6 @@ version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" -[[package]] -name = "remove_dir_all" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" -dependencies = [ - "winapi", -] - [[package]] name = "rustc-demangle" version = "0.1.16" @@ -457,9 +370,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.42" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a3351dcbc1f067e2c92ab7c3c1f288ad1a4cffc470b5aaddb4c2e0a3ae80043" +checksum = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" dependencies = [ "itoa", "ryu", @@ -468,29 +381,15 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" +checksum = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] -[[package]] -name = "tempfile" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -dependencies = [ - "cfg-if", - "libc", - "rand", - "redox_syscall", - "remove_dir_all", - "winapi", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -520,9 +419,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" +checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" [[package]] name = "unicode-xid" @@ -567,44 +466,15 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "tempfile", "timerfd", "utils", ] [[package]] name = "vmm-sys-util" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ebb6ba7ba5653b69bfd3fab8c8c363945c0d3f616a6a1592e12122c3be4724e" +checksum = "f86cb7552cfb77270aefe112931d8fe6899ae09d4de5c2685a1db5372ed3ab27" dependencies = [ "libc", ] - -[[package]] -name = "wasi" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/src/devices/Cargo.toml b/src/devices/Cargo.toml index 15bdbd33b77..dba9210d2a0 100644 --- a/src/devices/Cargo.toml +++ b/src/devices/Cargo.toml @@ -16,7 +16,3 @@ utils = { path = "../utils" } net_gen = { path = "../net_gen" } rate_limiter = { path = "../rate_limiter" } virtio_gen = { path = "../virtio_gen" } - -[dev-dependencies] -utils = { path = "../utils" } -tempfile = ">=3.0.2" diff --git a/src/devices/src/virtio/block.rs b/src/devices/src/virtio/block.rs index 7979a8e673c..9b0cf2be158 100644 --- a/src/devices/src/virtio/block.rs +++ b/src/devices/src/virtio/block.rs @@ -654,20 +654,20 @@ impl VirtioDevice for Block { #[cfg(test)] mod tests { - extern crate tempfile; + extern crate utils; - use self::tempfile::{tempfile, NamedTempFile}; - use super::*; - - use libc; - use memory_model::Address; use std::fs::{metadata, OpenOptions}; use std::sync::mpsc::Receiver; use std::thread; use std::time::Duration; use std::u32; + use libc; + + use super::*; use crate::virtio::queue::tests::*; + use memory_model::Address; + use utils::tempfile::TempFile; const EPOLLIN: epoll::Events = epoll::Events::EPOLLIN; @@ -707,13 +707,23 @@ mod tests { let epoll_config = EpollConfig::new(0, epoll_raw_fd, sender); - let f: File = tempfile().unwrap(); - f.set_len(0x1000).unwrap(); + let tmp_f = TempFile::new().unwrap(); + tmp_f.as_file().set_len(0x1000).unwrap(); + + let mut perm = tmp_f.as_file().metadata().unwrap().permissions(); + perm.set_readonly(!is_disk_read_only); + tmp_f.as_file().set_permissions(perm).unwrap(); // Rate limiting is enabled but with a high operation rate (10 million ops/s). let rate_limiter = RateLimiter::new(0, None, 0, 100_000, None, 10).unwrap(); DummyBlock { - block: Block::new(f, is_disk_read_only, epoll_config, Some(rate_limiter)).unwrap(), + block: Block::new( + tmp_f.as_file().try_clone().unwrap(), + is_disk_read_only, + epoll_config, + Some(rate_limiter), + ) + .unwrap(), epoll_raw_fd, _receiver, } @@ -1513,8 +1523,8 @@ mod tests { // test block device update handler { - let f = NamedTempFile::new().unwrap(); - let path = f.path().to_path_buf(); + let f = TempFile::new().unwrap(); + let path = f.as_path(); let mdata = metadata(&path).unwrap(); let mut id = vec![0; VIRTIO_BLK_ID_BYTES as usize]; let str_id = format!("{}{}{}", mdata.st_dev(), mdata.st_rdev(), mdata.st_ino()); diff --git a/src/firecracker/Cargo.toml b/src/firecracker/Cargo.toml index 042b8fe74a7..c47072e8027 100644 --- a/src/firecracker/Cargo.toml +++ b/src/firecracker/Cargo.toml @@ -14,6 +14,3 @@ logger = { path = "../logger" } mmds = { path = "../mmds" } seccomp = { path = "../seccomp" } vmm = { path = "../vmm" } - -[dev-dependencies] -tempfile = ">=3.0.2" diff --git a/src/jailer/Cargo.toml b/src/jailer/Cargo.toml index 1f2a6713223..5cac4424723 100644 --- a/src/jailer/Cargo.toml +++ b/src/jailer/Cargo.toml @@ -9,6 +9,3 @@ libc = ">=0.2.39" regex = ">=1.0.0" utils = { path = "../utils" } - -[dev-dependencies] -tempfile = ">=3.0.2" diff --git a/src/jailer/src/cgroup.rs b/src/jailer/src/cgroup.rs index da028696446..1a244562aa7 100644 --- a/src/jailer/src/cgroup.rs +++ b/src/jailer/src/cgroup.rs @@ -238,47 +238,47 @@ impl Cgroup { #[cfg(test)] mod tests { - extern crate tempfile; - - use self::tempfile::{tempdir, tempdir_in, NamedTempFile}; - use super::*; use std::io::Write; use std::path::PathBuf; + use super::*; + use utils::tempdir::TempDir; + use utils::tempfile::TempFile; + #[test] fn test_inherit_from_parent() { // 1. If parent file does not exist, return an error. // This is /A/B/ . - let dir = tempdir().expect("Cannot create temporary directory."); + let dir = TempDir::new().expect("Cannot create temporary directory."); // This is /A/B/C . - let dir2 = tempdir_in(dir.path()).expect("Cannot create temporary directory."); - let mut path2 = PathBuf::from(dir2.path()); + let dir2 = TempDir::new_in(dir.as_path()).expect("Cannot create temporary directory."); + let mut path2 = PathBuf::from(dir2.as_path()); let result = inherit_from_parent(&mut PathBuf::from(&path2), "inexistent"); assert!(result.is_err()); assert!(format!("{:?}", result).contains("ReadToString")); // 2. If parent file exists and is empty, will go one level up, and return error because // the grandparent file does not exist. - let mut named_file = NamedTempFile::new_in(dir.path()).expect("Cannot create named file."); + let named_file = TempFile::new_in(dir.as_path()).expect("Cannot create named file."); let result = inherit_from_parent( &mut path2.clone(), - named_file.path().file_name().unwrap().to_str().unwrap(), + named_file.as_path().file_name().unwrap().to_str().unwrap(), ); assert!(result.is_err()); assert!(format!("{:?}", result).contains("CgroupInheritFromParent")); let child_file = dir2 - .path() - .join(named_file.path().file_name().unwrap().to_str().unwrap()); + .as_path() + .join(named_file.as_path().file_name().unwrap().to_str().unwrap()); // 3. If parent file exists and is not empty, will return ok and child file will have its // contents. let some_line = "Parent line"; - writeln!(named_file, "{}", some_line).expect("Cannot write to file."); + writeln!(named_file.as_file(), "{}", some_line).expect("Cannot write to file."); let result = inherit_from_parent( &mut path2, - named_file.path().file_name().unwrap().to_str().unwrap(), + named_file.as_path().file_name().unwrap().to_str().unwrap(), ); assert!(result.is_ok()); let res = readln_special(&child_file).expect("Cannot read from file."); diff --git a/src/logger/Cargo.toml b/src/logger/Cargo.toml index 3fdd074a3a7..b950b125178 100644 --- a/src/logger/Cargo.toml +++ b/src/logger/Cargo.toml @@ -14,4 +14,4 @@ serde_json = ">=1.0.9" utils = { path = "../utils" } [dev-dependencies] -tempfile = ">=3.0.2" +libc = ">=0.2.39" diff --git a/src/logger/src/lib.rs b/src/logger/src/lib.rs index 8397e09eee7..35f76275ce5 100644 --- a/src/logger/src/lib.rs +++ b/src/logger/src/lib.rs @@ -40,7 +40,7 @@ //! //! ``` //! extern crate libc; -//! extern crate tempfile; +//! extern crate utils; //! //! use libc::c_char; //! use std::io::Cursor; @@ -643,15 +643,15 @@ impl Log for Logger { #[cfg(test)] mod tests { - extern crate tempfile; - use self::tempfile::NamedTempFile; - use super::*; - use log::MetadataBuilder; - - use std::fs::File; + use std::fs::{File, OpenOptions}; use std::io::BufRead; use std::io::BufReader; + use log::MetadataBuilder; + + use super::*; + use utils::tempfile::TempFile; + const TEST_INSTANCE_ID: &str = "TEST-INSTANCE-ID"; const TEST_APP_NAME: &str = "Firecracker"; const TEST_APP_VERSION: &str = "1.0"; @@ -729,28 +729,56 @@ mod tests { error!("error"); // Assert that initialization works only once. + let log_file_temp = - NamedTempFile::new().expect("Failed to create temporary output logging file."); - let log_file = String::from(log_file_temp.path().to_path_buf().to_str().unwrap()); + TempFile::new().expect("Failed to create temporary output logging file."); + let log_file = String::from(log_file_temp.as_path().to_path_buf().to_str().unwrap()); let metrics_file_temp = - NamedTempFile::new().expect("Failed to create temporary metrics logging file."); + TempFile::new().expect("Failed to create temporary metrics logging file."); l.set_instance_id(TEST_INSTANCE_ID.to_string()); assert!(l .init( &app_info, - Box::new(log_file_temp), - Box::new(metrics_file_temp), + Box::new( + OpenOptions::new() + .read(true) + .write(true) + .open(&log_file) + .unwrap() + ), + Box::new( + OpenOptions::new() + .read(true) + .write(true) + .open(metrics_file_temp.as_path()) + .unwrap() + ), ) .is_ok()); info!("info"); warn!("warning"); + let log_file_temp2 = TempFile::new().unwrap(); + let metrics_file_temp2 = TempFile::new().unwrap(); + assert!(l .init( &app_info, - Box::new(NamedTempFile::new().unwrap()), - Box::new(NamedTempFile::new().unwrap()), + Box::new( + OpenOptions::new() + .read(true) + .write(true) + .open(log_file_temp2.as_path()) + .unwrap() + ), + Box::new( + OpenOptions::new() + .read(true) + .write(true) + .open(metrics_file_temp2.as_path()) + .unwrap() + ), ) .is_err()); diff --git a/src/memory_model/Cargo.toml b/src/memory_model/Cargo.toml index 49902467097..88fe6ade4e4 100644 --- a/src/memory_model/Cargo.toml +++ b/src/memory_model/Cargo.toml @@ -5,7 +5,6 @@ authors = ["The Chromium OS Authors"] [dependencies] libc = ">=0.2.39" -utils = { path = "../utils" } [dev-dependencies] -tempfile = ">=3.0.2" +utils = { path = "../utils" } diff --git a/src/memory_model/src/mmap.rs b/src/memory_model/src/mmap.rs index 08584da42a4..9037128aa86 100644 --- a/src/memory_model/src/mmap.rs +++ b/src/memory_model/src/mmap.rs @@ -307,14 +307,15 @@ impl Drop for MemoryMapping { #[cfg(test)] mod tests { - extern crate tempfile; + extern crate utils; - use self::tempfile::tempfile; - use super::*; - use std::fs::File; + use std::fs::{File, OpenOptions}; use std::mem; use std::path::Path; + use self::utils::tempfile::TempFile; + use super::*; + #[test] fn basic_map() { let m = MemoryMapping::new(1024).unwrap(); @@ -383,7 +384,11 @@ mod tests { .read_to_memory(1, &mut file, mem::size_of::()) .is_ok()); - let mut f = tempfile().unwrap(); + let temp_f = TempFile::new().unwrap(); + let mut f = OpenOptions::new() + .read(true) + .open(temp_f.as_path()) + .unwrap(); assert!(mem_map .read_to_memory(1, &mut f, mem::size_of::()) .is_err()); diff --git a/src/utils/src/lib.rs b/src/utils/src/lib.rs index 4bebe0c0891..64435c0b0a8 100644 --- a/src/utils/src/lib.rs +++ b/src/utils/src/lib.rs @@ -4,10 +4,11 @@ #[macro_use] extern crate vmm_sys_util; -pub use vmm_sys_util::{errno, eventfd, ioctl, signal, terminal}; +pub use vmm_sys_util::{errno, eventfd, ioctl, tempdir, tempfile, terminal}; pub mod net; pub mod rand; +pub mod signal; pub mod sm; pub mod structs; pub mod syscall; diff --git a/src/utils/src/rand.rs b/src/utils/src/rand.rs index d18ae3850c1..68539d5b887 100644 --- a/src/utils/src/rand.rs +++ b/src/utils/src/rand.rs @@ -1,4 +1,4 @@ -// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use crate::time; diff --git a/src/utils/src/signal.rs b/src/utils/src/signal.rs new file mode 100644 index 00000000000..07157ca315f --- /dev/null +++ b/src/utils/src/signal.rs @@ -0,0 +1,18 @@ +extern crate libc; +extern crate vmm_sys_util; + +use libc::c_int; +pub use vmm_sys_util::signal::*; + +extern "C" { + fn __libc_current_sigrtmin() -> c_int; + fn __libc_current_sigrtmax() -> c_int; +} + +pub fn sigrtmin() -> c_int { + unsafe { __libc_current_sigrtmin() } +} + +pub fn sigrtmax() -> c_int { + unsafe { __libc_current_sigrtmax() } +} diff --git a/src/utils/src/structs.rs b/src/utils/src/structs.rs index 6c390c05745..dcfc543399f 100644 --- a/src/utils/src/structs.rs +++ b/src/utils/src/structs.rs @@ -1,4 +1,4 @@ -// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // // Portions Copyright 2017 The Chromium OS Authors. All rights reserved. diff --git a/src/utils/src/time.rs b/src/utils/src/time.rs index 1447bece52a..acf1b1525a3 100644 --- a/src/utils/src/time.rs +++ b/src/utils/src/time.rs @@ -1,4 +1,4 @@ -// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use std::fmt; diff --git a/src/utils/src/validators.rs b/src/utils/src/validators.rs index 5d1709174bc..785204da1e5 100644 --- a/src/utils/src/validators.rs +++ b/src/utils/src/validators.rs @@ -1,4 +1,4 @@ -// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // Misc data format validations, shared by multiple Firecracker components. diff --git a/src/vmm/Cargo.toml b/src/vmm/Cargo.toml index 58a2acefc28..d946c76e42c 100644 --- a/src/vmm/Cargo.toml +++ b/src/vmm/Cargo.toml @@ -28,4 +28,4 @@ seccomp = { path = "../seccomp" } cpuid = { path = "../cpuid" } [dev-dependencies] -tempfile = ">=3.0.2" +libc = ">=0.2.39" diff --git a/src/vmm/src/default_syscalls/filters.rs b/src/vmm/src/default_syscalls/filters.rs index bb2fecd8d4f..18cb6cadf48 100644 --- a/src/vmm/src/default_syscalls/filters.rs +++ b/src/vmm/src/default_syscalls/filters.rs @@ -1,10 +1,14 @@ // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 +extern crate libc; +extern crate utils; + use seccomp::{ allow_syscall, allow_syscall_if, Error, SeccompAction, SeccompCmpArgLen as ArgLen, SeccompCmpOp::Eq, SeccompCondition as Cond, SeccompFilter, SeccompRule, }; +use utils::signal::sigrtmin; /// The default filter containing the white listed syscall rules required by `Firecracker` to /// function. @@ -93,11 +97,7 @@ pub fn default_filter() -> Result { 1, ArgLen::DWORD, Eq, - utils::signal::validate_signal_num( - super::super::vstate::VCPU_RTSIG_OFFSET, - true - ) - .map_err(|_| Error::InvalidArgumentNumber)? as u64, + (sigrtmin() + super::super::vstate::VCPU_RTSIG_OFFSET) as u64 )?]], ), allow_syscall(libc::SYS_timerfd_create), diff --git a/src/vmm/src/lib.rs b/src/vmm/src/lib.rs index 8859342b315..b0a95862c2b 100644 --- a/src/vmm/src/lib.rs +++ b/src/vmm/src/lib.rs @@ -1654,19 +1654,16 @@ mod tests { }}; } - extern crate tempfile; - - use super::*; - use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::sync::atomic::AtomicUsize; - use self::tempfile::NamedTempFile; + use super::*; use arch::DeviceType; use devices::virtio::{ActivateResult, MmioDevice, Queue}; use dumbo::MacAddr; + use utils::tempfile::TempFile; use vmm_config::drive::DriveError; use vmm_config::machine_config::CpuFeaturesTemplate; use vmm_config::{RateLimiterConfig, TokenBucketConfig}; @@ -1703,10 +1700,10 @@ mod tests { fn default_kernel_config(&mut self, cust_kernel_path: Option) { let kernel_temp_file = - NamedTempFile::new().expect("Failed to create temporary kernel file."); + TempFile::new().expect("Failed to create temporary kernel file."); let kernel_path = match cust_kernel_path { Some(kernel_path) => kernel_path, - None => kernel_temp_file.path().to_path_buf(), + None => kernel_temp_file.as_path().to_path_buf(), }; let kernel_file = File::open(kernel_path).expect("Cannot open kernel file"); let mut cmdline = kernel_cmdline::Cmdline::new(arch::CMDLINE_MAX_SIZE); @@ -1837,11 +1834,11 @@ mod tests { #[test] fn test_insert_block_device() { let mut vmm = create_vmm_object(InstanceState::Uninitialized); - let f = NamedTempFile::new().unwrap(); + let f = TempFile::new().unwrap(); // Test that creating a new block device returns the correct output. let root_block_device = BlockDeviceConfig { drive_id: String::from("root"), - path_on_host: f.path().to_path_buf(), + path_on_host: f.as_path().to_path_buf(), is_root_device: true, partuuid: None, is_read_only: false, @@ -1857,7 +1854,7 @@ mod tests { // Test that updating a block device returns the correct output. let root_block_device = BlockDeviceConfig { drive_id: String::from("root"), - path_on_host: f.path().to_path_buf(), + path_on_host: f.as_path().to_path_buf(), is_root_device: true, partuuid: None, is_read_only: true, @@ -1873,7 +1870,7 @@ mod tests { // Test insert second drive with the same path fails. let root_block_device = BlockDeviceConfig { drive_id: String::from("dummy_dev"), - path_on_host: f.path().to_path_buf(), + path_on_host: f.as_path().to_path_buf(), is_root_device: false, partuuid: None, is_read_only: true, @@ -1882,11 +1879,11 @@ mod tests { assert!(vmm.insert_block_device(root_block_device.clone()).is_err()); // Test inserting a second drive is ok. - let f = NamedTempFile::new().unwrap(); + let f = TempFile::new().unwrap(); // Test that creating a new block device returns the correct output. let non_root = BlockDeviceConfig { drive_id: String::from("non_root"), - path_on_host: f.path().to_path_buf(), + path_on_host: f.as_path().to_path_buf(), is_root_device: false, partuuid: None, is_read_only: false, @@ -1898,7 +1895,7 @@ mod tests { // devices. let non_root = BlockDeviceConfig { drive_id: String::from("non_root"), - path_on_host: f.path().to_path_buf(), + path_on_host: f.as_path().to_path_buf(), is_root_device: true, partuuid: None, is_read_only: false, @@ -1910,7 +1907,7 @@ mod tests { vmm.set_instance_state(InstanceState::Running); let root_block_device = BlockDeviceConfig { drive_id: String::from("root"), - path_on_host: f.path().to_path_buf(), + path_on_host: f.as_path().to_path_buf(), is_root_device: false, partuuid: None, is_read_only: true, @@ -2239,9 +2236,10 @@ mod tests { let mut vmm = create_vmm_object(InstanceState::Uninitialized); assert!(vmm.check_health().is_err()); + let kernel_file_temp = TempFile::new().unwrap(); vmm.set_kernel_config(KernelConfig { cmdline: kernel_cmdline::Cmdline::new(10), - kernel_file: tempfile::tempfile().unwrap(), + kernel_file: File::open(kernel_file_temp.as_path()).unwrap(), }); assert!(vmm.check_health().is_ok()); } @@ -2283,12 +2281,12 @@ mod tests { #[test] fn test_attach_block_devices() { let mut vmm = create_vmm_object(InstanceState::Uninitialized); - let block_file = NamedTempFile::new().unwrap(); + let block_file = TempFile::new().unwrap(); // Use Case 1: Root Block Device is not specified through PARTUUID. let root_block_device = BlockDeviceConfig { drive_id: String::from("root"), - path_on_host: block_file.path().to_path_buf(), + path_on_host: block_file.as_path().to_path_buf(), is_root_device: true, partuuid: None, is_read_only: false, @@ -2310,7 +2308,7 @@ mod tests { let mut vmm = create_vmm_object(InstanceState::Uninitialized); let root_block_device = BlockDeviceConfig { drive_id: String::from("root"), - path_on_host: block_file.path().to_path_buf(), + path_on_host: block_file.as_path().to_path_buf(), is_root_device: true, partuuid: Some("0eaa91a0-01".to_string()), is_read_only: false, @@ -2335,7 +2333,7 @@ mod tests { let mut vmm = create_vmm_object(InstanceState::Uninitialized); let non_root_block_device = BlockDeviceConfig { drive_id: String::from("not_root"), - path_on_host: block_file.path().to_path_buf(), + path_on_host: block_file.as_path().to_path_buf(), is_root_device: false, partuuid: Some("0eaa91a0-01".to_string()), is_read_only: false, @@ -2370,8 +2368,8 @@ mod tests { } // Test partial update of block devices. - let new_block = NamedTempFile::new().unwrap(); - let path = String::from(new_block.path().to_path_buf().to_str().unwrap()); + let new_block = TempFile::new().unwrap(); + let path = String::from(new_block.as_path().to_path_buf().to_str().unwrap()); assert!(vmm .set_block_device_path("not_root".to_string(), path) .is_ok()); @@ -2384,7 +2382,7 @@ mod tests { vmm.set_instance_state(InstanceState::Running); // Test updating the block device path, after instance start. - let path = String::from(new_block.path().to_path_buf().to_str().unwrap()); + let path = String::from(new_block.as_path().to_path_buf().to_str().unwrap()); match vmm.set_block_device_path("not_root".to_string(), path) { Err(VmmActionError::DriveConfig(ErrorKind::User, DriveError::EpollHandlerNotFound)) => { } @@ -2449,8 +2447,8 @@ mod tests { .is_err()); // Test valid kernel path and invalid cmdline. - let kernel_file = NamedTempFile::new().expect("Failed to create temporary kernel file."); - let kernel_path = String::from(kernel_file.path().to_path_buf().to_str().unwrap()); + let kernel_file = TempFile::new().expect("Failed to create temporary kernel file."); + let kernel_path = String::from(kernel_file.as_path().to_path_buf().to_str().unwrap()); let invalid_cmdline = String::from_utf8(vec![b'X'; arch::CMDLINE_MAX_SIZE + 1]).unwrap(); assert!(vmm .configure_boot_source(BootSourceConfig { @@ -2488,13 +2486,13 @@ mod tests { let mut vmm = create_vmm_object(InstanceState::Uninitialized); vmm.default_kernel_config(None); - let root_file = NamedTempFile::new().unwrap(); - let scratch_file = NamedTempFile::new().unwrap(); + let root_file = TempFile::new().unwrap(); + let scratch_file = TempFile::new().unwrap(); let scratch_id = "not_root".to_string(); let root_block_device = BlockDeviceConfig { drive_id: String::from("root"), - path_on_host: root_file.path().to_path_buf(), + path_on_host: root_file.as_path().to_path_buf(), is_root_device: true, partuuid: None, is_read_only: false, @@ -2502,7 +2500,7 @@ mod tests { }; let non_root_block_device = BlockDeviceConfig { drive_id: scratch_id.clone(), - path_on_host: scratch_file.path().to_path_buf(), + path_on_host: scratch_file.as_path().to_path_buf(), is_root_device: false, partuuid: None, is_read_only: true, @@ -2605,11 +2603,11 @@ mod tests { #[test] fn test_init_logger() { // Error case: update after instance is running - let log_file = NamedTempFile::new().unwrap(); - let metrics_file = NamedTempFile::new().unwrap(); + let log_file = TempFile::new().unwrap(); + let metrics_file = TempFile::new().unwrap(); let desc = LoggerConfig { - log_fifo: log_file.path().to_str().unwrap().to_string(), - metrics_fifo: metrics_file.path().to_str().unwrap().to_string(), + log_fifo: log_file.as_path().to_str().unwrap().to_string(), + metrics_fifo: metrics_file.as_path().to_str().unwrap().to_string(), level: LoggerLevel::Warning, show_level: true, show_log_origin: true, @@ -2626,7 +2624,7 @@ mod tests { // Error case: initializing logger with invalid log pipe returns error. let desc = LoggerConfig { log_fifo: String::from("not_found_file_log"), - metrics_fifo: metrics_file.path().to_str().unwrap().to_string(), + metrics_fifo: metrics_file.as_path().to_str().unwrap().to_string(), level: LoggerLevel::Debug, show_level: false, show_log_origin: false, @@ -2637,7 +2635,7 @@ mod tests { // Error case: initializing logger with invalid metrics pipe returns error. let desc = LoggerConfig { - log_fifo: log_file.path().to_str().unwrap().to_string(), + log_fifo: log_file.as_path().to_str().unwrap().to_string(), metrics_fifo: String::from("not_found_file_metrics"), level: LoggerLevel::Debug, show_level: false, @@ -2660,11 +2658,11 @@ mod tests { assert!(vmm.init_logger(desc).is_err()); // Initializing logger with valid pipes is ok. - let log_file = NamedTempFile::new().unwrap(); - let metrics_file = NamedTempFile::new().unwrap(); + let log_file = TempFile::new().unwrap(); + let metrics_file = TempFile::new().unwrap(); let desc = LoggerConfig { - log_fifo: log_file.path().to_str().unwrap().to_string(), - metrics_fifo: metrics_file.path().to_str().unwrap().to_string(), + log_fifo: log_file.as_path().to_str().unwrap().to_string(), + metrics_fifo: metrics_file.as_path().to_str().unwrap().to_string(), level: LoggerLevel::Info, show_level: true, show_log_origin: true, @@ -2679,7 +2677,7 @@ mod tests { assert!(vmm.flush_metrics().is_ok()); - let f = File::open(metrics_file).unwrap(); + let f = File::open(metrics_file.as_path()).unwrap(); let mut reader = BufReader::new(f); let mut line = String::new(); @@ -2695,7 +2693,7 @@ mod tests { // Validate logfile works. warn!("this is a test"); - let f = File::open(log_file).unwrap(); + let f = File::open(log_file.as_path()).unwrap(); let mut reader = BufReader::new(f); let mut line = String::new(); @@ -2937,8 +2935,8 @@ mod tests { fn test_configure_vmm_from_json() { let mut vmm = create_vmm_object(InstanceState::Uninitialized); - let kernel_file = NamedTempFile::new().unwrap(); - let rootfs_file = NamedTempFile::new().unwrap(); + let kernel_file = TempFile::new().unwrap(); + let rootfs_file = TempFile::new().unwrap(); // We will test different scenarios with invalid resources configuration and // check the expected errors. We include configuration for the kernel and rootfs @@ -2961,7 +2959,7 @@ mod tests { }} ] }}"#, - rootfs_file.path().to_str().unwrap() + rootfs_file.as_path().to_str().unwrap() ); match vmm.configure_from_json(json) { @@ -2988,7 +2986,7 @@ mod tests { }} ] }}"#, - kernel_file.path().to_str().unwrap() + kernel_file.as_path().to_str().unwrap() ); match vmm.configure_from_json(json) { @@ -3020,8 +3018,8 @@ mod tests { "ht_enabled": false }} }}"#, - kernel_file.path().to_str().unwrap(), - rootfs_file.path().to_str().unwrap() + kernel_file.as_path().to_str().unwrap(), + rootfs_file.as_path().to_str().unwrap() ); match vmm.configure_from_json(json) { @@ -3053,8 +3051,8 @@ mod tests { "ht_enabled": false }} }}"#, - kernel_file.path().to_str().unwrap(), - rootfs_file.path().to_str().unwrap() + kernel_file.as_path().to_str().unwrap(), + rootfs_file.as_path().to_str().unwrap() ); match vmm.configure_from_json(json) { @@ -3085,8 +3083,8 @@ mod tests { "metrics_fifo": "metrics.fifo" }} }}"#, - kernel_file.path().to_str().unwrap(), - rootfs_file.path().to_str().unwrap() + kernel_file.as_path().to_str().unwrap(), + rootfs_file.as_path().to_str().unwrap() ); match vmm.configure_from_json(json) { @@ -3123,8 +3121,8 @@ mod tests { }} ] }}"#, - kernel_file.path().to_str().unwrap(), - rootfs_file.path().to_str().unwrap() + kernel_file.as_path().to_str().unwrap(), + rootfs_file.as_path().to_str().unwrap() ); match vmm.configure_from_json(json) { @@ -3164,8 +3162,8 @@ mod tests { "ht_enabled": false }} }}"#, - kernel_file.path().to_str().unwrap(), - rootfs_file.path().to_str().unwrap() + kernel_file.as_path().to_str().unwrap(), + rootfs_file.as_path().to_str().unwrap() ); assert!(vmm.configure_from_json(json).is_ok()); diff --git a/src/vmm/src/signal_handler.rs b/src/vmm/src/signal_handler.rs index 9d915589948..c8aca7ec463 100644 --- a/src/vmm/src/signal_handler.rs +++ b/src/vmm/src/signal_handler.rs @@ -1,9 +1,6 @@ // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -extern crate logger; -extern crate utils; - use libc::{_exit, c_int, c_void, siginfo_t, SIGBUS, SIGSEGV, SIGSYS}; use logger::{Metric, LOGGER, METRICS}; @@ -105,30 +102,9 @@ pub fn register_signal_handlers() -> utils::errno::Result<()> { // register a signal handler which will be called in the current thread and will interrupt // whatever work is done on the current thread, so we have to keep in mind that the registered // signal handler must only do async-signal-safe operations. - unsafe { - register_signal_handler( - SIGSYS, - utils::signal::SignalHandler::Siginfo(sigsys_handler), - false, - libc::SA_SIGINFO, - )?; - } - unsafe { - register_signal_handler( - SIGBUS, - utils::signal::SignalHandler::Siginfo(sigbus_sigsegv_handler), - false, - libc::SA_SIGINFO, - )?; - } - unsafe { - register_signal_handler( - SIGSEGV, - utils::signal::SignalHandler::Siginfo(sigbus_sigsegv_handler), - false, - libc::SA_SIGINFO, - )?; - } + register_signal_handler(SIGSYS, sigsys_handler)?; + register_signal_handler(SIGBUS, sigbus_sigsegv_handler)?; + register_signal_handler(SIGSEGV, sigbus_sigsegv_handler)?; Ok(()) } diff --git a/src/vmm/src/vmm_config/drive.rs b/src/vmm/src/vmm_config/drive.rs index 4bd41724ac1..3763a1607b3 100644 --- a/src/vmm/src/vmm_config/drive.rs +++ b/src/vmm/src/vmm_config/drive.rs @@ -228,10 +228,9 @@ impl BlockDeviceConfigs { #[cfg(test)] mod tests { - extern crate tempfile; - use self::tempfile::NamedTempFile; use super::*; + use utils::tempfile::TempFile; // This implementation is used only in tests. // We cannot directly derive clone because RateLimiter does not implement clone. @@ -257,8 +256,8 @@ mod tests { #[test] fn test_add_non_root_block_device() { - let dummy_file = NamedTempFile::new().unwrap(); - let dummy_path = dummy_file.path().to_path_buf(); + let dummy_file = TempFile::new().unwrap(); + let dummy_path = dummy_file.as_path().to_path_buf(); let dummy_id = String::from("1"); let dummy_block_device = BlockDeviceConfig { path_on_host: dummy_path.clone(), @@ -289,8 +288,8 @@ mod tests { #[test] fn test_add_one_root_block_device() { - let dummy_file = NamedTempFile::new().unwrap(); - let dummy_path = dummy_file.path().to_path_buf(); + let dummy_file = TempFile::new().unwrap(); + let dummy_path = dummy_file.as_path().to_path_buf(); let dummy_block_device = BlockDeviceConfig { path_on_host: dummy_path, @@ -315,8 +314,8 @@ mod tests { #[test] fn test_add_two_root_block_devices_configs() { - let dummy_file_1 = NamedTempFile::new().unwrap(); - let dummy_path_1 = dummy_file_1.path().to_path_buf(); + let dummy_file_1 = TempFile::new().unwrap(); + let dummy_path_1 = dummy_file_1.as_path().to_path_buf(); let root_block_device_1 = BlockDeviceConfig { path_on_host: dummy_path_1, is_root_device: true, @@ -326,8 +325,8 @@ mod tests { rate_limiter: None, }; - let dummy_file_2 = NamedTempFile::new().unwrap(); - let dummy_path_2 = dummy_file_2.path().to_path_buf(); + let dummy_file_2 = TempFile::new().unwrap(); + let dummy_path_2 = dummy_file_2.as_path().to_path_buf(); let root_block_device_2 = BlockDeviceConfig { path_on_host: dummy_path_2, is_root_device: true, @@ -350,8 +349,8 @@ mod tests { #[test] // Test BlockDevicesConfigs::add when you first add the root device and then the other devices. fn test_add_root_block_device_first() { - let dummy_file_1 = NamedTempFile::new().unwrap(); - let dummy_path_1 = dummy_file_1.path().to_path_buf(); + let dummy_file_1 = TempFile::new().unwrap(); + let dummy_path_1 = dummy_file_1.as_path().to_path_buf(); let root_block_device = BlockDeviceConfig { path_on_host: dummy_path_1, is_root_device: true, @@ -361,8 +360,8 @@ mod tests { rate_limiter: None, }; - let dummy_file_2 = NamedTempFile::new().unwrap(); - let dummy_path_2 = dummy_file_2.path().to_path_buf(); + let dummy_file_2 = TempFile::new().unwrap(); + let dummy_path_2 = dummy_file_2.as_path().to_path_buf(); let dummy_block_device_2 = BlockDeviceConfig { path_on_host: dummy_path_2, is_root_device: false, @@ -372,8 +371,8 @@ mod tests { rate_limiter: None, }; - let dummy_file_3 = NamedTempFile::new().unwrap(); - let dummy_path_3 = dummy_file_3.path().to_path_buf(); + let dummy_file_3 = TempFile::new().unwrap(); + let dummy_path_3 = dummy_file_3.as_path().to_path_buf(); let dummy_block_device_3 = BlockDeviceConfig { path_on_host: dummy_path_3, is_root_device: false, @@ -407,8 +406,8 @@ mod tests { #[test] // Test BlockDevicesConfigs::add when you add other devices first and then the root device. fn test_root_block_device_add_last() { - let dummy_file_1 = NamedTempFile::new().unwrap(); - let dummy_path_1 = dummy_file_1.path().to_path_buf(); + let dummy_file_1 = TempFile::new().unwrap(); + let dummy_path_1 = dummy_file_1.as_path().to_path_buf(); let root_block_device = BlockDeviceConfig { path_on_host: dummy_path_1.clone(), is_root_device: true, @@ -418,8 +417,8 @@ mod tests { rate_limiter: None, }; - let dummy_file_2 = NamedTempFile::new().unwrap(); - let dummy_path_2 = dummy_file_2.path().to_path_buf(); + let dummy_file_2 = TempFile::new().unwrap(); + let dummy_path_2 = dummy_file_2.as_path().to_path_buf(); let dummy_block_device_2 = BlockDeviceConfig { path_on_host: dummy_path_2, is_root_device: false, @@ -429,8 +428,8 @@ mod tests { rate_limiter: None, }; - let dummy_file_3 = NamedTempFile::new().unwrap(); - let dummy_path_3 = dummy_file_3.path().to_path_buf(); + let dummy_file_3 = TempFile::new().unwrap(); + let dummy_path_3 = dummy_file_3.as_path().to_path_buf(); let dummy_block_device_3 = BlockDeviceConfig { path_on_host: dummy_path_3, is_root_device: false, @@ -465,8 +464,8 @@ mod tests { #[test] fn test_update() { - let dummy_file_1 = NamedTempFile::new().unwrap(); - let dummy_path_1 = dummy_file_1.path().to_path_buf(); + let dummy_file_1 = TempFile::new().unwrap(); + let dummy_path_1 = dummy_file_1.as_path().to_path_buf(); let root_block_device = BlockDeviceConfig { path_on_host: dummy_path_1.clone(), is_root_device: true, @@ -476,8 +475,8 @@ mod tests { rate_limiter: None, }; - let dummy_file_2 = NamedTempFile::new().unwrap(); - let dummy_path_2 = dummy_file_2.path().to_path_buf(); + let dummy_file_2 = TempFile::new().unwrap(); + let dummy_path_2 = dummy_file_2.as_path().to_path_buf(); let mut dummy_block_device_2 = BlockDeviceConfig { path_on_host: dummy_path_2.clone(), is_root_device: false, diff --git a/src/vmm/src/vmm_config/logger.rs b/src/vmm/src/vmm_config/logger.rs index 99ac7618bd2..68ccb1a05b7 100644 --- a/src/vmm/src/vmm_config/logger.rs +++ b/src/vmm/src/vmm_config/logger.rs @@ -127,15 +127,15 @@ impl Display for LoggerConfigError { #[cfg(test)] mod tests { - extern crate tempfile; - use self::tempfile::NamedTempFile; + use super::*; + use utils::tempfile::TempFile; #[test] fn test_log_writer() { let log_file_temp = - NamedTempFile::new().expect("Failed to create temporary output logging file."); - let good_file = String::from(log_file_temp.path().to_path_buf().to_str().unwrap()); + TempFile::new().expect("Failed to create temporary output logging file."); + let good_file = String::from(log_file_temp.as_path().to_path_buf().to_str().unwrap()); let res = LoggerWriter::new(&good_file); assert!(res.is_ok()); diff --git a/src/vmm/src/vstate.rs b/src/vmm/src/vstate.rs index 4b93523ac80..3210f7824e5 100644 --- a/src/vmm/src/vstate.rs +++ b/src/vmm/src/vstate.rs @@ -27,7 +27,7 @@ use kvm_ioctls::*; use logger::{LogOption, Metric, LOGGER, METRICS}; use memory_model::{Address, GuestAddress, GuestMemory, GuestMemoryError}; use utils::eventfd::EventFd; -use utils::signal::{register_signal_handler, Killable, SignalHandler}; +use utils::signal::{register_signal_handler, sigrtmin, Killable}; use utils::sm::StateMachine; #[cfg(target_arch = "x86_64")] use vmm_config::machine_config::{CpuFeaturesTemplate, VmConfig}; @@ -390,16 +390,9 @@ impl Vcpu { }); } } - unsafe { - // This uses an async signal safe handler to kill the vcpu handles. - register_signal_handler( - VCPU_RTSIG_OFFSET, - SignalHandler::Siginfo(handle_signal), - true, - libc::SA_SIGINFO, - ) + + register_signal_handler(sigrtmin() + VCPU_RTSIG_OFFSET, handle_signal) .expect("Failed to register vcpu signal handler"); - } } /// Constructs a new VCPU for `vm`. @@ -842,7 +835,7 @@ impl VcpuHandle { .expect("event sender channel closed on vcpu end."); // Kick the vcpu so it picks up the message. self.vcpu_thread - .kill(VCPU_RTSIG_OFFSET) + .kill(sigrtmin() + VCPU_RTSIG_OFFSET) .map_err(Error::SignalVcpu)?; Ok(()) } @@ -880,6 +873,7 @@ mod tests { use kernel::cmdline as kernel_cmdline; use kernel::loader as kernel_loader; + use utils::signal::validate_signal_num; // Auxiliary function being used throughout the tests. fn setup_vcpu(mem_size: usize) -> (Vm, Vcpu) { @@ -1137,7 +1131,7 @@ mod tests { barrier.wait(); // Kick the Vcpu using the custom signal. handle - .kill(VCPU_RTSIG_OFFSET) + .kill(sigrtmin() + VCPU_RTSIG_OFFSET) .expect("failed to signal thread"); handle.join().expect("failed to join thread"); // Verify that the Vcpu saw its kvm immediate-exit as set. @@ -1265,4 +1259,9 @@ mod tests { // Validate that the vCPU signaled its exit. assert_eq!(vcpu_exit_evt.read().unwrap(), 1); } + + #[test] + fn test_vcpu_rtsig_offset() { + assert!(validate_signal_num(sigrtmin() + VCPU_RTSIG_OFFSET).is_ok()); + } } diff --git a/tests/integration_tests/build/test_coverage.py b/tests/integration_tests/build/test_coverage.py index 4e8c77d32f2..37012d1835b 100644 --- a/tests/integration_tests/build/test_coverage.py +++ b/tests/integration_tests/build/test_coverage.py @@ -19,7 +19,7 @@ import host_tools.cargo_build as host # pylint: disable=import-error -COVERAGE_TARGET_PCT = 85.3 +COVERAGE_TARGET_PCT = 85.2 COVERAGE_MAX_DELTA = 0.01 CARGO_KCOV_REL_PATH = os.path.join(host.CARGO_BUILD_REL_PATH, 'kcov')