Documentation
¶
Overview ¶
Package dokivm provides virtual machine management.
Index ¶
- func GenerateID() string
- func IsAvailable() bool
- func Platform() string
- func RegisterBackend(name string, factory func(*VMMConfig) (VMM, error))
- type DriveConfig
- type FilesystemConfig
- type HypervisorInfo
- type MicroVM
- type NetworkConfig
- type VMConfig
- type VMM
- type VMMConfig
- type VMState
- type VMStats
- type VsockClient
- type VsockConfig
- type VsockMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAvailable ¶
func IsAvailable() bool
IsAvailable returns true if any microVM backend is available.
Types ¶
type DriveConfig ¶
DriveConfig holds extra block device config.
type FilesystemConfig ¶
type FilesystemConfig struct {
Type string // "virtiofs", "9p", "pmem"
Source string
Target string
Tag string
}
FilesystemConfig holds virtio-fs or 9p config.
type HypervisorInfo ¶
type HypervisorInfo struct {
Type string // "kvm", "gunyah", "geniezone", "halla", "none"
Backend string // "crosvm", "firecracker", "qemu", "none"
Available bool
Path string
}
HypervisorInfo returns information about the available hypervisor.
func DetectHypervisor ¶
func DetectHypervisor() *HypervisorInfo
DetectHypervisor returns the detected hypervisor info.
type MicroVM ¶
type MicroVM struct {
ID string
VMM VMM
PID int
State VMState
CID uint32
TapDevice string
CreatedAt time.Time
StartedAt time.Time
}
MicroVM represents a running microVM.
type NetworkConfig ¶
type NetworkConfig struct {
Type string // "tap", "bridge", "none", "host"
TapName string
Bridge string
IP string
Gateway string
DNS []string
MacAddress string
}
NetworkConfig holds network configuration for a VM.
type VMConfig ¶
type VMConfig struct {
ID string
Kernel string
Rootfs string
Initrd string
CPUs int
Memory int // MB
Cmd []string
Env []string
Cwd string
Network *NetworkConfig
Vsock *VsockConfig
Filesystems []FilesystemConfig
KernelArgs string
Console bool
ReadOnlyRootfs bool
ExtraDrives []DriveConfig
}
VMConfig holds configuration for creating a microVM.
type VMM ¶
type VMM interface {
Create(ctx context.Context, cfg *VMConfig) (*MicroVM, error)
Start(ctx context.Context, vmID string) error
Stop(ctx context.Context, vmID string, timeout time.Duration) error
Kill(ctx context.Context, vmID string) error
State(ctx context.Context, vmID string) (VMState, error)
Exec(ctx context.Context, vmID string, cmd []string, env []string, tty bool) error
Attach(ctx context.Context, vmID string) error
Logs(ctx context.Context, vmID string) (io.Reader, error)
Stats(ctx context.Context, vmID string) (*VMStats, error)
Cleanup(ctx context.Context, vmID string) error
Name() string
}
VMM abstracts any microVM backend (crosvm, firecracker, qemu).
type VMMConfig ¶
type VMMConfig struct {
ForceBackend string
KernelPath string
WorkDir string
CNIBinDir string
CNIConfDir string
Debug bool
}
VMMConfig holds global VMM configuration.
type VMStats ¶
type VMStats struct {
CPUPercent float64
MemoryMB int64
MemoryMaxMB int64
NetRxBytes int64
NetTxBytes int64
DiskRead int64
DiskWrite int64
}
VMStats holds resource usage statistics.
type VsockClient ¶
type VsockClient struct {
// contains filtered or unexported fields
}
VsockClient communicates with a microVM guest via vsock.
func NewVsockClient ¶
func NewVsockClient(cid, port uint32) *VsockClient
NewVsockClient creates a vsock client for the given CID.
func (*VsockClient) Exec ¶
func (v *VsockClient) Exec(_ context.Context, cmd []string, env []string, cwd string, tty bool, stdout, stderr io.Writer) error
Exec sends an exec command to the guest via vsock.
func (*VsockClient) HealthCheck ¶
func (v *VsockClient) HealthCheck(_ context.Context) (string, error)
HealthCheck sends a health check probe.
type VsockConfig ¶
VsockConfig holds vsock configuration.
type VsockMessage ¶
type VsockMessage struct {
Type string `json:"type"`
Data json.RawMessage `json:"data,omitempty"`
Cmd []string `json:"cmd,omitempty"`
Env []string `json:"env,omitempty"`
Cwd string `json:"cwd,omitempty"`
Tty bool `json:"tty,omitempty"`
Code int `json:"code,omitempty"`
Sig string `json:"sig,omitempty"`
}
VsockMessage represents a message exchanged via vsock.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package crosvm provides crosvm-based VM backend.
|
Package crosvm provides crosvm-based VM backend. |
|
Package firecracker provides Firecracker-based VM backend.
|
Package firecracker provides Firecracker-based VM backend. |
|
Package network provides VM networking.
|
Package network provides VM networking. |
|
Package qemu provides QEMU-based VM backend.
|
Package qemu provides QEMU-based VM backend. |
|
Package rootfs builds root filesystems for VMs.
|
Package rootfs builds root filesystems for VMs. |