Skip to content
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
6 changes: 6 additions & 0 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 @@ -19,7 +19,7 @@ serde_json = "1.0.128"
thiserror = "1.0.63"

vmm = { path = "../vmm" }
vmm-sys-util = { version = "0.12.1", features = ["with-serde"] }
vmm-sys-util = "0.12.1"

[features]
tracing = ["log-instrument", "vmm/tracing"]
Expand Down
1 change: 1 addition & 0 deletions src/firecracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ thiserror = "1.0.63"
timerfd = "1.6.0"
utils = { path = "../utils" }
vmm = { path = "../vmm" }
vmm-sys-util = { version = "0.12.1", features = ["with-serde"] }

[dev-dependencies]
cargo_toml = "0.20.4"
Expand Down
6 changes: 3 additions & 3 deletions src/firecracker/examples/uffd/uffd_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::ptr;

use serde::{Deserialize, Serialize};
use userfaultfd::{Error, Event, Uffd};
use utils::sock_ctrl_msg::ScmSocket;
use vmm_sys_util::sock_ctrl_msg::ScmSocket;

// This is the same with the one used in src/vmm.
/// This describes the mapping between Firecracker base virtual address and offset in the
Expand Down Expand Up @@ -299,8 +299,8 @@ mod tests {
use std::mem::MaybeUninit;
use std::os::unix::net::UnixListener;

use utils::tempdir::TempDir;
use utils::tempfile::TempFile;
use vmm_sys_util::tempdir::TempDir;
use vmm_sys_util::tempfile::TempFile;

use super::*;

Expand Down
13 changes: 6 additions & 7 deletions src/firecracker/src/api_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ pub use micro_http::{Body, HttpServer, Request, Response, ServerError, StatusCod
use parsed_request::{ParsedRequest, RequestAction};
use seccompiler::BpfProgramRef;
use serde_json::json;
use utils::eventfd::EventFd;
use utils::time::{get_time_us, ClockType};
use vmm::logger::{
debug, error, info, update_metric_with_elapsed_time, warn, ProcessTimeReporter, METRICS,
};
use vmm::rpc_interface::{ApiRequest, ApiResponse, VmmAction};
use vmm::vmm_config::snapshot::SnapshotType;
use vmm_sys_util::eventfd::EventFd;

/// Structure associated with the API server implementation.
#[derive(Debug)]
Expand Down Expand Up @@ -101,17 +102,15 @@ impl ApiServer {
}
};
for server_request in request_vec {
let request_processing_start_us =
utils::time::get_time_us(utils::time::ClockType::Monotonic);
let request_processing_start_us = get_time_us(ClockType::Monotonic);
// Use `self.handle_request()` as the processing callback.
let response = server_request
.process(|request| self.handle_request(request, request_processing_start_us));
if let Err(err) = server.respond(response) {
error!("API Server encountered an error on response: {}", err);
};

let delta_us = utils::time::get_time_us(utils::time::ClockType::Monotonic)
- request_processing_start_us;
let delta_us = get_time_us(ClockType::Monotonic) - request_processing_start_us;
debug!("Total previous API call duration: {} us.", delta_us);
}
}
Expand Down Expand Up @@ -205,14 +204,14 @@ mod tests {
use std::thread;

use micro_http::HttpConnection;
use utils::tempfile::TempFile;
use utils::time::ClockType;
use vmm::builder::StartMicrovmError;
use vmm::logger::StoreMetric;
use vmm::rpc_interface::{VmmActionError, VmmData};
use vmm::seccomp_filters::get_empty_filters;
use vmm::vmm_config::instance_info::InstanceInfo;
use vmm::vmm_config::snapshot::CreateSnapshotParams;
use vmm_sys_util::tempfile::TempFile;

use super::request::cpu_configuration::parse_put_cpu_config;
use super::*;
Expand Down Expand Up @@ -259,7 +258,7 @@ mod tests {
// latencies_us.pause_vm metric can be set to 0, failing the assertion below. By
// subtracting 1 we assure that the metric will always be set to at least 1 (if it gets set
// at all, which is what this test is trying to prove).
let start_time_us = utils::time::get_time_us(ClockType::Monotonic) - 1;
let start_time_us = get_time_us(ClockType::Monotonic) - 1;
assert_eq!(METRICS.latencies_us.pause_vm.fetch(), 0);
to_api.send(Box::new(Ok(VmmData::Empty))).unwrap();
let response =
Expand Down
4 changes: 2 additions & 2 deletions src/firecracker/src/api_server_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use std::thread;

use event_manager::{EventOps, Events, MutEventSubscriber, SubscriberOps};
use seccompiler::BpfThreadMap;
use utils::epoll::EventSet;
use utils::eventfd::EventFd;
use vmm::logger::{error, warn, ProcessTimeReporter};
use vmm::resources::VmResources;
use vmm::rpc_interface::{
Expand All @@ -19,6 +17,8 @@ use vmm::rpc_interface::{
};
use vmm::vmm_config::instance_info::InstanceInfo;
use vmm::{EventManager, FcExitCode, Vmm};
use vmm_sys_util::epoll::EventSet;
use vmm_sys_util::eventfd::EventFd;

use super::api_server::{ApiServer, HttpServer, ServerError};

Expand Down
4 changes: 2 additions & 2 deletions src/firecracker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use event_manager::SubscriberOps;
use seccomp::FilterError;
use seccompiler::BpfThreadMap;
use utils::arg_parser::{ArgParser, Argument};
use utils::terminal::Terminal;
use utils::validators::validate_instance_id;
use vmm::builder::StartMicrovmError;
use vmm::logger::{
Expand All @@ -32,6 +31,7 @@ use vmm::snapshot::{Snapshot, SnapshotError};
use vmm::vmm_config::instance_info::{InstanceInfo, VmState};
use vmm::vmm_config::metrics::{init_metrics, MetricsConfig, MetricsConfigError};
use vmm::{EventManager, FcExitCode, HTTP_MAX_PAYLOAD_SIZE};
use vmm_sys_util::terminal::Terminal;

use crate::seccomp::SeccompConfig;

Expand All @@ -47,7 +47,7 @@ enum MainError {
/// Failed to set the logger: {0}
SetLogger(vmm::logger::LoggerInitError),
/// Failed to register signal handlers: {0}
RegisterSignalHandlers(#[source] utils::errno::Error),
RegisterSignalHandlers(#[source] vmm_sys_util::errno::Error),
/// Arguments parsing error: {0} \n\nFor more information try --help.
ParseArguments(#[from] utils::arg_parser::UtilsArgParserError),
/// When printing Snapshot Data format: {0}
Expand Down
2 changes: 1 addition & 1 deletion src/firecracker/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::time::Duration;

use event_manager::{EventOps, Events, MutEventSubscriber};
use timerfd::{ClockId, SetTimeFlags, TimerFd, TimerState};
use utils::epoll::EventSet;
use vmm::logger::{error, warn, IncMetric, METRICS};
use vmm_sys_util::epoll::EventSet;

/// Metrics reporting period.
pub(crate) const WRITE_METRICS_PERIOD_MS: u64 = 60000;
Expand Down
2 changes: 1 addition & 1 deletion src/firecracker/src/seccomp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ mod tests {
use std::sync::Arc;

use seccompiler::BpfThreadMap;
use utils::tempfile::TempFile;
use vmm_sys_util::tempfile::TempFile;

use super::*;

Expand Down
1 change: 1 addition & 0 deletions src/jailer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ log-instrument = { path = "../log-instrument", optional = true }
nix = { version = "0.29.0", default-features = false, features = ["dir"] }
regex = { version = "1.10.6", default-features = false, features = ["std"] }
thiserror = "1.0.63"
vmm-sys-util = "0.12.1"

utils = { path = "../utils" }

Expand Down
6 changes: 3 additions & 3 deletions src/jailer/src/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ pub mod test_util {
use std::io::Write;
use std::path::{Path, PathBuf};

use utils::rand;
use vmm_sys_util::rand;

#[derive(Debug)]
pub struct MockCgroupFs {
Expand Down Expand Up @@ -617,8 +617,8 @@ mod tests {
use std::io::{BufReader, Write};
use std::path::PathBuf;

use utils::tempdir::TempDir;
use utils::tempfile::TempFile;
use vmm_sys_util::tempdir::TempDir;
use vmm_sys_util::tempfile::TempFile;

use super::*;
use crate::cgroup::test_util::MockCgroupFs;
Expand Down
2 changes: 1 addition & 1 deletion src/jailer/src/chroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::ffi::CStr;
use std::path::Path;
use std::ptr::null;

use utils::syscall::SyscallReturnCode;
use vmm_sys_util::syscall::SyscallReturnCode;

use super::{to_cstring, JailerError};

Expand Down
16 changes: 8 additions & 8 deletions src/jailer/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
use std::{fmt, io};

use utils::arg_parser::UtilsArgParserError::MissingValue;
use utils::syscall::SyscallReturnCode;
use utils::time::{get_time_us, ClockType};
use utils::{arg_parser, validators};
use vmm_sys_util::syscall::SyscallReturnCode;

use crate::cgroup::{CgroupConfiguration, CgroupConfigurationBuilder};
use crate::chroot::chroot;
Expand Down Expand Up @@ -663,7 +664,7 @@
// Daemonize before exec, if so required (when the dev_null variable != None).
if let Some(dev_null) = dev_null {
// Meter CPU usage before fork()
self.jailer_cpu_time_us = utils::time::get_time_us(utils::time::ClockType::ProcessCpu);
self.jailer_cpu_time_us = get_time_us(ClockType::ProcessCpu);

Check warning on line 667 in src/jailer/src/env.rs

View check run for this annotation

Codecov / codecov/patch

src/jailer/src/env.rs#L667

Added line #L667 was not covered by tests

// We follow the double fork method to daemonize the jailer referring to
// https://0xjet.github.io/3OHA/2022/04/11/post.html
Expand All @@ -688,7 +689,7 @@
.map_err(JailerError::SetSid)?;

// Meter CPU usage before fork()
self.jailer_cpu_time_us += utils::time::get_time_us(utils::time::ClockType::ProcessCpu);
self.jailer_cpu_time_us += get_time_us(ClockType::ProcessCpu);

Check warning on line 692 in src/jailer/src/env.rs

View check run for this annotation

Codecov / codecov/patch

src/jailer/src/env.rs#L692

Added line #L692 was not covered by tests

// Daemons should not have controlling terminals.
// If a daemon has a controlling terminal, it can receive signals
Expand All @@ -714,8 +715,7 @@
}

// Compute jailer's total CPU time up to the current time.
self.jailer_cpu_time_us +=
utils::time::get_time_us(utils::time::ClockType::ProcessCpu) - self.start_time_cpu_us;
self.jailer_cpu_time_us += get_time_us(ClockType::ProcessCpu) - self.start_time_cpu_us;

Check warning on line 718 in src/jailer/src/env.rs

View check run for this annotation

Codecov / codecov/patch

src/jailer/src/env.rs#L718

Added line #L718 was not covered by tests
// Reset process start time.
self.start_time_cpu_us = 0;

Expand All @@ -736,9 +736,9 @@
use std::fs::create_dir_all;
use std::os::linux::fs::MetadataExt;

use utils::rand;
use utils::tempdir::TempDir;
use utils::tempfile::TempFile;
use vmm_sys_util::rand;
use vmm_sys_util::tempdir::TempDir;
use vmm_sys_util::tempfile::TempFile;

use super::*;
use crate::build_arg_parser;
Expand Down
9 changes: 5 additions & 4 deletions src/jailer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

use env::PROC_MOUNTS;
use utils::arg_parser::{ArgParser, Argument, UtilsArgParserError as ParsingError};
use utils::syscall::SyscallReturnCode;
use utils::time::{get_time_us, ClockType};
use utils::validators;
use vmm_sys_util::syscall::SyscallReturnCode;

use crate::env::Env;

Expand Down Expand Up @@ -334,8 +335,8 @@

Env::new(
arguments,
utils::time::get_time_us(utils::time::ClockType::Monotonic),
utils::time::get_time_us(utils::time::ClockType::ProcessCpu),
get_time_us(ClockType::Monotonic),
get_time_us(ClockType::ProcessCpu),

Check warning on line 339 in src/jailer/src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/jailer/src/main.rs#L338-L339

Added lines #L338 - L339 were not covered by tests
PROC_MOUNTS,
)
.and_then(|env| {
Expand All @@ -356,7 +357,7 @@
use std::fs::File;
use std::os::unix::io::IntoRawFd;

use utils::rand;
use vmm_sys_util::rand;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/jailer/src/resource_limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::fmt;
use std::fmt::{Display, Formatter};

use utils::syscall::SyscallReturnCode;
use vmm_sys_util::syscall::SyscallReturnCode;

use super::JailerError;

Expand Down
1 change: 1 addition & 0 deletions src/rebase-snap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ displaydoc = "0.2.5"
libc = "0.2.158"
log-instrument = { path = "../log-instrument", optional = true }
thiserror = "1.0.63"
vmm-sys-util = "0.12.1"

utils = { path = "../utils" }

Expand Down
7 changes: 3 additions & 4 deletions src/rebase-snap/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use std::io::{Seek, SeekFrom};
use std::os::unix::io::AsRawFd;

use utils::arg_parser::{ArgParser, Argument, Arguments, UtilsArgParserError as ArgError};
use utils::seek_hole::SeekHole;
use utils::u64_to_usize;
use vmm_sys_util::seek_hole::SeekHole;

const REBASE_SNAP_VERSION: &str = env!("CARGO_PKG_VERSION");
const BASE_FILE: &str = "base-file";
Expand Down Expand Up @@ -104,7 +103,7 @@ fn rebase(base_file: &mut File, diff_file: &mut File) -> Result<(), FileError> {
base_file.as_raw_fd(),
diff_file.as_raw_fd(),
(&mut cursor as *mut u64).cast::<i64>(),
u64_to_usize(block_end.saturating_sub(cursor)),
usize::try_from(block_end.saturating_sub(cursor)).unwrap(),
)
};
if num_transferred_bytes < 0 {
Expand Down Expand Up @@ -161,7 +160,7 @@ mod tests {
use std::io::{Seek, SeekFrom, Write};
use std::os::unix::fs::FileExt;

use utils::{rand, tempfile};
use vmm_sys_util::{rand, tempfile};

use super::*;

Expand Down
3 changes: 3 additions & 0 deletions src/seccompiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ thiserror = "1.0.63"

utils = { path = "../utils" }

[dev-dependencies]
vmm-sys-util = "0.12.1"

[features]
tracing = ["log-instrument", "utils/tracing"]

Expand Down
2 changes: 1 addition & 1 deletion src/seccompiler/src/seccompiler_bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ mod tests {
use std::path::PathBuf;

use bincode::Error as BincodeError;
use utils::tempfile::TempFile;
use vmm_sys_util::tempfile::TempFile;

use super::compiler::CompilationError as FilterFormatError;
use super::{
Expand Down
1 change: 1 addition & 0 deletions src/snapshot-editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ log-instrument = { path = "../log-instrument", optional = true }
semver = "1.0.23"
thiserror = "1.0.63"
vmm = { path = "../vmm" }
vmm-sys-util = "0.12.1"

[target.'cfg(target_arch = "aarch64")'.dependencies]
clap-num = "1.0.2"
Expand Down
Loading
Loading