Documentation
¶
Index ¶
Constants ¶
const (
// NetQueueSize: default virtio-net ring depth per queue; 512 balances throughput vs request latency.
NetQueueSize = 512
)
Variables ¶
var ( ErrNotFound = errors.New("network not found") ErrNotConfigured = errors.New("network provider not configured") )
Functions ¶
func NetNumQueues ¶ added in v0.3.2
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
ResolveQueueSize returns qs if non-zero, otherwise the default NetQueueSize. Negative values aren't reachable from validated callers.
func VMIDPrefix ¶ added in v0.3.2
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
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, ...).