diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index aaa8e2886a..b14391b932 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -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, diff --git a/src/runtime/virtcontainers/clh_test.go b/src/runtime/virtcontainers/clh_test.go index bb4a04925b..58b1b7fe9a 100644 --- a/src/runtime/virtcontainers/clh_test.go +++ b/src/runtime/virtcontainers/clh_test.go @@ -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()))