Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

config: support kernel parameters #369

Merged
merged 1 commit into from Aug 8, 2017
Merged

config: support kernel parameters #369

merged 1 commit into from Aug 8, 2017

Conversation

wcwxyz
Copy link
Contributor

@wcwxyz wcwxyz commented Jul 28, 2017

Add support to pass extra kernel parameters in configuration.

The story behind this feature is, I have trouble running centos:6
/bin/bash and it turns out guest kernel is using vsyscall=none which
breaks old libc.

Fixes: #368

Signed-off-by: WANG Chao chao.wang@ucloud.cn

@coveralls
Copy link

coveralls commented Jul 28, 2017

Coverage Status

Coverage decreased (-0.3%) to 53.195% when pulling 36c9d44 on wcwxyz:config-kernel-params into df043b1 on clearcontainers:master.

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @wcwxyz - thanks for raising this! The code looks good, but there are a few tweaks to do to update cc-env output and add some tests.

Also, note that the runtime is failing under SemaphoreCI with these changes, so that will need a bit of debugging.

I'm going to mark this PR as needing changes as a result.

Please let us know if you need any help with any of the above (and don't worry about the big red cross! 😄

config.go Outdated
@@ -122,6 +124,31 @@ func (h hypervisor) image() string {
return h.Image
}

func (h hypervisor) kernelParams() []vc.Param {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you add some tests to TestHypervisorDefaults() for this new function.

config.go Outdated
return deserializeParams(h.KernelParams)
}

func deserializeParams(paramString string) []vc.Param {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a test too.

config.go Outdated
@@ -193,6 +221,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
HypervisorPath: hypervisor,
KernelPath: kernel,
ImagePath: image,
KernelParams: kernelParams,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cc-env command should display the kernel params too. See commit 257b46a for an example of adding extra details to the cc-env output (you'll need to update the formatVersion as that commit did).

@@ -4,6 +4,8 @@
path = "@QEMUPATH@"
kernel = "@KERNELPATH@"
image = "@IMAGEPATH@"
# Uncomment if having trouble running pre-2.15 glibc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to say, please can you add a comment stating the format of this variable. For example, it could become something like this:

# Optional space-separated list of options to pass to the guest kernel.
# For example, uncomment the line below if you are having trouble running pre-2.15 glibc
## kernel_params = "vsyscall=emulate"

@wcwxyz
Copy link
Contributor Author

wcwxyz commented Jul 28, 2017

I will update according to your comment. Thanks for review.

@coveralls
Copy link

coveralls commented Jul 31, 2017

Coverage Status

Coverage increased (+0.9%) to 54.398% when pulling 4e24641 on wcwxyz:config-kernel-params into df043b1 on clearcontainers:master.

Copy link
Contributor

@sboeuf sboeuf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wcwxyz The code looks very good to me. The only change I would like to see is having your changes rely as much as possible on the virtcontainers library. We already have a serializeParams in virtcontainers, and about deserializeParams, you should add it there.

config.go Outdated
return params
}

func serializeParams(params []vc.Param) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the function that already exists in virtcontainers: https://github.com/containers/virtcontainers/blob/master/hypervisor.go#L183

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to re-use such functions as much as you do.
Do you know how should I submit PRs in both virtcontainers and runtime, and have semaphoreci/travis-ci working?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the idea is that you submit the first PR to virtcontainers and after it got merged, we will revendor virtcontainers inside the runtime repository so that you can rely on the new function you have just created.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good to know. Thank you.

config.go Outdated
return h.KernelParams
}

func deserializeParams(paramString string) []vc.Param {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create this function in virtcontainers as it can be reused by any consumer of the virtcontainers library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

@sboeuf
Copy link
Contributor

sboeuf commented Aug 5, 2017

@wcwxyz I have updated the vendoring of virtcontainers for the runtime. You can now modify this PR so that it relies on the patch that you submitted to virtcontainers ;)

@wcwxyz
Copy link
Contributor Author

wcwxyz commented Aug 7, 2017

Re-pushed(No code changes). Please take a look. Thanks.

@coveralls
Copy link

coveralls commented Aug 7, 2017

Coverage Status

Coverage increased (+0.3%) to 55.441% when pulling 4f10446 on wcwxyz:config-kernel-params into 1ec2462 on clearcontainers:master.

cc-env.go Outdated
Hypervisor: hypervisor,
Image: image,
Kernel: kernel,
KernelParams: kernelParams,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running cc-runtime cc-env gives the following:

[Kernel]
  Path = "/usr/share/clear-containers/vmlinux.container"
  Resolved = "/usr/share/clear-containers/vmlinux-4.9.35-62.container"

[KernelParams]
  Parameters = ""

But what we really want is:

[Kernel]
  [Kernel.Location]
    Path = "/usr/share/clear-containers/vmlinux.container"
    Resolved = "/usr/share/clear-containers/vmlinux-4.9.35-62.container"
  Parameters = ""

That way, all the kernel details are kept under Kernel. This is also in line with what we already have for Hypervisor:

[Hypervisor]
  MachineType = "pc-lite"
  [Hypervisor.Location]
    Path = "/usr/bin/qemu-lite-system-x86_64"
    Resolved = "/usr/bin/qemu-lite-system-x86_64"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will do.

Add support to pass extra kernel parameters in configuration or directly
configured on build. This information can be retrieved from cc-env.

The story behind this feature is, I have trouble running centos:6
/bin/bash and it turns out guest kernel is using vsyscall=none which
breaks old libc.

Fixes: #368

Signed-off-by: WANG Chao <chao.wang@ucloud.cn>
@coveralls
Copy link

coveralls commented Aug 8, 2017

Coverage Status

Coverage increased (+0.3%) to 55.39% when pulling 528772f on wcwxyz:config-kernel-params into bcfc581 on clearcontainers:master.

@jodh-intel
Copy link
Contributor

@wcwxyz - great! Thanks for making these changes.

@sboeuf - could you re-review please?

@sboeuf
Copy link
Contributor

sboeuf commented Aug 8, 2017

LGTM

@jodh-intel
Copy link
Contributor

It looks like one of the cri-o tests is problematic under semaphore. I've raised clearcontainers/tests#326 to investigate that issue.

@jodh-intel jodh-intel merged commit 939f7e3 into clearcontainers:master Aug 8, 2017
mcastelino pushed a commit to mcastelino/runtime that referenced this pull request Dec 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants