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:
Bo Chen 2022-08-17 12:15:04 -07:00
parent 16baecc5b1
commit 3a597c2742
2 changed files with 7 additions and 7 deletions

View File

@ -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.
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
kernelPath, err := clh.config.KernelAssetPath()
if err != nil {
return err
}
// Create the VM config via the constructor to ensure default values are properly assigned
clh.vmconfig = *chclient.NewVmConfig(*chclient.NewKernelConfig(kernelPath))
clh.vmconfig.Payload.SetKernel(kernelPath)
if clh.config.ConfidentialGuest {
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
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
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
}
initrd := chclient.NewInitramfsConfig(initrdPath)
clh.vmconfig.SetInitramfs(*initrd)
clh.vmconfig.Payload.SetInitramfs(initrdPath)
}
// Use serial port as the guest console only in debug mode,

View File

@ -557,7 +557,7 @@ func TestCloudHypervisorResizeMemory(t *testing.T) {
clh := cloudHypervisor{}
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.HotplugSize = func(i int64) *int64 { return &i }(int64(40 * utils.GiB.ToBytes()))