vm

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BridgeName is the name of the network bridge used for VMs
	BridgeName = "sshvm-br0"
)

Variables

This section is empty.

Functions

func GetFirecrackerBinary

func GetFirecrackerBinary() []byte

GetFirecrackerBinary returns the embedded firecracker binary

func GetVmlinuxBinary

func GetVmlinuxBinary() []byte

GetVmlinuxBinary returns the embedded vmlinux kernel

Types

type IPPool

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

IPPool manages allocation of IP addresses for VMs

func NewIPPool

func NewIPPool(network *net.IPNet) (*IPPool, error)

NewIPPool creates a new IP pool from the given network

func (*IPPool) Allocate

func (p *IPPool) Allocate() (net.IP, error)

Allocate allocates an IP address from the pool

func (*IPPool) Available

func (p *IPPool) Available() int

Available returns the number of available IP addresses

func (*IPPool) Gateway

func (p *IPPool) Gateway() net.IP

Gateway returns the gateway IP address (network + 1) for this network

func (*IPPool) IsAllocated

func (p *IPPool) IsAllocated(ip net.IP) bool

IsAllocated checks if an IP address is allocated

func (*IPPool) MaskSize

func (p *IPPool) MaskSize() int

MaskSize returns the number of bits in the network mask (e.g. 24 for /24)

func (*IPPool) Netmask

func (p *IPPool) Netmask() net.IP

Netmask returns the subnet mask (e.g. 255.255.255.0) for this network

func (*IPPool) Release

func (p *IPPool) Release(ip net.IP)

Release releases an IP address back to the pool

type Manager

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

Manager manages the lifecycle of Firecracker VMs

func NewManager

func NewManager(config *internal.Config, logger logrus.FieldLogger, firecrackerBinary []byte, vmlinuxBinary []byte) (*Manager, error)

NewManager creates a new VM manager

func (*Manager) DestroyVM

func (m *Manager) DestroyVM(vmID string) error

DestroyVM forcibly stops and removes a VM

func (*Manager) GetActiveVMCount

func (m *Manager) GetActiveVMCount() int

GetActiveVMCount returns the current number of active VMs

func (*Manager) GetOrCreateVM

func (m *Manager) GetOrCreateVM(ctx context.Context, vmID string) (*VM, error)

GetOrCreateVM gets an existing VM or creates a new one if it doesn't exist

func (*Manager) GetVM

func (m *Manager) GetVM(vmID string) (*VM, bool)

GetVM returns the VM for a given user ID

func (*Manager) ReleaseVM

func (m *Manager) ReleaseVM(vmID string) error

ReleaseVM decrements the reference count for a VM and destroys it if no more references

type VM

type VM struct {
	ID         string
	IP         net.IP
	Gateway    net.IP
	Netmask    net.IP
	SocketPath string
	PIDFile    string
	// contains filtered or unexported fields
}

VM represents a single Firecracker microVM instance

func (*VM) Start

func (vm *VM) Start(ctx context.Context, manager *Manager) error

Start starts the Firecracker process for this VM

func (*VM) Stop

func (vm *VM) Stop() error

Stop stops the Firecracker process

Jump to

Keyboard shortcuts

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