Documentation
¶
Index ¶
- Constants
- Variables
- func AttachContainer(name string, tty bool) (detached bool, err error)
- func CheckDataDiskSize(name string, cfg VMConfig, size int64) error
- func CheckLocalPort(port int) error
- func CheckRosetta() error
- func CleanState(name string)
- func CreateContainer(name string, cfg VMConfig, imageDisk string) error
- func DataDiskSize(name string) (int64, error)
- func DefaultDisk(rootfsTarball, modloopPath, name string, log io.Writer, overlays ...string) (string, error)
- func DefaultRootFS(log io.Writer) (string, error)
- func DialConsole(name string) (net.Conn, error)
- func DiscardSuspended(name string) error
- func EngineOf(cfg VMConfig) string
- func Exists(name string) bool
- func FormatPorts(ports []PortForward) string
- func ForwardedPorts(name string) string
- func FreeLocalPort() (int, error)
- func K3sVersionOf(cfg VMConfig) string
- func LoadImage(name string, r io.Reader) error
- func MarshalControlRequest(req ControlRequest) ([]byte, error)
- func MarshalControlResponse(resp ControlResponse) ([]byte, error)
- func ProcessStatsEx(pid int) (cpuPct float64, rssBytes int64, cpuTime string)
- func RunDaemon(name string, restore bool, consoleLogPath string) error
- func SpawnVMDaemon(name string, restore bool, consoleLogPath string) error
- func UpdateStateStatus(name, status string) error
- func VMConsoleLogPath(name string) (string, error)
- func VMContainerDiskPath(name string) (string, error)
- func VMDir(name string) (string, error)
- func VMDockerSockPath(name string) (string, error)
- func VMExitPath(name string) (string, error)
- func VMKubeDir(name string) (string, error)
- func VMKubeconfigPath(name string) (string, error)
- func VMLoadSockPath(name string) (string, error)
- func VMLogPath(name string) (string, error)
- func VMMachineIDPath(name string) (string, error)
- func VMSSHKeyPath(name string) (string, error)
- func VMSSHSockPath(name string) (string, error)
- func VMSockPath(name string) (string, error)
- func VMSuspendPath(name string) (string, error)
- func VMsDir() (string, error)
- func WaitDaemonExit(name string, timeout time.Duration) error
- func WatchBoot(r io.Reader, steps []BootStep, line func(step int, text string), ...) (rest []byte, err error)
- func WriteConfig(name string, cfg VMConfig) error
- func WriteState(name string, pid int, mac, status string) error
- func WriteSuspendState(name, mac, suspendFile string) error
- type BootSpec
- type BootStep
- type ContainerConfig
- type ControlRequest
- type ControlResponse
- type ExitStatus
- type Image
- type KernelAssets
- type PortForward
- type PublishedPort
- type SandboxConfig
- type Share
- type VMConfig
- type VMState
- type VMStatus
Constants ¶
const ( // DefaultDataDiskSize is a new docker host's data disk (images, // containers, volumes). The file is sparse, so this is a ceiling, not // space taken up front. VMs created before data_disk_size existed got // 64 GiB. DefaultDataDiskSize = 20 << 30 // MinDataDiskSize is the smallest --disk accepted. MinDataDiskSize = 4 << 30 // GuestLayoutDiskResize is the first guest layout whose docker-setup // grows the data disk's filesystem to the disk's size on boot. (Layout 5 // is the /var/folders share, GuestLayoutTempShare, which doesn't resize.) GuestLayoutDiskResize = 6 )
const ( ImageKata = "kata" ImageAlpine = "alpine" ImageDocker = "docker" )
Base image names accepted by `vm run --image` and stored in config.json.
const ( // ImageCluster is the base image of `monolith cluster` VMs: Alpine // running a single-node k3s server on its bundled containerd. It isn't // in ValidImages; `vm run --image` doesn't create clusters. ImageCluster = "cluster" // ClusterLoadPort is the guest's image load service (cluster-serve // load), reached through the daemon's load.sock. ClusterLoadPort = 2382 )
const ( // DockerAPIPort is the guest TCP port relayed to dockerd's socket. The // guest only accepts connections to it from the user-mode gateway, so // containers can't reach it. DockerAPIPort = 2375 // NerdctlPortsPort is the guest TCP port that answers each connection // with `nerdctl ps --format json` (containerd engine), restricted to the // gateway like DockerAPIPort. The daemon reads published ports from it. NerdctlPortsPort = 2377 // LoopbackRelayPort is the guest TCP port (gateway only) that relays a // connection to a port on the guest's loopback. The first line sent is // the port ("<port>", or "6 <port>" for [::1]); the rest is the stream. LoopbackRelayPort = 2381 // SSHPort is the guest's internal sshd (containerd engine), used by // `monolith docker nerdctl` through the daemon's ssh.sock. SSHPort = 22 )
const ( EngineDocker = "docker" EngineContainerd = "containerd" )
Container engines for the docker image.
const ( // DefaultK3sVersion is the k3s release used when --k3s-version isn't given. DefaultK3sVersion = "v1.36.5+k3s1" // KubeAPIPort is the k3s API server port in the guest. KubeAPIPort = 6443 // GuestLayout is the version of the guest files written into a docker // image VM's disk when it's created. Layout 1 had the k3s services (no // longer used: docker hosts don't run Kubernetes); layout 2 adds clean // shutdown, Rosetta and file-change events; layout 3 adds the sandbox // pieces (repo overlay, listening-ports relay); layout 4 adds the boot // step markers, and is also recorded for alpine VMs; layout 5 mounts the // Mac's /var/folders (GuestLayoutTempShare); layout 6 grows the data // disk's filesystem (GuestLayoutDiskResize); layout 7 adds the cluster // image's load service (GuestLayoutImageLoad). GuestLayout = 7 // Minimum GuestLayout for each feature that needs guest files. GuestLayoutRosetta = 2 // also clean shutdown and file-change events GuestLayoutBootSteps = 4 GuestLayoutImageLoad = 7 // cluster image: `monolith cluster load` )
Kubernetes (k3s) in cluster VMs. The host downloads the k3s binary once per version and shares the directory read-only into the guest over virtio-fs (tag "k3s"); the guest runs it as a single-node server.
const ( // MsgConsoleAttach requests a bidirectional PTY relay. // After the daemon sends an ACK byte (MsgConsoleAttach), raw bytes // flow in both directions until the client disconnects. MsgConsoleAttach byte = 0x01 // MsgControl sends a JSON-encoded control command. // Format: [0x02] [4-byte big-endian length] [JSON request] // Response: [0x02] [4-byte big-endian length] [JSON response] MsgControl byte = 0x02 )
Protocol message types — first byte on the Unix socket connection.
const ( CmdPause = "pause" CmdResume = "resume" CmdSuspend = "suspend" CmdStop = "stop" CmdStatus = "status" CmdResize = "resize" // CmdSignal delivers Signal to a container's process. CmdSignal = "signal" )
Control command names.
const ( SandboxNetworkOutbound = "outbound" // internet, but nothing private: not the Mac, the LAN or the gateway SandboxNetworkNone = "none" // the shell container has no network at all SandboxNetworkAllow = "allow" // only the Allow list (plus DNS) )
Sandbox network policies.
const ( // ListeningPortsPort is the guest TCP port (gateway only) that answers // with /proc/net/tcp and /proc/net/tcp6, so the daemon can forward // whatever a sandbox's processes listen on. ListeningPortsPort = 2380 // GuestLayoutSandbox is the first guest layout with the sandbox pieces. GuestLayoutSandbox = 3 )
const ( StatusStopped = "stopped" // No process, no resources. Initial and final state. StatusRunning = "running" // Daemon alive, VM executing, guest clock ticking. StatusPaused = "paused" // Daemon alive, VM frozen in memory, guest clock stopped. StatusSuspended = "suspended" // Daemon exited, VM state saved to disk file. )
VM status constants — persisted in state.json and reported by `vm list`.
const DefaultImage = ImageAlpine
DefaultImage is used for new VMs when --image is not given. Existing VMs keep the image in their config.json.
const ( // FileEventsPort is the guest TCP port (gateway only) that takes one // path per line and touches it, raising inotify events in the guest. FileEventsPort = 2379 )
const ( // /var/folders. GuestLayoutTempShare = 5 )
const ImageContainer = "container"
ImageContainer is the base image of `monolith container` VMs: one VM per container, booting Kata's kernel with monolith-init as PID 1 and an APFS clone of the container image's disk as root. It isn't a `vm run --image` choice; `container run` creates these VMs.
Variables ¶
var ValidEngines = []string{EngineDocker, EngineContainerd}
ValidEngines is the set of accepted --engine values.
var ValidImages = []string{ImageKata, ImageAlpine, ImageDocker}
ValidImages is the set of accepted --image values.
var ValidSandboxNetworks = []string{SandboxNetworkOutbound, SandboxNetworkNone, SandboxNetworkAllow}
ValidSandboxNetworks is the set of accepted --network values.
Functions ¶
func AttachContainer ¶
AttachContainer relays a container's console to the terminal until the container exits or the user detaches.
With tty, the terminal is raw and every key goes to the container, Ctrl+C included; Ctrl+P Ctrl+Q detaches, as with Docker. Without tty, output is copied as is, stdin isn't read, and Ctrl+C (SIGINT) and SIGTERM are delivered to the container's process.
detached reports that the user detached and the container keeps running.
func CheckDataDiskSize ¶ added in v0.0.2
CheckDataDiskSize reports whether VM name's data disk can be set to size: at least MinDataDiskSize, never smaller than the disk already is (ext4 can't shrink online and the space may be in use), and growing an existing disk needs a guest that resizes its filesystem.
func CheckLocalPort ¶ added in v0.0.2
CheckLocalPort reports whether a localhost TCP forward of port could listen right now (nil) or not (the bind error), by binding it the way listenLocalTCP does and closing it again.
func CheckRosetta ¶
func CheckRosetta() error
CheckRosetta explains why Rosetta can't be shared into a VM, if it can't.
func CreateContainer ¶
CreateContainer creates container VM name from an image disk: the VM directory, an APFS clone of the disk (instant, copy-on-write) extended to cfg.Container.DiskSize (sparse; monolith-init grows the filesystem at boot) and the config.
func DataDiskSize ¶ added in v0.0.2
DataDiskSize returns the size of VM name's docker data disk, or 0 if it hasn't been created yet.
func DefaultDisk ¶
func DefaultDisk(rootfsTarball, modloopPath, name string, log io.Writer, overlays ...string) (string, error)
DefaultDisk returns the path to the VM's disk image, creating and populating it with the Alpine minirootfs on first use. Each VM gets its own disk under ~/.monolith/vms/<name>/disk.img. overlays are extra manifests under embeddings/ (e.g. "docker/manifest.yaml") applied after the base manifest; their files replace the base ones.
func DefaultRootFS ¶
DefaultRootFS returns the path to the cached Alpine minirootfs tarball, downloading it on first use.
func DialConsole ¶
DialConsole attaches to the VM daemon's console. The connection then carries console output, starting with the replay of recent output, and takes input for the guest.
func DiscardSuspended ¶
DiscardSuspended deletes a suspended VM's saved state and snapshot file, leaving it stopped. Used when a snapshot can't or shouldn't be restored.
func EngineOf ¶
EngineOf returns the VM's container engine; configs from before engines existed are docker.
func Exists ¶
Exists reports whether a VM directory exists for name. A VM is a directory under VMsDir holding a config.json (written by `vm run`) or a disk.img (older Alpine VMs and VMs started directly with __vmd).
func FormatPorts ¶ added in v0.0.2
func FormatPorts(ports []PortForward) string
FormatPorts formats forwards as ForwardedPorts does.
func ForwardedPorts ¶ added in v0.0.2
ForwardedPorts asks a docker or cluster VM's daemon for the ports it forwards to localhost, formatted for a list column: "8080,53/udp,9000!" ("!" = couldn't bind), "-" for none, "?" if the daemon didn't answer.
func FreeLocalPort ¶
FreeLocalPort returns a TCP port that is free on 127.0.0.1 right now, for the host end of a VM's Kubernetes API forward.
func K3sVersionOf ¶
K3sVersionOf returns the VM's k3s version, defaulting when unset.
func LoadImage ¶ added in v0.0.2
LoadImage writes an image tarball (`docker save` format) from r to cluster name's load socket, where the guest imports it into k3s's containerd, and waits for the guest's answer.
func MarshalControlRequest ¶
func MarshalControlRequest(req ControlRequest) ([]byte, error)
MarshalControlRequest encodes a control request to JSON bytes.
func MarshalControlResponse ¶
func MarshalControlResponse(resp ControlResponse) ([]byte, error)
MarshalControlResponse encodes a control response to JSON bytes.
func ProcessStatsEx ¶
ProcessStatsEx returns CPU%, RSS (bytes), and cumulative CPU time for the given PID. The cpuTime string is in the format "H:MM:SS" or "M:SS".
func RunDaemon ¶
RunDaemon is the main entry point for the VM daemon process. It boots (or restores) a VM, connects its serial console to a PTY, and listens on a Unix domain socket for console attachment and control commands. It blocks until the VM stops or a fatal error occurs.
If consoleLogPath is non-empty, all guest console output is appended to that file from boot onward, independent of any attached client.
func SpawnVMDaemon ¶
SpawnVMDaemon starts the VM daemon as a background process. It uses the same binary (os.Executable) with the hidden __vmd command. Returns after the daemon has started and its socket is ready. A non-empty consoleLogPath is forwarded as --log-console.
func UpdateStateStatus ¶
UpdateStateStatus updates only the status field of the state file. Used by the daemon to transition between running/paused without rewriting everything.
func VMConsoleLogPath ¶
VMConsoleLogPath is a container's output (`container logs`).
func VMContainerDiskPath ¶
VMContainerDiskPath is a container's root disk (an APFS clone of its image).
func VMDockerSockPath ¶
VMDockerSockPath returns the host socket relayed to dockerd in a docker image VM; point DOCKER_HOST at it.
func VMExitPath ¶
VMExitPath records how a container's last run ended.
func VMKubeDir ¶ added in v0.0.2
VMKubeDir returns the directory shared into a cluster VM (read-write); k3s writes its kubeconfig there.
func VMKubeconfigPath ¶ added in v0.0.2
VMKubeconfigPath returns the kubeconfig k3s writes in a cluster VM, with the server at https://127.0.0.1:6443 (as seen from the guest).
func VMLoadSockPath ¶ added in v0.0.2
VMLoadSockPath returns the host socket relayed to a cluster VM's image load service (`monolith cluster load` writes an image tarball to it).
func VMMachineIDPath ¶
VMMachineIDPath returns the path of the VM's persisted machine identifier.
func VMSSHKeyPath ¶
VMSSHKeyPath returns the private key for a containerd engine VM's internal sshd; the public half is at the same path plus ".pub".
func VMSSHSockPath ¶
VMSSHSockPath returns the host socket relayed to a containerd engine VM's internal sshd (use with ssh -o ProxyCommand="nc -U <path>").
func VMSockPath ¶
VMSockPath returns the path to the VM daemon's Unix domain socket.
func VMSuspendPath ¶
VMSuspendPath returns the path where a VM's state is saved on suspend.
func WaitDaemonExit ¶
WaitDaemonExit waits for a VM's daemon to exit.
func WatchBoot ¶
func WatchBoot(r io.Reader, steps []BootStep, line func(step int, text string), ended func(step int)) (rest []byte, err error)
WatchBoot reads console output from r and follows steps through it. Each console line goes to line with the index of the step it belongs to, and ended is called as each step ends. A marker for a later step ends the steps before it too. WatchBoot returns once the last step has ended, with the output read past that point, which belongs to the console.
func WriteConfig ¶
WriteConfig persists the VM configuration to its config file.
func WriteState ¶
WriteState writes the VM state file into the VM's cache directory.
func WriteSuspendState ¶
WriteSuspendState writes a suspended state (daemon has exited, state file on disk).
Types ¶
type BootSpec ¶
type BootSpec struct {
KernelPath string // raw ARM64 Image, as VZLinuxBootLoader requires
InitrdPath string // optional
CommandLine string
DiskPath string // root disk attached as /dev/vda
DiskReadOnly bool // true when the disk is a base image shared by all VMs
DataDiskPath string // optional second writable disk, attached as /dev/vdb
Rosetta bool // share Rosetta (virtio-fs tag "rosetta") to run x86-64 binaries
// HandlesStop is true when the guest shuts down cleanly on the VM's
// stop request, so the daemon can wait longer before forcing it.
HandlesStop bool
}
BootSpec is everything the daemon needs from a base image to boot a VM.
type BootStep ¶
BootStep is a stage of the guest's boot as seen on its console. It ends when the guest prints marker End, or a line containing Match.
type ContainerConfig ¶
type ContainerConfig struct {
Image string `json:"image"` // reference as the user gave it, for display
ImageID string `json:"image_id"` // image store ID the disk was cloned from
Spec ci.Spec `json:"spec"` // the process, handed to monolith-init
// StopSignal is what `container stop` sends first (the image's
// STOPSIGNAL, e.g. "SIGQUIT" for nginx); default SIGTERM.
StopSignal string `json:"stop_signal,omitempty"`
Created time.Time `json:"created"`
DiskSize int64 `json:"disk_size"` // bytes (--disk)
// Attach makes the daemon hold the process until a console client
// attaches, so a foreground run sees all output. `run`/`start -a` set
// it; `run -d`/`start` clear it.
Attach bool `json:"attach,omitempty"`
// AutoRemove deletes the container when it exits (`run -d --rm`; a
// foreground --rm is removed by the CLI after reading the exit code).
AutoRemove bool `json:"auto_remove,omitempty"`
// Ports are `run -p`: forwarded from the Mac's localhost to the
// container while it runs.
Ports []PublishedPort `json:"ports,omitempty"`
}
ContainerConfig makes a VM a container (`monolith container`).
type ControlRequest ¶
type ControlRequest struct {
Cmd string `json:"cmd"`
Force bool `json:"force,omitempty"` // for stop: forceful termination
Rows uint16 `json:"rows,omitempty"` // for resize: terminal rows
Cols uint16 `json:"cols,omitempty"` // for resize: terminal columns
Signal int `json:"signal,omitempty"` // for signal: the signal number
Timeout int `json:"timeout,omitempty"` // for stop: seconds before killing a container (0: default)
}
ControlRequest is a JSON-encoded command sent from client to daemon.
func AttachConsole ¶
func AttachConsole(name string) (*ControlRequest, error)
AttachConsole connects to the VM daemon's Unix socket and relays the console PTY to the user's terminal. It handles the Ctrl+] escape sequence for the command prompt and Ctrl+C for quick detach.
Returns a ControlRequest if the user issued a command from the escape prompt (pause, resume, suspend, stop), or nil on clean detach.
func RelayConsole ¶
RelayConsole relays a console connection from DialConsole to the terminal as AttachConsole does, writing pending first: output already read from conn. It closes conn.
func UnmarshalControlRequest ¶
func UnmarshalControlRequest(data []byte) (ControlRequest, error)
UnmarshalControlRequest decodes a control request from JSON bytes.
type ControlResponse ¶
type ControlResponse struct {
OK bool `json:"ok"`
Status string `json:"status,omitempty"` // current VM status after the operation
Forced bool `json:"forced,omitempty"` // stop: the guest ignored the request and was force-stopped
Error string `json:"error,omitempty"`
// Ports is reported by status for docker and cluster VMs: published
// container or service ports and whether each is forwarded to the Mac's
// localhost.
Ports []PortForward `json:"ports,omitempty"`
}
ControlResponse is a JSON-encoded reply from daemon to client.
func SendControlCommand ¶
func SendControlCommand(name string, req ControlRequest) (ControlResponse, error)
SendControlCommand connects to the VM daemon and sends a control command. Returns the daemon's response.
func UnmarshalControlResponse ¶
func UnmarshalControlResponse(data []byte) (ControlResponse, error)
UnmarshalControlResponse decodes a control response from JSON bytes.
type ExitStatus ¶
type ExitStatus struct {
Code int `json:"code"`
Error string `json:"error,omitempty"` // why the process couldn't run
FinishedAt time.Time `json:"finished_at"`
}
ExitStatus is how a container's process ended.
func ReadExit ¶
func ReadExit(name string) (ExitStatus, bool)
ReadExit returns how the container last exited; ok is false if it never has (or is running again).
func WaitContainerExit ¶
func WaitContainerExit(name string, timeout time.Duration) (ExitStatus, error)
WaitContainerExit waits for a container's daemon to exit and returns how the container ended.
type Image ¶
type Image interface {
Name() string
// Prepare downloads and caches any shared assets, creates per-VM files
// if the image needs them, and returns the boot spec for VM name. It is
// idempotent; `vm run` calls it before spawning the daemon so first-run
// downloads happen in the foreground, and the daemon calls it again.
// What it does (downloads, disk creation) is logged to log, a line at a
// time; nothing when everything is cached.
Prepare(name string, log io.Writer) (*BootSpec, error)
}
Image is a guest base image: where the kernel comes from, how the root disk is produced, and which kernel command line boots it.
func LookupImage ¶
LookupImage returns the base image with the given name.
type KernelAssets ¶
func DefaultKernel ¶
func DefaultKernel(log io.Writer) (*KernelAssets, error)
type PortForward ¶
type PortForward struct {
Port int `json:"port"`
Protocol string `json:"protocol,omitempty"` // "tcp" or "udp"
Error string `json:"error,omitempty"`
}
PortForward is a container port published to localhost on the Mac. Error is set when the daemon couldn't bind it, e.g. another VM holds the port.
type PublishedPort ¶ added in v0.0.2
type PublishedPort struct {
Host int `json:"host"`
Container int `json:"container"`
Protocol string `json:"protocol"`
}
PublishedPort is one `container run -p`: localhost:Host on the Mac to Container in the container VM, over Protocol ("tcp" or "udp").
func (PublishedPort) String ¶ added in v0.0.2
func (p PublishedPort) String() string
String formats p as `docker ps` does: "127.0.0.1:8080->80/tcp".
type SandboxConfig ¶
type SandboxConfig struct {
Repo string `json:"repo"` // absolute path of the repo on the Mac
Image string `json:"image,omitempty"` // container image for the shell (empty: default/devcontainer)
Network string `json:"network,omitempty"` // SandboxNetwork* (empty: outbound)
Allow []string `json:"allow,omitempty"` // host:port allowlist for SandboxNetworkAllow
}
SandboxConfig is the sandbox part of a VM's config.
func (*SandboxConfig) NetworkOf ¶
func (s *SandboxConfig) NetworkOf() string
NetworkOf returns the sandbox's network policy.
type Share ¶
type Share struct {
}
Share is a host directory exposed to the guest over virtio-fs; the guest mounts it with `mount -t virtiofs <Tag> <dir>`.
type VMConfig ¶
type VMConfig struct {
CPUs uint `json:"cpus"`
Memory uint64 `json:"memory"` // bytes
NetworkMode string `json:"network_mode"` // "nat", "shared", "host", "isolated", "none"
NetworkName string `json:"network_name,omitempty"` // named network to join (for shared/isolated modes)
HostInterface string `json:"host_interface,omitempty"` // physical NIC for "host" mode (e.g. "en0")
Image string `json:"image,omitempty"` // base image: "kata", "alpine", "docker", "container" or "cluster"
Engine string `json:"engine,omitempty"` // docker image only: "docker" (default) or "containerd"
Kubernetes bool `json:"kubernetes,omitempty"` // obsolete: docker hosts used to run k3s; read only so 'docker start' can clear it
K3sVersion string `json:"k3s_version,omitempty"` // cluster image: k3s release, e.g. "v1.36.5+k3s1" (default DefaultK3sVersion)
KubePort int `json:"kube_port,omitempty"` // cluster image: host port on 127.0.0.1 forwarded to the k3s API
GuestLayout int `json:"guest_layout,omitempty"` // docker and alpine images: GuestLayout its disk was created with
Rosetta bool `json:"rosetta,omitempty"` // docker and cluster images: run x86-64 binaries with Rosetta
DataDiskSize int64 `json:"data_disk_size,omitempty"` // docker image only: data disk bytes (--disk; default DefaultDataDiskSize)
// Sandbox makes a docker image VM a repo sandbox (`monolith sandbox`).
Sandbox *SandboxConfig `json:"sandbox,omitempty"`
// Container makes the VM a container (`monolith container`).
Container *ContainerConfig `json:"container,omitempty"`
MAC string `json:"mac,omitempty"` // assigned on first boot, then reused
}
VMConfig holds the per-VM hardware configuration.
func DefaultConfig ¶
func DefaultConfig() VMConfig
DefaultConfig returns the default VM configuration: 1 vCPU, 512 MiB RAM, NAT networking, Alpine base image.
func ReadConfig ¶
ReadConfig reads the VM configuration from its config file. If the file does not exist, default values are returned, except that a VM directory that already holds an Alpine disk.img stays on Alpine.
type VMState ¶
type VMState struct {
PID int `json:"pid"`
MAC string `json:"mac"`
StartedAt int64 `json:"started_at"` // unix timestamp
Status string `json:"status,omitempty"` // "running", "paused", "suspended"
SuspendFile string `json:"suspend_file,omitempty"` // path to .vmstate file when suspended
}
VMState represents the persisted runtime state of a VM.
func ReadRawState ¶
ReadRawState reads the raw VM state file without computing derived status. Used by the top command to access PID/MAC for per-tick stat gathering. Returns nil if the VM is not running or state file is missing.
type VMStatus ¶
type VMStatus struct {
State string // "running", "paused", "suspended", or "stopped"
IP string // e.g. "192.168.64.3" or "" if unknown
StartedAt time.Time // zero if stopped
CPUPercent float64 // host-side CPU% of the VM process
MemoryRSS int64 // host-side RSS in bytes
}
VMStatus is the computed status of a VM for display purposes.
Source Files
¶
- alpine_disk.go
- alpine_kernel.go
- bindcheck.go
- bootsteps.go
- client.go
- cluster.go
- config.go
- console_bus.go
- container.go
- container_agent.go
- container_attach.go
- container_ports.go
- datadisk.go
- docker.go
- fswatch.go
- image.go
- image_alpine.go
- image_cluster.go
- image_docker.go
- image_kata.go
- k3s.go
- keybag.go
- load.go
- paths.go
- portfwd.go
- portlisten.go
- preplog.go
- protocol.go
- rosetta.go
- sandbox.go
- sshkey.go
- state.go
- vmd.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package guestinit embeds monolith-init (cmd/monolith-init, built for linux/arm64 by `make build`) and packs it into the initrd container VMs boot from.
|
Package guestinit embeds monolith-init (cmd/monolith-init, built for linux/arm64 by `make build`) and packs it into the initrd container VMs boot from. |