diff --git a/virtcontainers/clh.go b/virtcontainers/clh.go index 4561220162..3dd1da84ca 100644 --- a/virtcontainers/clh.go +++ b/virtcontainers/clh.go @@ -756,7 +756,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 8bd9870dad..0d336ae005 100644 --- a/virtcontainers/clh_test.go +++ b/virtcontainers/clh_test.go @@ -233,3 +233,35 @@ 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() + assert.NoError(err) + + 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) +}