Add with_data_dir constructor to RouterHypervisor

Allows callers to specify a custom data directory for VM work files
(overlays, sockets, console logs) instead of using the default
~/.local/share/vmctl/vms/ path. Needed for container deployments
where the work dir is a mounted volume.
This commit is contained in:
Till Wegmueller 2026-04-07 17:44:53 +02:00
parent 633e76bad1
commit 4c73599379

View file

@ -30,11 +30,21 @@ impl RouterHypervisor {
/// On illumos, creates a PropolisBackend with the given ZFS pool.
#[allow(unused_variables)]
pub fn new(bridge: Option<String>, zfs_pool: Option<String>) -> Self {
Self::with_data_dir(bridge, zfs_pool, None)
}
/// Build a router with a custom data directory for VM work files.
#[allow(unused_variables)]
pub fn with_data_dir(
bridge: Option<String>,
zfs_pool: Option<String>,
data_dir: Option<std::path::PathBuf>,
) -> Self {
#[cfg(target_os = "linux")]
{
RouterHypervisor {
noop: noop::NoopBackend,
qemu: Some(qemu::QemuBackend::new(None, None, bridge)),
qemu: Some(qemu::QemuBackend::new(None, data_dir, bridge)),
}
}
#[cfg(target_os = "illumos")]