mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-13 15:14:08 +00:00
cli: only set systemd related kernel parameters when needed
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>
This commit is contained in:
parent
463e6dee0b
commit
38af66ca39
@ -152,8 +152,7 @@ func create(containerID, bundlePath, console, pidFilePath string, detach bool,
|
||||
return createPIDFile(pidFilePath, process.Pid)
|
||||
}
|
||||
|
||||
func getKernelParams(containerID string) []vc.Param {
|
||||
return []vc.Param{
|
||||
var systemdKernelParam = []vc.Param{
|
||||
{
|
||||
Key: "init",
|
||||
Value: "/usr/lib/systemd/systemd",
|
||||
@ -170,17 +169,31 @@ func getKernelParams(containerID string) []vc.Param {
|
||||
Key: "systemd.mask",
|
||||
Value: "systemd-networkd.socket",
|
||||
},
|
||||
}
|
||||
|
||||
func getKernelParams(containerID string, needSystemd bool) []vc.Param {
|
||||
p := []vc.Param{
|
||||
{
|
||||
Key: "ip",
|
||||
Value: fmt.Sprintf("::::::%s::off::", containerID),
|
||||
},
|
||||
}
|
||||
|
||||
if needSystemd {
|
||||
p = append(p, systemdKernelParam...)
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func needSystemd(config vc.HypervisorConfig) bool {
|
||||
return config.ImagePath != ""
|
||||
}
|
||||
|
||||
// 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, needSystemd(runtimeConfig.HypervisorConfig))
|
||||
|
||||
if runtimeConfig.HypervisorConfig.Debug {
|
||||
strParams := vc.SerializeParams(defaultKernelParams, "=")
|
||||
|
@ -861,7 +861,7 @@ func TestCreateInvalidKernelParams(t *testing.T) {
|
||||
getKernelParamsFunc = savedFunc
|
||||
}()
|
||||
|
||||
getKernelParamsFunc = func(containerID string) []vc.Param {
|
||||
getKernelParamsFunc = func(containerID string, needSystemd bool) []vc.Param {
|
||||
return []vc.Param{
|
||||
{
|
||||
Key: "",
|
||||
|
Loading…
Reference in New Issue
Block a user