runtime: vCPUs pinning is sandbox specific, not hypervisor

While at it, make sure we persist this and fix a misc typo.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
Eric Ernst
2023-01-11 16:25:44 -08:00
parent e3d3b72fa2
commit 6ee550e9a5
8 changed files with 32 additions and 23 deletions

View File

@@ -575,9 +575,6 @@ type HypervisorConfig struct {
// Use legacy serial for the guest console
LegacySerial bool
// EnableVCPUsPinning controls whether each vCPU thread should be scheduled to a fixed CPU
EnableVCPUsPinning bool
}
// vcpu mapping from vcpu number to thread number

View File

@@ -189,6 +189,7 @@ func (s *Sandbox) dumpConfig(ss *persistapi.SandboxState) {
SystemdCgroup: sconfig.SystemdCgroup,
SandboxCgroupOnly: sconfig.SandboxCgroupOnly,
DisableGuestSeccomp: sconfig.DisableGuestSeccomp,
EnableVCPUsPinning: sconfig.EnableVCPUsPinning,
GuestSeLinuxLabel: sconfig.GuestSeLinuxLabel,
}
@@ -430,6 +431,7 @@ func loadSandboxConfig(id string) (*SandboxConfig, error) {
SystemdCgroup: savedConf.SystemdCgroup,
SandboxCgroupOnly: savedConf.SandboxCgroupOnly,
DisableGuestSeccomp: savedConf.DisableGuestSeccomp,
EnableVCPUsPinning: savedConf.EnableVCPUsPinning,
GuestSeLinuxLabel: savedConf.GuestSeLinuxLabel,
}
sconfig.SandboxBindMounts = append(sconfig.SandboxBindMounts, savedConf.SandboxBindMounts...)

View File

@@ -288,4 +288,7 @@ type SandboxConfig struct {
SandboxCgroupOnly bool
DisableGuestSeccomp bool
// EnableVCPUsPinning controls whether each vCPU thread should be scheduled to a fixed CPU
EnableVCPUsPinning bool
}

View File

@@ -143,9 +143,6 @@ const (
// DefaultVCPUs is a sandbox annotation that specifies the maximum number of vCPUs allocated for the VM by the hypervisor.
DefaultMaxVCPUs = kataAnnotHypervisorPrefix + "default_max_vcpus"
// EnableVCPUsPinning is a sandbox annotation that controls bundling between vCPU threads and CPUs
EnableVCPUsPinning = kataAnnotationsPrefix + "enable_vcpus_pinning"
//
// Memory related annotations
//
@@ -253,6 +250,9 @@ const (
// SandboxCgroupOnly is a sandbox annotation that determines if kata processes are managed only in sandbox cgroup.
SandboxCgroupOnly = kataAnnotRuntimePrefix + "sandbox_cgroup_only"
// EnableVCPUsPinning is a sandbox annotation that controls bundling between vCPU threads and CPUs
EnableVCPUsPinning = kataAnnotationsPrefix + "enable_vcpus_pinning"
// EnablePprof is a sandbox annotation that determines if pprof enabled.
EnablePprof = kataAnnotRuntimePrefix + "enable_pprof"

View File

@@ -178,7 +178,11 @@ type SandboxConfig struct {
// SandboxCgroupOnly enables cgroup only at podlevel in the host
SandboxCgroupOnly bool
// DisableGuestSeccomp disable seccomp within the guest
DisableGuestSeccomp bool
// EnableVCPUsPinning controls whether each vCPU thread should be scheduled to a fixed CPU
EnableVCPUsPinning bool
}
// valid checks that the sandbox configuration is valid.
@@ -2508,9 +2512,9 @@ func (s *Sandbox) fetchContainers(ctx context.Context) error {
// is then pinned to one fixed CPU in CPUSet.
func (s *Sandbox) checkVCPUsPinning(ctx context.Context) error {
if s.config == nil {
return fmt.Errorf("no hypervisor config found")
return fmt.Errorf("no sandbox config found")
}
if !s.config.HypervisorConfig.EnableVCPUsPinning {
if !s.config.EnableVCPUsPinning {
return nil
}