network

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// NetQueueSize: default virtio-net ring depth per queue; 512 balances throughput vs request latency.
	NetQueueSize = 512
)

Variables

View Source
var (
	ErrNotFound      = errors.New("network not found")
	ErrNotConfigured = errors.New("network provider not configured")
)

Functions

func NetNumQueues added in v0.3.2

func NetNumQueues(cpu int) int

NetNumQueues returns the virtio-net queue count for the given CPU count. CH uses queue pairs (TX+RX), so the result is always even (≥ 2).

func ResolveQueueSize added in v0.3.2

func ResolveQueueSize(qs int) int

ResolveQueueSize returns qs if non-zero, otherwise the default NetQueueSize. Negative values aren't reachable from validated callers.

func TuneTAP added in v0.3.2

func TuneTAP(link netlink.Link) error

TuneTAP applies best-effort performance tuning to a TAP device.

func VMIDPrefix added in v0.3.2

func VMIDPrefix(vmID string) string

VMIDPrefix returns the first 8 characters of a VM ID, matching the truncation used by both bridge and CNI TAP device naming.

Types

type AddSpec added in v0.4.0

type AddSpec struct {
	Index    int
	Existing *types.NetworkConfig
}

AddSpec is one NIC's add request; Existing != nil reuses MAC/IP for recovery.

func AddRange added in v0.4.0

func AddRange(from, count int) []AddSpec

AddRange builds AddSpecs for a contiguous block of fresh NIC indices.

func AddRecover added in v0.4.0

func AddRecover(existing []*types.NetworkConfig) []AddSpec

AddRecover builds AddSpecs for re-creating existing NICs (post-reboot recovery).

type Network

type Network interface {
	Type() string
	Verify(ctx context.Context, vmID string) error
	// Prepare provisions per-VM state; returns the netns path or "".
	Prepare(ctx context.Context, vmID string, vmCfg *types.VMConfig) (string, error)
	Add(ctx context.Context, vmID string, vmCfg *types.VMConfig, specs ...AddSpec) ([]*types.NetworkConfig, error)
	Remove(ctx context.Context, vmID string, indices ...int) error
	Delete(context.Context, []string) ([]string, error)
	Inspect(context.Context, string) (*types.Network, error)
	List(context.Context) ([]*types.Network, error)
	RegisterGC(*gc.Orchestrator)
}

Network is the per-VM host-side networking provider (CNI, bridge, ...).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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