mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
runtime: clh: Use the new 'payload' interface
The new 'payload' interface now contains the 'kernel' and 'initramfs' config. Fixes: #4952 Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
16baecc5b1
commit
3a597c2742
@ -459,13 +459,15 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net
|
|||||||
// to fetch if this is the first time the hypervisor is created.
|
// to fetch if this is the first time the hypervisor is created.
|
||||||
clh.Logger().WithField("function", "CreateVM").Info("Sandbox not found creating")
|
clh.Logger().WithField("function", "CreateVM").Info("Sandbox not found creating")
|
||||||
|
|
||||||
|
// Create the VM config via the constructor to ensure default values are properly assigned
|
||||||
|
clh.vmconfig = *chclient.NewVmConfig(*chclient.NewPayloadConfig())
|
||||||
|
|
||||||
// Make sure the kernel path is valid
|
// Make sure the kernel path is valid
|
||||||
kernelPath, err := clh.config.KernelAssetPath()
|
kernelPath, err := clh.config.KernelAssetPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Create the VM config via the constructor to ensure default values are properly assigned
|
clh.vmconfig.Payload.SetKernel(kernelPath)
|
||||||
clh.vmconfig = *chclient.NewVmConfig(*chclient.NewKernelConfig(kernelPath))
|
|
||||||
|
|
||||||
if clh.config.ConfidentialGuest {
|
if clh.config.ConfidentialGuest {
|
||||||
if err := clh.enableProtection(); err != nil {
|
if err := clh.enableProtection(); err != nil {
|
||||||
@ -505,7 +507,7 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net
|
|||||||
// Followed by extra kernel parameters defined in the configuration file
|
// Followed by extra kernel parameters defined in the configuration file
|
||||||
params = append(params, clh.config.KernelParams...)
|
params = append(params, clh.config.KernelParams...)
|
||||||
|
|
||||||
clh.vmconfig.Cmdline = chclient.NewCmdLineConfig(kernelParamsToString(params))
|
clh.vmconfig.Payload.SetCmdline(kernelParamsToString(params))
|
||||||
|
|
||||||
// set random device generator to hypervisor
|
// set random device generator to hypervisor
|
||||||
clh.vmconfig.Rng = chclient.NewRngConfig(clh.config.EntropySource)
|
clh.vmconfig.Rng = chclient.NewRngConfig(clh.config.EntropySource)
|
||||||
@ -547,9 +549,7 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
initrd := chclient.NewInitramfsConfig(initrdPath)
|
clh.vmconfig.Payload.SetInitramfs(initrdPath)
|
||||||
|
|
||||||
clh.vmconfig.SetInitramfs(*initrd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use serial port as the guest console only in debug mode,
|
// Use serial port as the guest console only in debug mode,
|
||||||
|
@ -557,7 +557,7 @@ func TestCloudHypervisorResizeMemory(t *testing.T) {
|
|||||||
clh := cloudHypervisor{}
|
clh := cloudHypervisor{}
|
||||||
|
|
||||||
mockClient := &clhClientMock{}
|
mockClient := &clhClientMock{}
|
||||||
mockClient.vmInfo.Config = *chclient.NewVmConfig(*chclient.NewKernelConfig(""))
|
mockClient.vmInfo.Config = *chclient.NewVmConfig(*chclient.NewPayloadConfig())
|
||||||
mockClient.vmInfo.Config.Memory = chclient.NewMemoryConfig(int64(utils.MemUnit(clhConfig.MemorySize) * utils.MiB))
|
mockClient.vmInfo.Config.Memory = chclient.NewMemoryConfig(int64(utils.MemUnit(clhConfig.MemorySize) * utils.MiB))
|
||||||
mockClient.vmInfo.Config.Memory.HotplugSize = func(i int64) *int64 { return &i }(int64(40 * utils.GiB.ToBytes()))
|
mockClient.vmInfo.Config.Memory.HotplugSize = func(i int64) *int64 { return &i }(int64(40 * utils.GiB.ToBytes()))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user