| Crates.io | herolib-virt |
| lib.rs | herolib-virt |
| version | 0.3.13 |
| created_at | 2025-12-26 21:15:04.218001+00 |
| updated_at | 2026-01-24 05:26:18.225429+00 |
| description | Virtualization and container management for herolib (buildah, nerdctl, kubernetes) |
| homepage | |
| repository | https://github.com/herolib/herolib_rust |
| max_upload_size | |
| id | 2006276 |
| size | 2,328,060 |
Virtualization and containerization tools for building, managing, and deploying containers, virtual machines, and filesystem layers.
Add to your Cargo.toml:
[dependencies]
herolib-virt = { path = "../virt", features = ["rhai"] }
Or install the library:
./install.sh
./build.sh
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")?;
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);
Build OCI/Docker container images with a fluent builder API.
Builder: Main builder type for creating container imagesBuildahError: Error type for Buildah operationsSee Rhai examples under rhaiexamples/buildah/ for detailed examples.
Manage containers with containerd/nerdctl.
Container: Container representationContainerStatus: Container status enumerationNerdctlError: Error type for Nerdctl operationsSee Rhai examples under rhaiexamples/nerdctl/ for detailed examples.
Mount and manage remote filesystems and pack/unpack filesystem layers.
RfsBuilder: Builder for filesystem operationsMount: Mount point representationMountType: Filesystem type enumerationRfsError: Error type for RFS operationsSee Rhai examples under rhaiexamples/rfs/ for detailed examples.
Create and manage QCOW2 disk images with snapshot support.
Qcow2Manager: Manager for QCOW2 operationsQcow2Error: Error type for QCOW2 operationsSee Rhai examples under rhaiexamples/qcow2/ for detailed examples.
Manage virtual machines using Cloud Hypervisor.
CloudHvManager: Manager for Cloud Hypervisor operationsCloudHvError: Error type for Cloud Hypervisor operationsSee Rhai examples under rhaiexamples/cloudhv/ for detailed 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 examplesrhai (default): Enable Rhai scripting supportfull: Enable all featuresCore dependencies:
tokio - Async runtimeserde - Serialization frameworkanyhow - Error handlingthiserror - Error typesOptional dependencies (with rhai feature):
rhai - Scripting language supportGenerate documentation:
cargo doc --no-deps --open
Apache 2.0