Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VM Snapshot Management #15

Open
Else00 opened this issue Feb 5, 2025 · 1 comment
Open

VM Snapshot Management #15

Else00 opened this issue Feb 5, 2025 · 1 comment
Labels
good first issue Good for newcomers

Comments

@Else00
Copy link

Else00 commented Feb 5, 2025

Current Behavior

Currently lume does not support creating, managing, or restoring VM snapshots.

Desired Behavior

Ability to:

  • Create named snapshots of running or stopped VMs
  • List available snapshots for a VM
  • Restore VMs to previous snapshots
  • Delete snapshots
  • Export/Import snapshots

Technical Implementation

macOS Virtualization.Framework already provides snapshot support through VZMacOSVirtualMachineSnapshot class, which offers:

  • VZMacOSVirtualMachine.takeSnapshot() - Creates a snapshot of the current VM state
  • VZMacOSVirtualMachine.restoreSnapshot(_:) - Restores VM to a previous snapshot
  • Snapshot data can be written to disk using write(toFile:) and loaded using init(contentsOf:)

This native support makes implementation straightforward, mainly requiring:

  1. CLI interface to expose snapshot functions
  2. Snapshot management system
  3. Storage handling for snapshot files

Proposed CLI Commands

# Create snapshot
lume snapshot create <vm-name> [--name <snapshot-name>]

# List snapshots
lume snapshot list <vm-name>

# Restore snapshot
lume snapshot restore <vm-name> <snapshot-name>

# Delete snapshot
lume snapshot delete <vm-name> <snapshot-name>

# Export snapshot
lume snapshot export <vm-name> <snapshot-name> <output-path>

# Import snapshot
lume snapshot import <vm-name> <snapshot-path>
@f-trycua
Copy link
Contributor

f-trycua commented Feb 8, 2025

Thanks for these details, @Else00, and for already digging into the Apple Virtualization docs.

I haven’t had the chance to experiment with VZMacOSVirtualMachine.takeSnapshot() yet, but do you think it could be used to implement a lume suspend command? VZVirtualMachine can be paused, but I’m not sure if that state can persist across different runs.

@f-trycua f-trycua added the good first issue Good for newcomers label Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants