trycua/cua

[Lume] VM Snapshot Management

Open

#15 创建于 2025年2月5日

在 GitHub 查看
 (1 评论) (1 反应) (0 负责人)HTML (1,051 fork)batch import
good first issue

仓库指标

Star
 (16,722 star)
PR 合并指标
 (平均合并 1天 9小时) (30 天内合并 119 个 PR)

描述

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>

贡献者指南