Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
api: add sandbox pause and resume API
Browse files Browse the repository at this point in the history
By exporting the existing sandbox operations.

Signed-off-by: Peng Tao <[email protected]>
  • Loading branch information
bergwolf committed Apr 24, 2018
1 parent eb23771 commit 5165de0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions virtcontainers/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type VCSandbox interface {
ID() string
SetAnnotations(annotations map[string]string) error

Pause() error
Resume() error
Release() error
}

Expand Down
10 changes: 10 additions & 0 deletions virtcontainers/pkg/vcmock/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,13 @@ func (p *Sandbox) GetContainer(containerID string) vc.VCContainer {
func (p *Sandbox) Release() error {
return nil
}

// Pause implements the VCSandbox function of the same name.
func (p *Sandbox) Pause() error {
return nil
}

// Resume implements the VCSandbox function of the same name.
func (p *Sandbox) Resume() error {
return nil
}
10 changes: 6 additions & 4 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,15 +929,17 @@ func (s *Sandbox) stop() error {
return s.setSandboxState(StateStopped)
}

func (s *Sandbox) pause() error {
// Pause pauses the sandbox
func (s *Sandbox) Pause() error {
if err := s.hypervisor.pauseSandbox(); err != nil {
return err
}

return s.pauseSetStates()
}

func (s *Sandbox) resume() error {
// Resume resumes the sandbox
func (s *Sandbox) Resume() error {
if err := s.hypervisor.resumeSandbox(); err != nil {
return err
}
Expand Down Expand Up @@ -1079,9 +1081,9 @@ func togglePauseSandbox(sandboxID string, pause bool) (*Sandbox, error) {
}

if pause {
err = p.pause()
err = p.Pause()
} else {
err = p.resume()
err = p.Resume()
}

if err != nil {
Expand Down

0 comments on commit 5165de0

Please sign in to comment.