Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/oci/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ const (
// AnnotationVPMemNoMultiMapping indicates that we should disable LCOW vpmem layer multi mapping
AnnotationVPMemNoMultiMapping = "io.microsoft.virtualmachine.lcow.vpmem.nomultimapping"

// AnnotationKernelBootOptions is used to specify kernel options used while booting a linux kernel
AnnotationKernelBootOptions = "io.microsoft.virtualmachine.lcow.kernelbootoptions"

// AnnotationStorageQoSBandwidthMaximum indicates the maximum number of bytes per second. If `0`
// will default to the platform default.
AnnotationStorageQoSBandwidthMaximum = "io.microsoft.virtualmachine.storageqos.bandwidthmaximum"
Expand Down
1 change: 1 addition & 0 deletions internal/oci/uvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ func SpecToUVMCreateOpts(ctx context.Context, s *specs.Spec, id, owner string) (
lopts.CPUGroupID = parseAnnotationsString(s.Annotations, AnnotationCPUGroupID, lopts.CPUGroupID)
lopts.NetworkConfigProxy = parseAnnotationsString(s.Annotations, AnnotationNetworkConfigProxy, lopts.NetworkConfigProxy)
lopts.SecurityPolicy = parseAnnotationsString(s.Annotations, AnnotationSecurityPolicy, lopts.SecurityPolicy)
lopts.KernelBootOptions = parseAnnotationsString(s.Annotations, AnnotationKernelBootOptions, lopts.KernelBootOptions)

handleAnnotationPreferredRootFSType(ctx, s.Annotations, lopts)
handleAnnotationKernelDirectBoot(ctx, s.Annotations, lopts)
Expand Down
1 change: 1 addition & 0 deletions internal/uvm/create_lcow.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ func CreateLCOW(ctx context.Context, opts *OptionsLCOW) (_ *UtilityVM, err error
kernelArgs += " panic=-1 quiet"
}

// Add Kernel Boot options
if opts.KernelBootOptions != "" {
kernelArgs += " " + opts.KernelBootOptions
}
Expand Down
29 changes: 29 additions & 0 deletions test/cri-containerd/runpodsandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1327,3 +1327,32 @@ func createSandboxContainerAndExec(t *testing.T, annotations map[string]string,

return output, errorMsg, exitCode
}

func Test_RunPodSandbox_KernelOptions_LCOW(t *testing.T) {
requireFeatures(t, featureLCOW)

pullRequiredLcowImages(t, []string{imageLcowK8sPause, imageLcowAlpine})

annotations := map[string]string{
oci.AnnotationFullyPhysicallyBacked: "true",
oci.AnnotationMemorySizeInMB: "2048",
oci.AnnotationKernelBootOptions: "hugepagesz=2M hugepages=10",
}

hugePagesCmd := []string{"grep", "-i", "HugePages_Total", "/proc/meminfo"}
output, errorMsg, exitCode := createSandboxContainerAndExec(t, annotations, nil, hugePagesCmd)

if exitCode != 0 {
t.Fatalf("Exec into container failed with: %v and exit code: %d, %s", errorMsg, exitCode, t.Name())
}

splitOutput := strings.Split(output, ":")
numOfHugePages, err := strconv.Atoi(strings.TrimSpace(splitOutput[1]))
if err != nil {
t.Fatalf("Error happened while extracting number of hugepages: %v from output : %s", err, output)
}

if numOfHugePages != 10 {
t.Fatalf("Expected number of hugepages to be 10. Got output instead: %d", numOfHugePages)
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.