vmstate

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package vmstate tracks running winkit VMs via JSON state files. Each VM gets a file named <name>.json in a state directory (default ~/.winkit/run/).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDir

func DefaultDir() string

DefaultDir returns the default state directory (~/.winkit/run/).

func IsAlive

func IsAlive(pid int) bool

IsAlive checks if a process with the given PID is still running.

func Remove

func Remove(dir, name string) error

Remove deletes the state file for name. No error if it doesn't exist.

func Save

func Save(dir string, s *State) error

Save writes the state to <dir>/<name>.json. Creates dir if needed.

Types

type State

type State struct {
	Name      string    `json:"name"`
	ImagePath string    `json:"image_path"`
	PID       int       `json:"pid"`
	Backend   string    `json:"backend"`
	StartedAt time.Time `json:"started_at"`
	SSHPort   uint16    `json:"ssh_port,omitempty"`
	RDPPort   uint16    `json:"rdp_port,omitempty"`
	VNCPort   uint16    `json:"vnc_port,omitempty"`
	// Forwards are the extra host:guest TCP forwards the VM was started with.
	Forwards  []string `json:"forwards,omitempty"`
	Accel     string   `json:"accel,omitempty"`
	OutputDir string   `json:"output_dir,omitempty"`
}

State describes a running VM.

func FindByImage

func FindByImage(dir, path string) (*State, error)

FindByImage returns the first state whose ImagePath matches path, or nil.

func List

func List(dir string) ([]*State, error)

List returns all states in dir. Returns nil (not error) if dir doesn't exist.

func Load

func Load(dir, name string) (*State, error)

Load reads the state for name from <dir>/<name>.json.

Jump to

Keyboard shortcuts

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