Documentation
¶
Index ¶
- Variables
- func MergeKernelArgs(base string, extras ...string) string
- type ActiveBallooningConfig
- type BalloonVM
- type Controller
- type Features
- type GaugeObservation
- type HostPressureSample
- type HostPressureState
- type KernelPageInitMode
- type ManualReclaimAction
- type ManualReclaimRequest
- type ManualReclaimResponse
- type Metrics
- func (m *Metrics) RecordGaugeState(ctx context.Context, obs GaugeObservation)
- func (m *Metrics) RecordPressureTransition(ctx context.Context, from, to HostPressureState)
- func (m *Metrics) RecordReclaimAction(ctx context.Context, trigger, status string, hvType hypervisor.Type)
- func (m *Metrics) RecordReclaimBytes(ctx context.Context, trigger, kind string, bytes int64)
- func (m *Metrics) RecordReconcile(ctx context.Context, trigger, status string, duration time.Duration)
- func (m *Metrics) RecordSamplerError(ctx context.Context, sampler string)
- type Policy
- type PressureSampler
- type Source
Constants ¶
This section is empty.
Variables ¶
var ( ErrActiveBallooningDisabled = errors.New("active ballooning is disabled") ErrGuestMemoryDisabled = errors.New("guest memory reclaim is disabled") )
Functions ¶
func MergeKernelArgs ¶
MergeKernelArgs merges kernel args deterministically. Duplicate keys are de-duplicated with "last write wins" semantics.
Types ¶
type ActiveBallooningConfig ¶
type ActiveBallooningConfig struct {
Enabled bool
PollInterval time.Duration
PressureHighWatermarkAvailablePercent int
PressureLowWatermarkAvailablePercent int
ProtectedFloorPercent int
ProtectedFloorMinBytes int64
MinAdjustmentBytes int64
PerVMMaxStepBytes int64
PerVMCooldown time.Duration
}
ActiveBallooningConfig controls host-driven balloon reclaim behavior.
func DefaultActiveBallooningConfig ¶
func DefaultActiveBallooningConfig() ActiveBallooningConfig
DefaultActiveBallooningConfig returns conservative defaults for active reclaim.
func (ActiveBallooningConfig) Normalize ¶
func (c ActiveBallooningConfig) Normalize() ActiveBallooningConfig
Normalize applies defaults and clamps invalid values.
type BalloonVM ¶
type BalloonVM struct {
ID string
Name string
HypervisorType hypervisor.Type
SocketPath string
AssignedMemoryBytes int64
}
BalloonVM describes a running VM that may participate in reclaim.
type Controller ¶
type Controller interface {
Start(ctx context.Context) error
TriggerReclaim(ctx context.Context, req ManualReclaimRequest) (ManualReclaimResponse, error)
}
Controller coordinates automatic and manual reclaim.
func NewController ¶
func NewController(policy Policy, cfg ActiveBallooningConfig, source Source, log *slog.Logger) Controller
NewController creates the active ballooning controller.
func NewControllerWithSampler ¶
func NewControllerWithSampler(policy Policy, cfg ActiveBallooningConfig, source Source, sampler PressureSampler, log *slog.Logger) Controller
NewControllerWithSampler creates the active ballooning controller with an injected host pressure sampler. This is primarily useful for tests that need deterministic reclaim behavior.
type Features ¶
type Features struct {
EnableBalloon bool
FreePageReporting bool
DeflateOnOOM bool
FreePageHinting bool
RequireBalloon bool
}
Features are generic guest memory toggles consumed by hypervisor backends.
type GaugeObservation ¶
type HostPressureSample ¶
type HostPressureSample struct {
TotalBytes int64
AvailableBytes int64
AvailablePercent float64
Stressed bool
}
HostPressureSample captures the host memory snapshot used for reclaim decisions.
type HostPressureState ¶
type HostPressureState string
HostPressureState summarizes host memory pressure.
const ( HostPressureStateHealthy HostPressureState = "healthy" HostPressureStatePressure HostPressureState = "pressure" )
type KernelPageInitMode ¶
type KernelPageInitMode string
KernelPageInitMode controls guest kernel page initialization behavior.
const ( // KernelPageInitPerformance minimizes guest page touching to preserve lazy host allocation. KernelPageInitPerformance KernelPageInitMode = "performance" // KernelPageInitHardened enforces page init-on-alloc/free hardening in the guest kernel. KernelPageInitHardened KernelPageInitMode = "hardened" )
type ManualReclaimAction ¶
type ManualReclaimAction struct {
InstanceID string
InstanceName string
Hypervisor hypervisor.Type
AssignedMemoryBytes int64
ProtectedFloorBytes int64
PreviousTargetGuestMemoryBytes int64
PlannedTargetGuestMemoryBytes int64
TargetGuestMemoryBytes int64
AppliedReclaimBytes int64
Status string
Error string
}
ManualReclaimAction captures one VM's reclaim plan/result.
type ManualReclaimRequest ¶
type ManualReclaimRequest struct {
ReclaimBytes int64
HoldFor time.Duration
DryRun bool
Reason string
}
ManualReclaimRequest triggers a proactive reclaim cycle.
type ManualReclaimResponse ¶
type ManualReclaimResponse struct {
RequestedReclaimBytes int64
PlannedReclaimBytes int64
AppliedReclaimBytes int64
HoldUntil *time.Time
HostAvailableBytes int64
HostPressureState HostPressureState
Actions []ManualReclaimAction
}
ManualReclaimResponse summarizes the last reconcile result.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func (*Metrics) RecordGaugeState ¶
func (m *Metrics) RecordGaugeState(ctx context.Context, obs GaugeObservation)
func (*Metrics) RecordPressureTransition ¶
func (m *Metrics) RecordPressureTransition(ctx context.Context, from, to HostPressureState)
func (*Metrics) RecordReclaimAction ¶
func (*Metrics) RecordReclaimBytes ¶
func (*Metrics) RecordReconcile ¶
type Policy ¶
type Policy struct {
Enabled bool
KernelPageInitMode KernelPageInitMode
ReclaimEnabled bool
VZBalloonRequired bool
}
Policy is the normalized, hypervisor-agnostic guest memory policy.
func DefaultPolicy ¶
func DefaultPolicy() Policy
DefaultPolicy returns conservative defaults (disabled reclaim, hardened page-init mode).
func (Policy) FeaturesForHypervisor ¶
FeaturesForHypervisor returns generic memory features for backend translation.
func (Policy) KernelArgs ¶
KernelArgs returns kernel args implied by the policy.
type PressureSampler ¶
type PressureSampler interface {
Sample(ctx context.Context) (HostPressureSample, error)
}
PressureSampler provides host memory pressure samples.