linux

package
v0.1.29 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VsockPortExec is the port for command execution
	VsockPortExec = 5000
	// VsockPortVFS is the port for VFS protocol
	VsockPortVFS = 5001
	// VsockPortReady is the port for ready signal
	VsockPortReady = 5002
)
View Source
const (
	TUNSETPERSIST = 0x400454cb
)

Variables

View Source
var (
	ErrTAPCreate         = errors.New("create TAP device")
	ErrTAPConfigure      = errors.New("configure TAP interface")
	ErrTAPSetMTU         = errors.New("set MTU")
	ErrTAPDelete         = errors.New("delete interface")
	ErrTUNOpen           = errors.New("open TUN device")
	ErrTUNSETIFF         = errors.New("TUNSETIFF")
	ErrTUNSETPERSIST     = errors.New("TUNSETPERSIST")
	ErrTUNSETPERSISTOff  = errors.New("TUNSETPERSIST(0)")
	ErrInterfaceNotFound = errors.New("interface not found")
	ErrInvalidCIDR       = errors.New("invalid CIDR")
	ErrCreateSocket      = errors.New("create socket")
	ErrSIOCSIFADDR       = errors.New("SIOCSIFADDR")
	ErrSIOCSIFNETMASK    = errors.New("SIOCSIFNETMASK")
	ErrSIOCGIFFLAGS      = errors.New("SIOCGIFFLAGS")
	ErrSIOCSIFFLAGS      = errors.New("SIOCSIFFLAGS")
)

TAP / network interface errors

View Source
var (
	ErrWriteConfig      = errors.New("write firecracker config")
	ErrCreateLogFile    = errors.New("create log file")
	ErrStartFirecracker = errors.New("start firecracker")
	ErrVMNotReady       = errors.New("VM failed to become ready")
	ErrVMReadyTimeout   = errors.New("timeout waiting for VM ready signal")
	ErrInvalidCPUCount  = errors.New("invalid cpu count")
)

Firecracker lifecycle errors

View Source
var (
	ErrVsockNotConfigured = errors.New("vsock not configured")
	ErrVsockConnect       = errors.New("connect to vsock UDS")
	ErrVsockSendConnect   = errors.New("send CONNECT command")
	ErrVsockReadResponse  = errors.New("read CONNECT response")
	ErrVsockConnectFailed = errors.New("vsock CONNECT failed")
	ErrVsockNoDirectFD    = errors.New("vsock not implemented for direct FD access; use VsockPath for UDS")
)

Vsock errors

View Source
var (
	ErrExecConnect        = errors.New("connect to exec service")
	ErrExecEncodeRequest  = errors.New("encode exec request")
	ErrExecWriteHeader    = errors.New("write header")
	ErrExecWriteRequest   = errors.New("write request")
	ErrExecReadRespHeader = errors.New("read response header")
	ErrExecReadRespData   = errors.New("read response data")
	ErrExecDecodeResponse = errors.New("decode exec response")
	ErrExecRemote         = errors.New("exec error")
)

Exec errors

View Source
var (
	ErrStop       = errors.New("stop")
	ErrCloseTapFD = errors.New("close tap fd")
)

Close errors

Functions

func ConfigureInterface

func ConfigureInterface(name, cidr string) error

func CreateTAP

func CreateTAP(name string) (int, error)

func DeleteInterface

func DeleteInterface(name string) error

func GenerateMAC

func GenerateMAC(vmID string) string

func SetMTU

func SetMTU(name string, mtu int) error

func SetupIPForwarding

func SetupIPForwarding() error

Types

type LinuxBackend

type LinuxBackend struct{}

func NewLinuxBackend

func NewLinuxBackend() *LinuxBackend

func (*LinuxBackend) Create

func (b *LinuxBackend) Create(ctx context.Context, config *vm.VMConfig) (vm.Machine, error)

func (*LinuxBackend) Name

func (b *LinuxBackend) Name() string

type LinuxMachine

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

func (*LinuxMachine) Close

func (m *LinuxMachine) Close(ctx context.Context) error

func (*LinuxMachine) DialVsock added in v0.1.20

func (m *LinuxMachine) DialVsock(port uint32) (net.Conn, error)

DialVsock opens a host-initiated vsock stream to a guest service port.

func (*LinuxMachine) Exec

func (m *LinuxMachine) Exec(ctx context.Context, command string, opts *api.ExecOptions) (*api.ExecResult, error)

func (*LinuxMachine) ExecInteractive

func (m *LinuxMachine) ExecInteractive(ctx context.Context, command string, opts *api.ExecOptions, rows, cols uint16, stdin io.Reader, stdout io.Writer, resizeCh <-chan [2]uint16) (int, error)

ExecInteractive executes a command with PTY support for interactive sessions

func (*LinuxMachine) ListFiles added in v0.1.25

func (m *LinuxMachine) ListFiles(ctx context.Context, path string) ([]api.FileInfo, error)

func (*LinuxMachine) NetworkFD

func (m *LinuxMachine) NetworkFD() (int, error)

func (*LinuxMachine) PID

func (m *LinuxMachine) PID() int

func (*LinuxMachine) ReadFile added in v0.1.25

func (m *LinuxMachine) ReadFile(ctx context.Context, path string) ([]byte, error)

func (*LinuxMachine) RootfsPath

func (m *LinuxMachine) RootfsPath() string

func (*LinuxMachine) Start

func (m *LinuxMachine) Start(ctx context.Context) error

func (*LinuxMachine) Stop

func (m *LinuxMachine) Stop(ctx context.Context) error

func (*LinuxMachine) TapName

func (m *LinuxMachine) TapName() string

TapName returns the TAP interface name

func (*LinuxMachine) VsockCID

func (m *LinuxMachine) VsockCID() uint32

VsockCID returns the guest CID

func (*LinuxMachine) VsockFD

func (m *LinuxMachine) VsockFD() (int, error)

func (*LinuxMachine) VsockPath

func (m *LinuxMachine) VsockPath() string

VsockPath returns the vsock UDS path for connecting to guest services

func (*LinuxMachine) Wait

func (m *LinuxMachine) Wait(ctx context.Context) error

func (*LinuxMachine) WriteFile added in v0.1.25

func (m *LinuxMachine) WriteFile(ctx context.Context, path string, content []byte, mode uint32) error

Jump to

Keyboard shortcuts

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