Skip to content

Commit

Permalink
Merge pull request #1108 from ninzavivek/vivek_kernel_options
Browse files Browse the repository at this point in the history
Support for Kernel Boot Options - LCOW
  • Loading branch information
dcantah authored Aug 13, 2021
2 parents bd67428 + ad0eaf3 commit 3ac13ee
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 0 deletions.
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.

0 comments on commit 3ac13ee

Please sign in to comment.