Skip to main content

VmManager

Struct VmManager 

Source
pub struct VmManager { /* private fields */ }
Expand description

Coordinates definitions, runtime state, QEMU, and QMP.

Implementations§

Source§

impl VmManager

Source

pub fn new(paths: AppPaths) -> Result<Self>

Construct a manager and secure all root directories.

Source

pub fn discover() -> Result<Self>

Discover roots from the XDG environment.

Source

pub const fn paths(&self) -> &AppPaths

Access resolved application roots.

Source

pub fn create(&self, options: &CreateOptions) -> Result<PathBuf>

Create a VM definition and an empty qcow2 system disk.

Source

pub fn clone_vm( &self, source_name: &str, destination_name: &str, ) -> Result<PathBuf>

Create an independent full-copy clone of a stopped VM.

Source

pub fn media_attach(&self, name: &str, media: &Path) -> Result<PathBuf>

Attach read-only installation media to a stopped VM.

Source

pub fn media_detach(&self, name: &str) -> Result<Option<PathBuf>>

Detach installation media from a stopped VM.

Source

pub fn disk_grow(&self, name: &str, amount: &str) -> Result<()>

Grow a stopped VM’s system disk by a positive amount such as 20G.

Source

pub fn disk_info(&self, name: &str) -> Result<Value>

Return qemu-img JSON information for a stopped VM’s system disk.

Source

pub fn port_add(&self, name: &str, forward: PortForward) -> Result<()>

Add a validated user-network port forward to a stopped VM.

Source

pub fn port_remove( &self, name: &str, protocol: NetworkProtocol, host_address: Ipv4Addr, host_port: u16, ) -> Result<PortForward>

Remove a user-network port forward from a stopped VM.

Source

pub fn usb_add(&self, name: &str, device: UsbHostDevice) -> Result<()>

Assign an exact host USB bus and address to a stopped VM.

Source

pub fn usb_remove( &self, name: &str, device: UsbHostDevice, ) -> Result<UsbHostDevice>

Remove an exact host USB bus and address from a stopped VM.

Source

pub fn share_add( &self, name: &str, tag: String, path: &Path, read_only: bool, ) -> Result<DirectoryShare>

Add a canonical host directory share to a stopped VM.

Source

pub fn share_remove(&self, name: &str, tag: &str) -> Result<DirectoryShare>

Remove a host directory share from a stopped VM by mount tag.

Source

pub fn configure( &self, name: &str, options: &ConfigureOptions, ) -> Result<VmConfig>

Atomically update compute, guest, and host integration settings for a stopped VM.

Source

pub fn backup_create( &self, name: &str, destination: &Path, ) -> Result<BackupManifest>

Create a portable, integrity-checked backup directory for a stopped VM.

Source

pub fn backup_verify(&self, root: &Path) -> Result<BackupManifest>

Verify hashes, schema, and qcow2 structure for a portable backup.

Source

pub fn backup_restore( &self, root: &Path, destination_name: &str, ) -> Result<PathBuf>

Restore a verified backup under a new VM name and independent identity.

Source

pub fn delete_vm(&self, name: &str) -> Result<DeleteReport>

Delete a stopped VM definition and only its known managed artifacts.

Source

pub fn config(&self, name: &str) -> Result<VmConfig>

Load a named definition.

Source

pub fn command(&self, name: &str) -> Result<CommandSpec>

Build the exact QEMU command without launching it.

Source

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

Launch QEMU as a daemon and record its private control endpoints.

Source

pub fn status(&self, name: &str) -> Result<VmStatus>

Query QMP when possible and distinguish stopped from stale state.

Source

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

Request ACPI power-off and escalate to QMP quit after the timeout.

Source

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

Stop QEMU immediately through QMP.

Source

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

Pause all virtual CPUs through QMP.

Source

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

Resume all virtual CPUs through QMP.

Source

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

Reset the virtual machine through QMP.

Source

pub fn balloon_status(&self, name: &str) -> Result<BalloonStatus>

Return the running VM’s guest-reported balloon state.

Source

pub fn balloon_set(&self, name: &str, memory_mib: u64) -> Result<()>

Request a bounded runtime memory target for a running VM.

Source

pub fn balloon_restore(&self, name: &str) -> Result<u64>

Restore a running VM’s balloon target to its configured boot memory.

Source

pub fn screenshot(&self, name: &str, destination: &Path) -> Result<u64>

Capture a running VM’s current framebuffer as a new bounded PPM file.

Source

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

Verify that the QEMU Guest Agent inside a running VM responds.

Source

pub fn agent_info(&self, name: &str) -> Result<Value>

Return the running guest agent’s version and supported command list.

Source

pub fn agent_shutdown(&self, name: &str, mode: ShutdownMode) -> Result<()>

Ask the guest operating system to shut down through its guest agent.

Source

pub fn snapshot_list(&self, name: &str) -> Result<String>

List internal qcow2 snapshots for a stopped VM.

Source

pub fn snapshot_create(&self, name: &str, snapshot: &str) -> Result<()>

Create an internal qcow2 snapshot for a stopped VM.

Source

pub fn snapshot_revert(&self, name: &str, snapshot: &str) -> Result<()>

Revert a stopped VM to an internal qcow2 snapshot.

Source

pub fn snapshot_delete(&self, name: &str, snapshot: &str) -> Result<()>

Delete an internal qcow2 snapshot from a stopped VM.

Source

pub fn generation_id(&self, name: &str) -> Result<Option<Uuid>>

Return the stable VM Generation ID exposed to the guest.

Source

pub fn regenerate_generation_id(&self, name: &str) -> Result<Uuid>

Replace a stopped VM’s generation ID after an external duplication event.

Source

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

Load current runtime state for the console.

Source

pub fn list(&self) -> Result<Vec<String>>

Return definition names in deterministic order.

Auto Trait Implementations§

§

impl Forget for VmManager

§

impl Freeze for VmManager
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for VmManager

§

impl RefUnwindSafe for VmManager

§

impl Send for VmManager
where RawVecInner: Send,

§

impl Sync for VmManager
where RawVecInner: Sync,

§

impl Unpin for VmManager
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for VmManager

§

impl UnwindSafe for VmManager
where RawVecInner: UnwindSafe,

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, 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.