mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-22 19:23:24 +00:00
Merge pull request #9231 from UiPath/fix/clh-pid-init
clh: initialize clh pid before using it
This commit is contained in:
commit
a31fb35e5d
@ -708,11 +708,10 @@ func (clh *cloudHypervisor) StartVM(ctx context.Context, timeout int) error {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
pid, err := clh.launchClh()
|
err = clh.launchClh()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to launch cloud-hypervisor: %q", err)
|
return fmt.Errorf("failed to launch cloud-hypervisor: %q", err)
|
||||||
}
|
}
|
||||||
clh.state.PID = pid
|
|
||||||
|
|
||||||
bootTimeout := clh.getClhAPITimeout()
|
bootTimeout := clh.getClhAPITimeout()
|
||||||
if bootTimeout < clhCreateAndBootVMMinimumTimeout {
|
if bootTimeout < clhCreateAndBootVMMinimumTimeout {
|
||||||
@ -1344,11 +1343,13 @@ func (clh *cloudHypervisor) clhPath() (string, error) {
|
|||||||
return p, err
|
return p, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (clh *cloudHypervisor) launchClh() (int, error) {
|
func (clh *cloudHypervisor) launchClh() error {
|
||||||
|
|
||||||
|
clh.state.PID = -1
|
||||||
|
|
||||||
clhPath, err := clh.clhPath()
|
clhPath, err := clh.clhPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
args := []string{cscAPIsocket, clh.state.apiSocket}
|
args := []string{cscAPIsocket, clh.state.apiSocket}
|
||||||
@ -1406,15 +1407,17 @@ func (clh *cloudHypervisor) launchClh() (int, error) {
|
|||||||
|
|
||||||
err = utils.StartCmd(cmdHypervisor)
|
err = utils.StartCmd(cmdHypervisor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clh.state.PID = cmdHypervisor.Process.Pid
|
||||||
|
|
||||||
if err := clh.waitVMM(clhTimeout); err != nil {
|
if err := clh.waitVMM(clhTimeout); err != nil {
|
||||||
clh.Logger().WithError(err).Warn("cloud-hypervisor init failed")
|
clh.Logger().WithError(err).Warn("cloud-hypervisor init failed")
|
||||||
return -1, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmdHypervisor.Process.Pid, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//###########################################################################
|
//###########################################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user