diff --git a/virtcontainers/clh.go b/virtcontainers/clh.go index b428b73196..47c96cfcab 100644 --- a/virtcontainers/clh.go +++ b/virtcontainers/clh.go @@ -754,7 +754,7 @@ func (clh *cloudHypervisor) LaunchClh() (string, int, error) { cmd.Env = append(cmd.Env, "RUST_BACKTRACE=full") } - if err := cmd.Start(); err != nil { + if err := utils.StartCmd(cmd); err != nil { fmt.Println("Error starting cloudHypervisor", err) if cmd.Process != nil { cmd.Process.Kill() diff --git a/virtcontainers/clh_test.go b/virtcontainers/clh_test.go index 3b0dc4e329..b79866e9f5 100644 --- a/virtcontainers/clh_test.go +++ b/virtcontainers/clh_test.go @@ -230,3 +230,34 @@ func TestClhCreateSandbox(t *testing.T) { assert.NoError(os.RemoveAll(parentDir)) assert.Exactly(clhConfig, clh.config) } + +func TestClooudHypervisorStartSandbox(t *testing.T) { + assert := assert.New(t) + clhConfig, err := newClhConfig() + + clh := &cloudHypervisor{ + config: clhConfig, + APIClient: &clhClientMock{}, + virtiofsd: &virtiofsdMock{}, + } + + sandbox := &Sandbox{ + ctx: context.Background(), + id: "testSandbox", + config: &SandboxConfig{ + HypervisorConfig: clhConfig, + }, + } + + vcStore, err := store.NewVCSandboxStore(sandbox.ctx, sandbox.id) + assert.NoError(err) + + sandbox.store = vcStore + + // Create parent dir path for hypervisor.json + parentDir := store.SandboxConfigurationRootPath(sandbox.id) + assert.NoError(os.MkdirAll(parentDir, store.DirMode)) + + err = clh.startSandbox(10) + assert.NoError(err) +}