snapshot

package
v0.6.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 12 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Rendered for darwin/amd64

Overview

Package snapshot provides VM state snapshot helpers, including both the public Virtualization save/restore APIs and the private save-with-options selector for compressed or encrypted state files.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSaveOptionsUnavailable reports that the private
	// _VZVirtualMachineSaveOptions class is not available on this OS.
	ErrSaveOptionsUnavailable = errors.New("private save options class unavailable")
	// ErrSaveWithOptionsUnsupported reports that the VM does not respond to
	// _saveMachineStateToURL:options:completionHandler:.
	ErrSaveWithOptionsUnsupported = errors.New("private save with options selector unavailable")
)

Functions

func CanSaveWithOptions

func CanSaveWithOptions(machine vz.VZVirtualMachine) bool

CanSaveWithOptions reports whether machine supports saving state with private SaveOptions on this host.

func SaveMachineStateWithOptions

func SaveMachineStateWithOptions(ctx context.Context, machine vz.VZVirtualMachine, queue *vm.Queue, url foundation.NSURL, opts SaveOptions) error

SaveMachineStateWithOptions saves machine state to url using the private _saveMachineStateToURL:options:completionHandler: selector.

If the private class or selector is unavailable, it returns ErrSaveOptionsUnavailable or ErrSaveWithOptionsUnsupported without hanging. If ctx expires before completion, it returns ctx.Err(); callers must not retry to the same URL or resume the VM while the save may still be running.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles VM state snapshot operations.

func NewManager

func NewManager(vmDir string) *Manager

NewManager creates a snapshot manager for vmDir.

func (*Manager) Delete

func (m *Manager) Delete(name string) error

Delete removes a named snapshot.

func (*Manager) List

func (m *Manager) List() ([]Meta, error)

List returns all available snapshots sorted by creation time.

func (*Manager) Restore

func (m *Manager) Restore(machine vz.VZVirtualMachine, queue *vm.Queue, name string) error

Restore restores a VM from a previously saved snapshot.

func (*Manager) Save

func (m *Manager) Save(machine vz.VZVirtualMachine, queue *vm.Queue, name string) error

Save saves the current VM state to a named snapshot.

type Meta

type Meta struct {
	Name     string    `json:"name"`
	Created  time.Time `json:"created"`
	Size     int64     `json:"size"`
	VMState  string    `json:"vmState"`
	FilePath string    `json:"filePath"`
}

Meta is the on-disk metadata format for VM state snapshots.

type SaveOptions

type SaveOptions struct {
	Compress bool
	Encrypt  bool
}

SaveOptions configures private VM state saving via _saveMachineStateToURL:options:completionHandler:.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL