forked from smol-machines/smolvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
119 lines (111 loc) · 4.17 KB
/
Copy pathlib.rs
File metadata and controls
119 lines (111 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//! smolvm - OCI-native microVM runtime
//!
//! smolvm is a library and CLI for running microVMs with strong isolation
//! and OCI container compatibility.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────┐
//! │ smolvm CLI / Library │
//! ├─────────────────────────────────────────────────┤
//! │ VM abstraction (VmBackend, VmHandle) │
//! ├─────────────────────────────────────────────────┤
//! │ libkrun (Hypervisor.framework / KVM) │
//! ├─────────────────────────────────────────────────┤
//! │ libkrunfw (embedded Linux kernel) │
//! └─────────────────────────────────────────────────┘
//! ```
//!
//! # Example
//!
//! ```no_run
//! use smolvm::{VmConfig, RootfsSource, default_backend};
//!
//! // Create a VM configuration
//! let config = VmConfig::builder(RootfsSource::path("/path/to/rootfs"))
//! .memory(1024) // 1 GB
//! .cpus(2)
//! .command(vec!["/bin/sh".into()])
//! .build();
//!
//! // Get the default backend for this platform
//! let backend = default_backend().unwrap();
//!
//! // Create and run the VM
//! let mut vm = backend.create(config).unwrap();
//! let exit = vm.wait().unwrap();
//!
//! println!("VM exited with: {}", exit);
//! ```
//!
//! # Features
//!
//! - VM creation and lifecycle management
//! - Rootfs from path or OCI images
//! - Host directory mounts via virtiofs
//! - Network egress via NAT
//! - vsock control channel
//! - Persistent overlay disks
//! - `exec` into running VMs
//!
//! # Platform Support
//!
//! | Platform | Backend | Status |
//! |----------|---------|--------|
//! | macOS (Apple Silicon) | libkrun + Hypervisor.framework | ✅ |
//! | macOS (Intel) | libkrun + Hypervisor.framework | ✅ |
//! | Linux (arm64) | libkrun + KVM | ✅ |
//! | Linux (x86_64) | libkrun + KVM | ✅ |
#![warn(missing_docs)]
#![warn(clippy::all)]
pub mod agent;
pub mod api;
pub mod config;
/// Canonical shared data models and constants used across adapters.
pub mod data;
pub mod db;
mod disk_utils;
pub mod dns_filter;
pub mod dns_filter_listener;
/// Language-neutral embedded runtime support shared by SDK adapters.
pub mod embedded;
pub mod log_rotation;
pub mod network;
pub mod platform;
pub mod process;
pub mod registry;
pub mod smolfile;
pub mod storage;
pub mod util;
pub mod vm;
/// Compatibility re-exports for smolvm error types.
///
/// The canonical error model lives under [`crate::data::error`]. This module
/// remains as a stable facade for existing `crate::error` and `smolvm::error`
/// imports.
pub mod error {
pub use crate::data::error::{AgentErrorKind, Error, Result};
}
// ============================================================================
// Default Command Constants
// ============================================================================
/// Default interactive command — spawns a shell.
pub const DEFAULT_SHELL_CMD: &str = "/bin/sh";
/// Default idle command — keeps a container alive without doing work.
pub const DEFAULT_IDLE_CMD: &[&str] = &["sleep", "infinity"];
// Re-export main types for convenience
pub use agent::{AgentClient, AgentManager};
pub use api::ApiDoc;
pub use config::{RecordState, RestartConfig, RestartPolicy, SmolvmConfig, VmRecord};
pub use data::resources::VmResources;
pub use data::storage::HostMount;
pub use db::SmolvmDb;
pub use error::{Error, Result};
pub use process::ChildProcess;
pub use registry::{RegistryAuth, RegistryConfig};
pub use vm::config::{NetworkPolicy, RootfsSource, Timeouts, VmConfig, VmId};
pub use vm::state::{ExitReason, VmState};
pub use vm::{default_backend, VmBackend, VmHandle};
/// Library version.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");