14 releases
Uses new Rust 2024
| 0.3.13 | Jan 24, 2026 |
|---|---|
| 0.3.12 | Jan 22, 2026 |
| 0.3.4 | Dec 31, 2025 |
| 0.2.1 | Dec 27, 2025 |
#931 in Filesystem
Used in 4 crates
(3 directly)
780KB
16K
SLoC
herolib-virt
Virtualization and containerization tools for building, managing, and deploying containers, virtual machines, and filesystem layers.
Features
- Buildah: OCI/Docker image building with a fluent builder pattern API
- Nerdctl: Container lifecycle management with containerd
- RFS: Remote filesystem mounting and layer management
- QCOW2: Disk image creation and management with snapshot support
- Cloud Hypervisor: Virtual machine creation and lifecycle management
- Cross-Platform: Works across Windows, macOS, and Linux
- Rhai Integration: Full support for Rhai scripting language (optional feature)
- Error Handling: Comprehensive error types and handling
Installation
Add to your Cargo.toml:
[dependencies]
herolib-virt = { path = "../virt", features = ["rhai"] }
Or install the library:
./install.sh
Building
./build.sh
Usage
Rust API
use herolib_virt::buildah;
// Create a container builder
let mut builder = buildah::Builder::new("mybuilder", "alpine:latest")?;
builder.run("apk add curl")?;
let image = builder.commit("myimage")?;
Rhai Scripting
When the rhai feature is enabled, you can use the virt module in Rhai scripts:
// Create a container using Buildah
let builder = bah("mybuilder", "alpine:latest");
builder.run("apk add curl");
builder.commit("myimage");
// Create a disk image
qcow2_create("/tmp/disk.qcow2", 20);
// Create a VM
let vm_spec = #{
id: "test-vm",
firmware_path: "/usr/share/OVMF/CLOUDHV.fd",
disk_path: "/tmp/disk.qcow2",
vcpus: 2,
memory_mb: 2048
};
let vm = cloudhv_vm_create(vm_spec);
Modules
Buildah (Container Image Building)
Build OCI/Docker container images with a fluent builder API.
Key Types
Builder: Main builder type for creating container imagesBuildahError: Error type for Buildah operations
Examples
See Rhai examples under rhaiexamples/buildah/ for detailed examples.
Nerdctl (Container Management)
Manage containers with containerd/nerdctl.
Key Types
Container: Container representationContainerStatus: Container status enumerationNerdctlError: Error type for Nerdctl operations
Examples
See Rhai examples under rhaiexamples/nerdctl/ for detailed examples.
RFS (Remote Filesystem)
Mount and manage remote filesystems and pack/unpack filesystem layers.
Key Types
RfsBuilder: Builder for filesystem operationsMount: Mount point representationMountType: Filesystem type enumerationRfsError: Error type for RFS operations
Examples
See Rhai examples under rhaiexamples/rfs/ for detailed examples.
QCOW2 (Disk Image Management)
Create and manage QCOW2 disk images with snapshot support.
Key Types
Qcow2Manager: Manager for QCOW2 operationsQcow2Error: Error type for QCOW2 operations
Examples
See Rhai examples under rhaiexamples/qcow2/ for detailed examples.
Cloud Hypervisor (VM Management)
Manage virtual machines using Cloud Hypervisor.
Key Types
CloudHvManager: Manager for Cloud Hypervisor operationsCloudHvError: Error type for Cloud Hypervisor operations
Examples
See Rhai examples under rhaiexamples/cloudhv/ for detailed examples.
Rhai Examples
The rhaiexamples/ directory contains comprehensive examples for all modules:
buildah/- Container image building examplesnerdctl/- Container management examplesrfs/- Remote filesystem examplesqcow2/- QCOW2 disk image examplescloudhv/- Cloud Hypervisor VM exampleskubernetes/- Kubernetes cluster management examples
Features
rhai(default): Enable Rhai scripting supportfull: Enable all features
Platform Support
- Linux (primary)
- macOS
- Windows
Dependencies
Core dependencies:
tokio- Async runtimeserde- Serialization frameworkanyhow- Error handlingthiserror- Error types
Optional dependencies (with rhai feature):
rhai- Scripting language support
Documentation
Generate documentation:
cargo doc --no-deps --open
License
Apache 2.0
Repository
Dependencies
~45–105MB
~2M SLoC