mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 12:44:39 +00:00
annotations: add cpu_features
[ port from runtime commit f03c17d107999fd68da87d98ab3e242ac7843051 ] So that users can use annotations to set it. Signed-off-by: Jia He <justin.he@arm.com> Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
parent
fa9d619e8a
commit
115dfa19cd
@ -81,6 +81,9 @@ const (
|
|||||||
// MachineAccelerators is a sandbox annotation to specify machine specific accelerators for the hypervisor.
|
// MachineAccelerators is a sandbox annotation to specify machine specific accelerators for the hypervisor.
|
||||||
MachineAccelerators = kataAnnotHypervisorPrefix + "machine_accelerators"
|
MachineAccelerators = kataAnnotHypervisorPrefix + "machine_accelerators"
|
||||||
|
|
||||||
|
// CPUFeatures is a sandbox annotation to specify cpu specific features.
|
||||||
|
CPUFeatures = kataAnnotHypervisorPrefix + "cpu_features"
|
||||||
|
|
||||||
// DisableVhostNet is a sandbox annotation to specify if vhost-net is not available on the host.
|
// DisableVhostNet is a sandbox annotation to specify if vhost-net is not available on the host.
|
||||||
DisableVhostNet = kataAnnotHypervisorPrefix + "disable_vhost_net"
|
DisableVhostNet = kataAnnotHypervisorPrefix + "disable_vhost_net"
|
||||||
|
|
||||||
|
@ -700,6 +700,12 @@ func addHypervisporVirtioFsOverrides(ocispec specs.Spec, sbConfig *vc.SandboxCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
func addHypervisporNetworkOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig) error {
|
func addHypervisporNetworkOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig) error {
|
||||||
|
if value, ok := ocispec.Annotations[vcAnnotations.CPUFeatures]; ok {
|
||||||
|
if value != "" {
|
||||||
|
sbConfig.HypervisorConfig.CPUFeatures = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if value, ok := ocispec.Annotations[vcAnnotations.DisableVhostNet]; ok {
|
if value, ok := ocispec.Annotations[vcAnnotations.DisableVhostNet]; ok {
|
||||||
disableVhostNet, err := strconv.ParseBool(value)
|
disableVhostNet, err := strconv.ParseBool(value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -784,6 +784,7 @@ func TestAddHypervisorAnnotations(t *testing.T) {
|
|||||||
ocispec.Annotations[vcAnnotations.Msize9p] = "512"
|
ocispec.Annotations[vcAnnotations.Msize9p] = "512"
|
||||||
ocispec.Annotations[vcAnnotations.MachineType] = "q35"
|
ocispec.Annotations[vcAnnotations.MachineType] = "q35"
|
||||||
ocispec.Annotations[vcAnnotations.MachineAccelerators] = "nofw"
|
ocispec.Annotations[vcAnnotations.MachineAccelerators] = "nofw"
|
||||||
|
ocispec.Annotations[vcAnnotations.CPUFeatures] = "pmu=off"
|
||||||
ocispec.Annotations[vcAnnotations.DisableVhostNet] = "true"
|
ocispec.Annotations[vcAnnotations.DisableVhostNet] = "true"
|
||||||
ocispec.Annotations[vcAnnotations.GuestHookPath] = "/usr/bin/"
|
ocispec.Annotations[vcAnnotations.GuestHookPath] = "/usr/bin/"
|
||||||
ocispec.Annotations[vcAnnotations.UseVSock] = "true"
|
ocispec.Annotations[vcAnnotations.UseVSock] = "true"
|
||||||
@ -819,6 +820,7 @@ func TestAddHypervisorAnnotations(t *testing.T) {
|
|||||||
assert.Equal(config.HypervisorConfig.Msize9p, uint32(512))
|
assert.Equal(config.HypervisorConfig.Msize9p, uint32(512))
|
||||||
assert.Equal(config.HypervisorConfig.HypervisorMachineType, "q35")
|
assert.Equal(config.HypervisorConfig.HypervisorMachineType, "q35")
|
||||||
assert.Equal(config.HypervisorConfig.MachineAccelerators, "nofw")
|
assert.Equal(config.HypervisorConfig.MachineAccelerators, "nofw")
|
||||||
|
assert.Equal(config.HypervisorConfig.CPUFeatures, "pmu=off")
|
||||||
assert.Equal(config.HypervisorConfig.DisableVhostNet, true)
|
assert.Equal(config.HypervisorConfig.DisableVhostNet, true)
|
||||||
assert.Equal(config.HypervisorConfig.GuestHookPath, "/usr/bin/")
|
assert.Equal(config.HypervisorConfig.GuestHookPath, "/usr/bin/")
|
||||||
assert.Equal(config.HypervisorConfig.UseVSock, true)
|
assert.Equal(config.HypervisorConfig.UseVSock, true)
|
||||||
|
Loading…
Reference in New Issue
Block a user