Skip to main content

VmManager

Struct VmManager 

Source
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

Source

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.

Source

pub fn with_driver( driver: Box<dyn VmDriver>, base_dir: PathBuf, ) -> Result<Self, VmError>

Create a VmManager with a specific driver (useful for testing).

Source

pub fn base_dir(&self) -> &Path

Base directory for all VM data.

Source

pub fn vm_dir(&self, name: &str) -> PathBuf

Directory for a specific VM’s data (logs, disks, seed ISOs).

Source

pub fn start(&self, config: &VmConfig) -> Result<VmHandle, VmError>

Boot a VM. Creates the VM directory and delegates to the driver.

Source

pub fn stop(&self, name: &str) -> Result<(), VmError>

Stop a VM gracefully.

Source

pub fn kill(&self, name: &str) -> Result<(), VmError>

Force-kill a VM.

Source

pub fn stop_by_handle(&self, handle: &VmHandle) -> Result<(), VmError>

Stop a VM using a pre-built handle (e.g. restored from persisted metadata).

Source

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).

Source

pub fn pause(&self, name: &str) -> Result<(), VmError>

Pause a running VM.

Source

pub fn resume(&self, name: &str) -> Result<(), VmError>

Resume a paused VM.

Source

pub fn state(&self, name: &str) -> Result<VmState, VmError>

Query current state of a VM.

Source

pub fn get_ip(&self, name: &str) -> Result<Option<String>, VmError>

Get the IP address of a ready VM.

Source

pub fn list(&self) -> Result<Vec<VmHandle>, VmError>

List all tracked VMs.

Source

pub fn wait_all_ready(&self, timeout_secs: u64) -> Result<(), VmError>

Wait for all VMs to emit the readiness marker within the timeout.

Source

pub fn clone_disk(base: &Path, target: &Path) -> Result<(), VmError>

Create a disk image as a CoW clone of a base image.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more