pub struct VmManager { /* private fields */ }Expand description
Manages all VMs on this node. Auto-selects the correct hypervisor driver.
Thread-safe: uses RwLock for concurrent access to VM state.
Implementations§
Source§impl VmManager
impl VmManager
Sourcepub fn new(base_dir: PathBuf) -> Result<Self, VmError>
pub fn new(base_dir: PathBuf) -> Result<Self, VmError>
Create a new VmManager with auto-detected driver.
base_dir is the root directory for VM data (disks, logs, configs).
Typically ~/.vm-rs/vms/ for development or /var/lib/vm-rs/ for production.
Sourcepub fn with_driver(
driver: Box<dyn VmDriver>,
base_dir: PathBuf,
) -> Result<Self, VmError>
pub fn with_driver( driver: Box<dyn VmDriver>, base_dir: PathBuf, ) -> Result<Self, VmError>
Create a VmManager with a specific driver (useful for testing).
Sourcepub fn vm_dir(&self, name: &str) -> PathBuf
pub fn vm_dir(&self, name: &str) -> PathBuf
Directory for a specific VM’s data (logs, disks, seed ISOs).
Sourcepub fn start(&self, config: &VmConfig) -> Result<VmHandle, VmError>
pub fn start(&self, config: &VmConfig) -> Result<VmHandle, VmError>
Boot a VM. Creates the VM directory and delegates to the driver.
Sourcepub fn stop_by_handle(&self, handle: &VmHandle) -> Result<(), VmError>
pub fn stop_by_handle(&self, handle: &VmHandle) -> Result<(), VmError>
Stop a VM using a pre-built handle (e.g. restored from persisted metadata).
Sourcepub fn kill_by_handle(&self, handle: &VmHandle) -> Result<(), VmError>
pub fn kill_by_handle(&self, handle: &VmHandle) -> Result<(), VmError>
Force-kill a VM using a pre-built handle (e.g. restored from persisted metadata).
Sourcepub fn get_ip(&self, name: &str) -> Result<Option<String>, VmError>
pub fn get_ip(&self, name: &str) -> Result<Option<String>, VmError>
Get the IP address of a ready VM.
Auto Trait Implementations§
impl !Freeze for VmManager
impl !RefUnwindSafe for VmManager
impl Send for VmManager
impl Sync for VmManager
impl Unpin for VmManager
impl UnsafeUnpin for VmManager
impl !UnwindSafe for VmManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more