Skip to content

Commit

Permalink
refactor: remove reexport of vmm-sys-util
Browse files Browse the repository at this point in the history
It is better not to reexport `vmm-sys-util` as it
entangles the code. Additionally, the original
reason of having one place to update this dependency
does not hold any more as now we rely on dependabot
for updates, so specifying dependency in multiple crates
is not an issue.

Signed-off-by: Egor Lazarchuk <[email protected]>
  • Loading branch information
ShadowCurse committed Sep 16, 2024
1 parent 4d1d994 commit eb26211
Show file tree
Hide file tree
Showing 88 changed files with 199 additions and 184 deletions.
5 changes: 5 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 vmm::utils::tempdir::TempDir;
use vmm::utils::tempfile::TempFile;
use vmm_sys_util::tempdir::TempDir;
use vmm_sys_util::tempfile::TempFile;

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions src/firecracker/src/api_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +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 @@ -204,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
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
8 changes: 4 additions & 4 deletions src/jailer/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use std::process::{exit, id, Command, Stdio};
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 @@ -736,9 +736,9 @@ mod tests {
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
4 changes: 2 additions & 2 deletions src/jailer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use std::{env as p_env, fs, io};

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 @@ -357,7 +357,7 @@ mod tests {
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
4 changes: 2 additions & 2 deletions src/rebase-snap/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +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 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 @@ -160,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
4 changes: 2 additions & 2 deletions src/snapshot-editor/src/edit_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::os::fd::AsRawFd;
use std::path::PathBuf;

use clap::Subcommand;
use fc_utils::seek_hole::SeekHole;
use vmm::utils::u64_to_usize;
use vmm_sys_util::seek_hole::SeekHole;

#[derive(Debug, thiserror::Error, displaydoc::Display)]
pub enum EditMemoryError {
Expand Down Expand Up @@ -108,7 +108,7 @@ mod tests {
use std::io::{Seek, SeekFrom, Write};
use std::os::unix::fs::FileExt;

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

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ log-instrument = { path = "../log-instrument", optional = true }
serde = { version = "1.0.210", features = ["derive"] }
thiserror = "1.0.63"
vm-memory = { version = "0.14.1", features = ["backend-mmap", "backend-bitmap"] }
vmm-sys-util = { version = "0.12.1", features = ["with-serde"] }
vmm-sys-util = "0.12.1"

[dev-dependencies]
serde_json = "1.0.128"
Expand Down
10 changes: 0 additions & 10 deletions src/utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

// We use `utils` as a wrapper over `vmm_sys_util` to control the latter
// dependency easier (i.e. update only in one place `vmm_sys_util` version).
// More specifically, we are re-exporting modules from `vmm_sys_util` as part
// of the `utils` crate.
pub use vmm_sys_util::ioctl::ioctl_expr;
pub use vmm_sys_util::{
epoll, errno, eventfd, fam, generate_fam_struct_impl, ioctl, ioctl_ioc_nr, ioctl_iow_nr, rand,
seek_hole, sock_ctrl_msg, syscall, tempdir, tempfile, terminal,
};

pub mod arg_parser;
pub mod time;
pub mod validators;
2 changes: 1 addition & 1 deletion src/vmm/src/arch/aarch64/vcpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub enum VcpuError {
/// Failed to set multiprocessor state: {0}
SetMp(kvm_ioctls::Error),
/// Failed FamStructWrapper operation: {0}
Fam(crate::utils::fam::Error),
Fam(vmm_sys_util::fam::Error),
/// {0}
GetMidrEl1(String),
}
Expand Down
2 changes: 1 addition & 1 deletion src/vmm/src/arch/x86_64/interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mod tests {
#[test]
fn test_apic_delivery_mode() {
let mut v: Vec<u32> = (0..20)
.map(|_| crate::utils::rand::xor_pseudo_rng_u32())
.map(|_| vmm_sys_util::rand::xor_pseudo_rng_u32())
.collect();

v.iter_mut()
Expand Down
2 changes: 1 addition & 1 deletion src/vmm/src/arch/x86_64/msr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::cpu_config::x86_64::cpuid::common::GetCpuidError;
/// MSR related errors.
pub enum MsrError {
/// Failed to create `vmm_sys_util::fam::FamStructWrapper` for MSRs
Fam(#[from] crate::utils::fam::Error),
Fam(#[from] vmm_sys_util::fam::Error),
/// Failed to get MSR index list: {0}
GetMsrIndexList(kvm_ioctls::Error),
/// Invalid CPU vendor: {0}
Expand Down
Loading

0 comments on commit eb26211

Please sign in to comment.