3 unstable releases
0.2.0 | Jul 18, 2022 |
---|---|
0.1.1 | May 26, 2022 |
0.1.0 | May 26, 2022 |
#801 in Unix APIs
52KB
1K
SLoC
firec
firec
(pronounced "fyrek") is Rust client library to interact with Firecracker. It allows you to
create, manipulate, query and stop VMMs.
Examples
use std::path::Path;
use firec::{
Machine,
config::{Config, Drive, Jailer, Machine as MachineCfg, network::Interface}};
use tokio::time::{sleep, Duration};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let kernel_args = "console=ttyS0 reboot=k panic=1 pci=off random.trust_cpu=on";
let iface = Interface::new("eth0", "tap0");
let config = Config::builder(None, Path::new("debian-vmlinux"))
.jailer_cfg()
.chroot_base_dir(Path::new("/srv"))
.exec_file(Path::new("/usr/bin/firecracker"))
.build()
.kernel_args(kernel_args)
.machine_cfg()
.vcpu_count(2)
.mem_size_mib(1024)
.build()
.add_drive("root", Path::new("debian.ext4"))
.is_root_device(true)
.build()
.add_network_interface(iface)
.socket_path(Path::new("/tmp/firecracker.socket"))
.build();
let mut machine = Machine::create(config).await?;
machine.start().await?;
// Let the machine run for a bit before we KILL IT :)
sleep(Duration::from_secs(15)).await;
machine.force_shutdown().await?;
Ok(())
}
status
Currently heavily in development and therefore expect a lot of API breakage for a while.
Having said that, we'll be following Cargo's SemVer rules so breaking changes will be released in new minor releases. However, we will only support the latest release.
Dependencies
~8–21MB
~247K SLoC