-
Notifications
You must be signed in to change notification settings - Fork 376
support to boot guest with an initrd image #98
Conversation
func (h hypervisor) image() (string, error) { | ||
p := h.Image | ||
|
||
if p == "" { | ||
p = defaultImagePath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're modifying the default behavior here. I am not against it, but it is worth being mentioned from the commit message I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value has to be removed because otherwise we always have ImagePath
and InitrdPath
set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's a good point, there is no reason to maintain default anymore I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I've added description of the removal in the commit message[1]. Thanks!
[1] a67e506
@@ -8,6 +8,7 @@ | |||
[hypervisor.qemu] | |||
path = "@QEMUPATH@" | |||
kernel = "@KERNELPATH@" | |||
initrd = "@INITRDPATH@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update kata-env.go
to add a [Initrd]
entry for parity with [Kernel]
and [Image]
(and bump formatVersion
to 1.0.10
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
fixing @jodh-intel and @sboeuf 's comments, lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments but globally looks good.
virtcontainers/qemu_amd64.go
Outdated
@@ -83,12 +86,12 @@ func maxQemuVCPUs() uint32 { | |||
return uint32(240) | |||
} | |||
|
|||
func newQemuArch(machineType string) qemuArch { | |||
func newQemuArch(machineType string, rootImage bool) qemuArch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you modify the function so that we directly pass the hypervisor configuration instead. This will prevent from adding some specific parameters like rootImage bool
and the check will be performed from each implementation if needed:
func newQemuArch(config HypervisorConfig) qemuArch {
...
if config.ImagePath != "" {
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
cli/create.go
Outdated
Key: "systemd.mask", | ||
Value: "systemd-networkd.socket", | ||
}, | ||
var systemdParam = []vc.Param{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/systemdParam
/systemdKernelParams
/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
cli/create.go
Outdated
} | ||
|
||
// setKernelParams adds the user-specified kernel parameters (from the | ||
// configuration file) to the defaults so that the former take priority. | ||
func setKernelParams(containerID string, runtimeConfig *oci.RuntimeConfig) error { | ||
defaultKernelParams := getKernelParamsFunc(containerID) | ||
defaultKernelParams := getKernelParamsFunc(containerID, runtimeConfig.HypervisorConfig.ImagePath != "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please get this check done outside of the function call, for readability purpose.
We should define a function:
func isInitRamFs(config vc.HypervisorConfig) bool {
if config.ImagePath == "" && config.InitrdPath != "" {
return true
}
return false
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. Thanks!
@jodh-intel @sboeuf change applied. PTAL. |
LGTM |
6773997
to
98cdfc9
Compare
Travis green. It seem jenkins is broken again. |
Thanks @bergwolf. lgtm P.S. I want that qemu command-line printed on a T-shirt! 😄 |
Once this lands, presumably, we'll want some new initrd tests to be created in https://github.com/kata-containers/tests? |
@jodh-intel Yes, we need to add some initrd tests for it. |
Hi @bergwolf. The CI is failing with a real error:
I think we need to do the following:
|
To include support for qemu initrd config. Signed-off-by: Peng Tao <bergwolf@gmail.com>
If an initrd image is configured in HypervisorConfig or passed in by annotations, append it to qemu command line arguments. Fixes: kata-containers#97 Signed-off-by: Peng Tao <bergwolf@gmail.com>
Add `initrd=[path]` option to configuration.toml and use it to set the HypervisorConfig.InitrdPath option. The default value of hypervisor image option is removed since we want to allow it to be unset. For the same reason, there is no default value for hypervisor initrd option either. Signed-off-by: Peng Tao <bergwolf@gmail.com>
Show the configured hypervisor initrd setting. Signed-off-by: Peng Tao <bergwolf@gmail.com>
For initrd based boot, we do not need the root parameters. Signed-off-by: Peng Tao <bergwolf@gmail.com>
When we install agent as init process in initrd based boot, there is no systemd to be configured. Signed-off-by: Peng Tao <bergwolf@gmail.com>
When we use initrd based booting, there is no systemd to be configured. Signed-off-by: Peng Tao <bergwolf@gmail.com>
To fix CI complains: virtcontainers/qemu.go:248::warning: cyclomatic complexity 18 of function (*qemu).createPod() is high (> 15) (gocyclo) Signed-off-by: Peng Tao <bergwolf@gmail.com>
@jodh-intel initrd is just a configuration. I don't think it needs to go into Makefile to set it. The test scripts can be tweaked to test proper targets. kata-containers/tests#172 is to enable the CI tests to do such testing properly. OTOH, do we have an equivalent way in https://github.com/kata-containers/tests that works similarly in our Jenkins setup to configure
|
hmmm, it can be set in Jenkins's job config. We can do it after this one and kata-containers/tests/pull/173 are both merged. |
Now with kata-containers/tests/pull/173, all checks passed. Merging as it is already approved. |
If an initrd image is configured in HypervisorConfig or passed in by annotations, append it to qemu command line arguments so that we boot the guest OS with the specified initrd image rather than a rootfs disk image.
A sample qemu command line: