pub struct VmManager { /* private fields */ }Expand description
Coordinates definitions, runtime state, QEMU, and QMP.
Implementations§
Source§impl VmManager
impl VmManager
Sourcepub fn new(paths: AppPaths) -> Result<Self>
pub fn new(paths: AppPaths) -> Result<Self>
Construct a manager and secure all root directories.
Sourcepub fn create(&self, options: &CreateOptions) -> Result<PathBuf>
pub fn create(&self, options: &CreateOptions) -> Result<PathBuf>
Create a VM definition and an empty qcow2 system disk.
Sourcepub fn clone_vm(
&self,
source_name: &str,
destination_name: &str,
) -> Result<PathBuf>
pub fn clone_vm( &self, source_name: &str, destination_name: &str, ) -> Result<PathBuf>
Create an independent full-copy clone of a stopped VM.
Sourcepub fn media_attach(&self, name: &str, media: &Path) -> Result<PathBuf>
pub fn media_attach(&self, name: &str, media: &Path) -> Result<PathBuf>
Attach read-only installation media to a stopped VM.
Sourcepub fn media_detach(&self, name: &str) -> Result<Option<PathBuf>>
pub fn media_detach(&self, name: &str) -> Result<Option<PathBuf>>
Detach installation media from a stopped VM.
Sourcepub fn disk_grow(&self, name: &str, amount: &str) -> Result<()>
pub fn disk_grow(&self, name: &str, amount: &str) -> Result<()>
Grow a stopped VM’s system disk by a positive amount such as 20G.
Sourcepub fn disk_info(&self, name: &str) -> Result<Value>
pub fn disk_info(&self, name: &str) -> Result<Value>
Return qemu-img JSON information for a stopped VM’s system disk.
Sourcepub fn port_add(&self, name: &str, forward: PortForward) -> Result<()>
pub fn port_add(&self, name: &str, forward: PortForward) -> Result<()>
Add a validated user-network port forward to a stopped VM.
Sourcepub fn port_remove(
&self,
name: &str,
protocol: NetworkProtocol,
host_address: Ipv4Addr,
host_port: u16,
) -> Result<PortForward>
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.
Sourcepub fn usb_add(&self, name: &str, device: UsbHostDevice) -> Result<()>
pub fn usb_add(&self, name: &str, device: UsbHostDevice) -> Result<()>
Assign an exact host USB bus and address to a stopped VM.
Sourcepub fn usb_remove(
&self,
name: &str,
device: UsbHostDevice,
) -> Result<UsbHostDevice>
pub fn usb_remove( &self, name: &str, device: UsbHostDevice, ) -> Result<UsbHostDevice>
Remove an exact host USB bus and address from a stopped VM.
Add a canonical host directory share to a stopped VM.
Remove a host directory share from a stopped VM by mount tag.
Sourcepub fn configure(
&self,
name: &str,
options: &ConfigureOptions,
) -> Result<VmConfig>
pub fn configure( &self, name: &str, options: &ConfigureOptions, ) -> Result<VmConfig>
Atomically update compute, guest, and host integration settings for a stopped VM.
Sourcepub fn backup_create(
&self,
name: &str,
destination: &Path,
) -> Result<BackupManifest>
pub fn backup_create( &self, name: &str, destination: &Path, ) -> Result<BackupManifest>
Create a portable, integrity-checked backup directory for a stopped VM.
Sourcepub fn backup_verify(&self, root: &Path) -> Result<BackupManifest>
pub fn backup_verify(&self, root: &Path) -> Result<BackupManifest>
Verify hashes, schema, and qcow2 structure for a portable backup.
Sourcepub fn backup_restore(
&self,
root: &Path,
destination_name: &str,
) -> Result<PathBuf>
pub fn backup_restore( &self, root: &Path, destination_name: &str, ) -> Result<PathBuf>
Restore a verified backup under a new VM name and independent identity.
Sourcepub fn delete_vm(&self, name: &str) -> Result<DeleteReport>
pub fn delete_vm(&self, name: &str) -> Result<DeleteReport>
Delete a stopped VM definition and only its known managed artifacts.
Sourcepub fn command(&self, name: &str) -> Result<CommandSpec>
pub fn command(&self, name: &str) -> Result<CommandSpec>
Build the exact QEMU command without launching it.
Sourcepub fn start(&self, name: &str) -> Result<VmState>
pub fn start(&self, name: &str) -> Result<VmState>
Launch QEMU as a daemon and record its private control endpoints.
Sourcepub fn status(&self, name: &str) -> Result<VmStatus>
pub fn status(&self, name: &str) -> Result<VmStatus>
Query QMP when possible and distinguish stopped from stale state.
Sourcepub fn stop(&self, name: &str, timeout: Duration) -> Result<()>
pub fn stop(&self, name: &str, timeout: Duration) -> Result<()>
Request ACPI power-off and escalate to QMP quit after the timeout.
Sourcepub fn balloon_status(&self, name: &str) -> Result<BalloonStatus>
pub fn balloon_status(&self, name: &str) -> Result<BalloonStatus>
Return the running VM’s guest-reported balloon state.
Sourcepub fn balloon_set(&self, name: &str, memory_mib: u64) -> Result<()>
pub fn balloon_set(&self, name: &str, memory_mib: u64) -> Result<()>
Request a bounded runtime memory target for a running VM.
Sourcepub fn balloon_restore(&self, name: &str) -> Result<u64>
pub fn balloon_restore(&self, name: &str) -> Result<u64>
Restore a running VM’s balloon target to its configured boot memory.
Sourcepub fn screenshot(&self, name: &str, destination: &Path) -> Result<u64>
pub fn screenshot(&self, name: &str, destination: &Path) -> Result<u64>
Capture a running VM’s current framebuffer as a new bounded PPM file.
Sourcepub fn agent_ping(&self, name: &str) -> Result<()>
pub fn agent_ping(&self, name: &str) -> Result<()>
Verify that the QEMU Guest Agent inside a running VM responds.
Sourcepub fn agent_info(&self, name: &str) -> Result<Value>
pub fn agent_info(&self, name: &str) -> Result<Value>
Return the running guest agent’s version and supported command list.
Sourcepub fn agent_shutdown(&self, name: &str, mode: ShutdownMode) -> Result<()>
pub fn agent_shutdown(&self, name: &str, mode: ShutdownMode) -> Result<()>
Ask the guest operating system to shut down through its guest agent.
Sourcepub fn snapshot_list(&self, name: &str) -> Result<String>
pub fn snapshot_list(&self, name: &str) -> Result<String>
List internal qcow2 snapshots for a stopped VM.
Sourcepub fn snapshot_create(&self, name: &str, snapshot: &str) -> Result<()>
pub fn snapshot_create(&self, name: &str, snapshot: &str) -> Result<()>
Create an internal qcow2 snapshot for a stopped VM.
Sourcepub fn snapshot_revert(&self, name: &str, snapshot: &str) -> Result<()>
pub fn snapshot_revert(&self, name: &str, snapshot: &str) -> Result<()>
Revert a stopped VM to an internal qcow2 snapshot.
Sourcepub fn snapshot_delete(&self, name: &str, snapshot: &str) -> Result<()>
pub fn snapshot_delete(&self, name: &str, snapshot: &str) -> Result<()>
Delete an internal qcow2 snapshot from a stopped VM.
Sourcepub fn generation_id(&self, name: &str) -> Result<Option<Uuid>>
pub fn generation_id(&self, name: &str) -> Result<Option<Uuid>>
Return the stable VM Generation ID exposed to the guest.
Sourcepub fn regenerate_generation_id(&self, name: &str) -> Result<Uuid>
pub fn regenerate_generation_id(&self, name: &str) -> Result<Uuid>
Replace a stopped VM’s generation ID after an external duplication event.
Sourcepub fn running_state(&self, name: &str) -> Result<VmState>
pub fn running_state(&self, name: &str) -> Result<VmState>
Load current runtime state for the console.