Skip to content

Commit 6791d55

Browse files
Ashwin Ginoriazulinx86
authored andcommitted
Fix: move snapshot into module under vmm
Moved `snapshot` into module under `vmm`. Many of these crates could be modules and the number of crates in our workspace greatly reduced. This reduces the binary size and makes the workspace more ergonomic. Signed-off-by: Ashwin Ginoria <aginoria@amazon.com>
1 parent 6414a07 commit 6791d55

File tree

28 files changed

+44
-88
lines changed

28 files changed

+44
-88
lines changed

Cargo.lock

Lines changed: 1 addition & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/firecracker/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ thiserror = "1.0.53"
2525
timerfd = "1.5.0"
2626

2727
seccompiler = { path = "../seccompiler" }
28-
snapshot = { path = "../snapshot" }
2928
utils = { path = "../utils" }
3029
vmm = { path = "../vmm" }
3130

@@ -45,7 +44,7 @@ serde = { version = "1.0.193" }
4544
serde_json = "1.0.109"
4645

4746
[features]
48-
tracing = ["log-instrument", "seccompiler/tracing", "snapshot/tracing", "utils/tracing", "vmm/tracing"]
47+
tracing = ["log-instrument", "seccompiler/tracing", "utils/tracing", "vmm/tracing"]
4948

5049
[[example]]
5150
name = "uffd_malicious_handler"

src/firecracker/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use api_server_adapter::ApiServerError;
1717
use event_manager::SubscriberOps;
1818
use seccomp::FilterError;
1919
use seccompiler::BpfThreadMap;
20-
use snapshot::{Error as SnapshotError, Snapshot};
2120
use utils::arg_parser::{ArgParser, Argument};
2221
use utils::terminal::Terminal;
2322
use utils::validators::validate_instance_id;
@@ -28,6 +27,7 @@ use vmm::logger::{
2827
use vmm::persist::SNAPSHOT_VERSION;
2928
use vmm::resources::VmResources;
3029
use vmm::signal_handler::register_signal_handlers;
30+
use vmm::snapshot::{Error as SnapshotError, Snapshot};
3131
use vmm::vmm_config::instance_info::{InstanceInfo, VmState};
3232
use vmm::vmm_config::metrics::{init_metrics, MetricsConfig, MetricsConfigError};
3333
use vmm::{EventManager, FcExitCode, HTTP_MAX_PAYLOAD_SIZE};

src/snapshot-editor/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ displaydoc = "0.2.4"
1515
libc = "0.2.151"
1616
log-instrument = { path = "../log-instrument", optional = true }
1717
semver = "1.0.20"
18-
snapshot = { path = "../snapshot" }
1918
thiserror = "1.0.53"
2019
vmm = { path = "../vmm" }
2120

src/snapshot-editor/src/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::path::PathBuf;
66

77
use fc_utils::u64_to_usize;
88
use semver::Version;
9-
use snapshot::Snapshot;
109
use vmm::persist::MicrovmState;
10+
use vmm::snapshot::Snapshot;
1111

1212
// Some errors are only used in aarch64 code
1313
#[allow(unused)]
@@ -18,11 +18,11 @@ pub enum UtilsError {
1818
/// Can not retrieve metadata for snapshot file: {0}
1919
VmStateFileMeta(std::io::Error),
2020
/// Can not load snapshot: {0}
21-
VmStateLoad(snapshot::Error),
21+
VmStateLoad(vmm::snapshot::Error),
2222
/// Can not open output file: {0}
2323
OutputFileOpen(std::io::Error),
2424
/// Can not save snapshot: {0}
25-
VmStateSave(snapshot::Error),
25+
VmStateSave(vmm::snapshot::Error),
2626
}
2727

2828
#[allow(unused)]

src/snapshot/Cargo.toml

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/vmm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ base64 = "0.21.0"
3636
bincode = "1.2.1"
3737
micro_http = { git = "https://github.com/firecracker-microvm/micro-http" }
3838
log-instrument = { path = "../log-instrument", optional = true }
39+
crc64 = "2.0.0"
3940

4041
seccompiler = { path = "../seccompiler" }
41-
snapshot = { path = "../snapshot"}
4242
utils = { path = "../utils" }
4343
smallvec = "1.11.2"
4444

src/vmm/src/arch/aarch64/regs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,8 @@ reg_data_array!([u8; 256], 256);
478478

479479
#[cfg(test)]
480480
mod tests {
481-
use snapshot::Snapshot;
482-
483481
use super::*;
482+
use crate::snapshot::Snapshot;
484483

485484
#[test]
486485
fn test_reg_size() {

src/vmm/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use linux_loader::loader::elf::Elf as Loader;
1818
use linux_loader::loader::pe::PE as Loader;
1919
use linux_loader::loader::KernelLoader;
2020
use seccompiler::BpfThreadMap;
21-
use snapshot::Persist;
2221
use userfaultfd::Uffd;
2322
use utils::eventfd::EventFd;
2423
use utils::time::TimestampUs;
@@ -53,6 +52,7 @@ use crate::devices::BusDevice;
5352
use crate::logger::{debug, error};
5453
use crate::persist::{MicrovmState, MicrovmStateError};
5554
use crate::resources::VmResources;
55+
use crate::snapshot::Persist;
5656
use crate::vmm_config::boot_source::BootConfig;
5757
use crate::vmm_config::drive::BlockDeviceType;
5858
use crate::vmm_config::instance_info::InstanceInfo;

src/vmm/src/device_manager/persist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use event_manager::{MutEventSubscriber, SubscriberOps};
1010
use kvm_ioctls::VmFd;
1111
use log::{error, warn};
1212
use serde::{Deserialize, Serialize};
13-
use snapshot::Persist;
1413
use vm_allocator::AllocPolicy;
1514

1615
use super::mmio::*;
@@ -45,6 +44,7 @@ use crate::devices::virtio::vsock::{
4544
use crate::devices::virtio::{TYPE_BALLOON, TYPE_BLOCK, TYPE_NET, TYPE_RNG};
4645
use crate::mmds::data_store::MmdsVersion;
4746
use crate::resources::VmResources;
47+
use crate::snapshot::Persist;
4848
use crate::vmm_config::mmds::MmdsConfigError;
4949
use crate::vstate::memory::GuestMemoryMmap;
5050
use crate::EventManager;
@@ -646,13 +646,13 @@ impl<'a> Persist<'a> for MMIODeviceManager {
646646

647647
#[cfg(test)]
648648
mod tests {
649-
use snapshot::Snapshot;
650649
use utils::tempfile::TempFile;
651650

652651
use super::*;
653652
use crate::builder::tests::*;
654653
use crate::devices::virtio::block_common::CacheType;
655654
use crate::resources::VmmConfig;
655+
use crate::snapshot::Snapshot;
656656
use crate::vmm_config::balloon::BalloonDeviceConfig;
657657
use crate::vmm_config::entropy::EntropyDeviceConfig;
658658
use crate::vmm_config::net::NetworkInterfaceConfig;

0 commit comments

Comments
 (0)