Documentation
¶
Index ¶
- Variables
- func CopyLogFile(ctx context.Context, path string, w io.Writer, follow bool) error
- func ReadLogFile(path string) ([]byte, error)
- type Manager
- func (m *Manager) DBPath() string
- func (m *Manager) Dir(id string) string
- func (m *Manager) ExecSocketPath(id string) string
- func (m *Manager) Get(id string) (VMState, error)
- func (m *Manager) Kill(id string) error
- func (m *Manager) List() ([]VMState, error)
- func (m *Manager) LogPath(id string) string
- func (m *Manager) Prune() ([]string, error)
- func (m *Manager) ReadLog(id string) ([]byte, error)
- func (m *Manager) Register(id string, config interface{}) error
- func (m *Manager) Remove(id string) error
- func (m *Manager) SocketPath(id string) string
- func (m *Manager) StreamLog(ctx context.Context, id string, w io.Writer, follow bool) error
- func (m *Manager) Unregister(id string) error
- type SubnetAllocator
- func (a *SubnetAllocator) Allocate(vmID string) (*SubnetInfo, error)
- func (a *SubnetAllocator) AllocationPath(vmID string) string
- func (a *SubnetAllocator) Cleanup(mgr *Manager) error
- func (a *SubnetAllocator) Get(vmID string) (*SubnetInfo, error)
- func (a *SubnetAllocator) Release(vmID string) error
- type SubnetInfo
- type VMState
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrStateDBInit = errors.New("initialize state database") ErrRegisterVM = errors.New("register VM") ErrUnregisterVM = errors.New("unregister VM") ErrListVMs = errors.New("list VMs") ErrGetVM = errors.New("get VM") ErrKillVM = errors.New("kill VM") ErrRemoveVM = errors.New("remove VM") ErrReadLog = errors.New("read VM log") ErrWriteLog = errors.New("write VM log") ErrNoAvailableSubnets = errors.New("no available subnets") ErrSaveSubnetAllocation = errors.New("failed to save subnet allocation") )
Functions ¶
func CopyLogFile ¶ added in v0.2.4
CopyLogFile writes the current contents of path to w and, when follow is true, continues streaming appended data until ctx is cancelled.
func ReadLogFile ¶ added in v0.2.4
ReadLogFile returns the current contents of path.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager() *Manager
func NewManagerWithDir ¶
func (*Manager) ExecSocketPath ¶
func (*Manager) SocketPath ¶
func (*Manager) StreamLog ¶ added in v0.2.4
StreamLog writes the current VM log to w and, when follow is true, continues streaming appended data until ctx is cancelled.
func (*Manager) Unregister ¶
type SubnetAllocator ¶
type SubnetAllocator struct {
// contains filtered or unexported fields
}
SubnetAllocator manages unique /24 subnet allocation for VMs Uses 192.168.X.0/24 where X ranges from 100-254.
func NewSubnetAllocator ¶
func NewSubnetAllocator() *SubnetAllocator
func NewSubnetAllocatorWithDir ¶ added in v0.1.19
func NewSubnetAllocatorWithDir(baseDir string) *SubnetAllocator
func (*SubnetAllocator) Allocate ¶
func (a *SubnetAllocator) Allocate(vmID string) (*SubnetInfo, error)
Allocate assigns a unique subnet to a VM.
func (*SubnetAllocator) AllocationPath ¶ added in v0.1.19
func (a *SubnetAllocator) AllocationPath(vmID string) string
AllocationPath is retained for lifecycle/debug compatibility.
func (*SubnetAllocator) Cleanup ¶
func (a *SubnetAllocator) Cleanup(mgr *Manager) error
Cleanup removes all stale subnet allocations (VMs that no longer exist).
func (*SubnetAllocator) Get ¶
func (a *SubnetAllocator) Get(vmID string) (*SubnetInfo, error)
Get retrieves subnet info for a VM.
func (*SubnetAllocator) Release ¶
func (a *SubnetAllocator) Release(vmID string) error
Release frees a subnet allocation.
type SubnetInfo ¶
type SubnetInfo struct {
Octet int `json:"octet"` // Third octet (e.g., 100 for 192.168.100.0/24)
GatewayIP string `json:"gateway_ip"` // Host TAP IP (e.g., 192.168.100.1)
GuestIP string `json:"guest_ip"` // Guest IP (e.g., 192.168.100.2)
Subnet string `json:"subnet"` // CIDR notation (e.g., 192.168.100.0/24)
VMID string `json:"vm_id"`
}
Click to show internal directories.
Click to hide internal directories.