vm

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ConfigDir [deprecated] is config directory name
	ConfigDir = "config"
)

Variables

This section is empty.

Functions

func FindAll

func FindAll() (map[string]Process, error)

FindAll finds all running cloud-hypervisor processes

Types

type Boot

type Boot struct {
	Kernel string `json:"kernel_image_path"`
	Initrd string `json:"initrd_path,omitempty"`
	Args   string `json:"boot_args"`
}

Boot config struct

type CPU

type CPU uint8

CPU type

func (CPU) String

func (c CPU) String() string

type Client

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

Client to a cloud hypervisor instance

func NewClient

func NewClient(unix string) *Client

NewClient creates a new instance of client

func (*Client) Inspect

func (c *Client) Inspect(ctx context.Context) (VMData, error)

Inspect return information about the vm

func (*Client) Pause

func (c *Client) Pause(ctx context.Context) error

func (*Client) Resume

func (c *Client) Resume(ctx context.Context) error

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context) error

Shutdown shuts the machine down

type Config

type Config struct {
	CPU       CPU    `json:"vcpu_count"`
	Mem       MemMib `json:"mem_size_mib"`
	HTEnabled bool   `json:"ht_enabled"`
}

Config struct

type Console

type Console struct {
	Namespace     string    `json:"namespace"`
	ListenAddress net.IPNet `json:"network_addr"`
	VmAddress     net.IPNet `json:"ip"`
}

type Disk

type Disk struct {
	ID         string `json:"drive_id"`
	Path       string `json:"path_on_host"`
	RootDevice bool   `json:"is_root_device"`
	ReadOnly   bool   `json:"is_read_only"`
}

Disk struct

func (Disk) String

func (d Disk) String() string

type Disks

type Disks []Disk

Disks is a list of vm disks

type Interface

type Interface struct {
	ID      string   `json:"iface_id"`
	Tap     string   `json:"host_dev_name"`
	Mac     string   `json:"guest_mac,omitempty"`
	Console *Console `json:"console,omitempty"`
}

Interface nic struct

type InterfaceType

type InterfaceType string

InterfaceType interface type

const (
	// InterfaceTAP tuntap type
	InterfaceTAP     InterfaceType = "tuntap"
	InterfaceMacvtap InterfaceType = "macvtap"
)

type Interfaces

type Interfaces []Interface

Interfaces is a list of node interfaces

type LegacyMonitor

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

LegacyMonitor has code to clean up legacy machines death

func (*LegacyMonitor) Monitor

func (m *LegacyMonitor) Monitor(ctx context.Context)

Monitor start vms monitoring

type Machine

type Machine struct {
	ID         string     `json:"id"`
	Boot       Boot       `json:"boot-source"`
	Disks      Disks      `json:"drives"`
	FS         []VirtioFS `json:"fs"`
	Interfaces Interfaces `json:"network-interfaces"`
	Config     Config     `json:"machine-config"`
	// devices to attack directly to VMd
	Devices []string `json:"devices"`
	// NoKeepAlive is not used by firecracker, but instead a marker
	// for the vm  mananger to not restart the machine when it stops
	NoKeepAlive bool `json:"no-keep-alive"`
}

Machine struct

func MachineFromFile

func MachineFromFile(n string) (*Machine, error)

MachineFromFile loads a vm config from file

func (*Machine) Run

func (m *Machine) Run(ctx context.Context, socket, logs string) (pkg.MachineInfo, error)

Run run the machine with cloud-hypervisor

func (*Machine) Save

func (m *Machine) Save(n string) error

Save saves a machine into a file

type MemMib

type MemMib uint64

MemMib is memory size in mib

func (MemMib) String

func (m MemMib) String() string

type Module

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

Module implements the VMModule interface

func NewVMModule

func NewVMModule(cl zbus.Client, root, config string) (*Module, error)

NewVMModule creates a new instance of vm manager

func (*Module) Delete

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

Delete deletes a machine by name (id)

func (*Module) Exists

func (m *Module) Exists(id string) bool

Exists checks if firecracker process running for this machine

func (*Module) Inspect

func (m *Module) Inspect(name string) (pkg.VMInfo, error)

Inspect a machine by name

func (*Module) List

func (m *Module) List() ([]string, error)

List all running vms names

func (*Module) Lock

func (m *Module) Lock(name string, lock bool) error

func (*Module) Logs

func (m *Module) Logs(name string) (string, error)

Logs returns machine logs for give machine name

func (*Module) Metrics

func (m *Module) Metrics() (pkg.MachineMetrics, error)

Metrics gets running machines network metrics

func (*Module) Monitor

func (m *Module) Monitor(ctx context.Context)

Monitor start vms monitoring

func (*Module) Run

func (m *Module) Run(vm pkg.VM) (pkg.MachineInfo, error)

Run vm

func (*Module) StreamCreate

func (m *Module) StreamCreate(name string, stream pkg.Stream) error

StreamCreate creates a stream for vm `name`

func (*Module) StreamDelete

func (m *Module) StreamDelete(id string) error

delete stream by stream id.

type Process

type Process struct {
	Pid  int
	Args []string
}

Process struct

func Find

func Find(name string) (Process, error)

Find find CH process by vm name

func (*Process) GetParam

func (p *Process) GetParam(arg string) ([]string, bool)

GetParam gets a value for a parm passed to process cmdline

type VMData

type VMData struct {
	CPU     CPU
	Memory  MemMib
	PTYPath string
}

type VirtioFS

type VirtioFS struct {
	Tag  string
	Path string
}

VirtioFS represents a virtiofs mount

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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