From 9621c596914c40245ce49d95bfa421f57304132a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 24 Feb 2022 11:26:57 +0100 Subject: [PATCH] clh: refactor image / initrd configuration set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a small code refactor removing a deadcode based the checks already done in the generic hypervisor abstraction. Signed-off-by: Fabiano FidĂȘncio --- src/runtime/virtcontainers/clh.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 0dc478e7eb..e81e34fcdc 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -289,11 +289,6 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net return err } - initrdPath, err := clh.config.InitrdAssetPath() - if err != nil { - return err - } - if imagePath != "" { pmem := chclient.NewPmemConfig(imagePath) *pmem.DiscardWrites = true @@ -303,12 +298,15 @@ func (clh *cloudHypervisor) CreateVM(ctx context.Context, id string, network Net } else { clh.vmconfig.Pmem = &[]chclient.PmemConfig{*pmem} } - } else if initrdPath != "" { + } else { + initrdPath, err := clh.config.InitrdAssetPath() + if err != nil { + return err + } + initrd := chclient.NewInitramfsConfig(initrdPath) clh.vmconfig.SetInitramfs(*initrd) - } else { - return errors.New("no image or initrd specified") } // Use serial port as the guest console only in debug mode,