Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PauseVM and ResumeVM support #460

Merged
merged 4 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ $(FIREWALL_BIN):

TC_REDIRECT_TAP_BIN?=$(BINPATH)/tc-redirect-tap
$(TC_REDIRECT_TAP_BIN):
GOBIN=$(dir $@) go install github.com/firecracker-microvm/firecracker-go-sdk/cni/cmd/tc-redirect-tap
GOBIN=$(dir $@) go install github.com/awslabs/tc-redirect-tap/cmd/tc-redirect-tap

TEST_BRIDGED_TAP_BIN?=$(BINPATH)/test-bridged-tap
$(TEST_BRIDGED_TAP_BIN): $(shell find internal/cmd/test-bridged-tap -name *.go) $(GOMOD) $(GOSUM)
Expand Down
36 changes: 36 additions & 0 deletions firecracker-control/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,42 @@ func (s *local) StopVM(requestCtx context.Context, req *proto.StopVMRequest) (*e
return resp, multierror.Append(shimErr, waitErr).ErrorOrNil()
}

// PauseVM pauses a VM
func (s *local) PauseVM(ctx context.Context, req *proto.PauseVMRequest) (*empty.Empty, error) {
client, err := s.shimFirecrackerClient(ctx, req.VMID)
if err != nil {
return nil, err
}

defer client.Close()

resp, err := client.PauseVM(ctx, req)
if err != nil {
s.logger.WithError(err).Error()
return nil, err
}

return resp, nil
}

// ResumeVM resumes a VM
func (s *local) ResumeVM(ctx context.Context, req *proto.ResumeVMRequest) (*empty.Empty, error) {
client, err := s.shimFirecrackerClient(ctx, req.VMID)
if err != nil {
return nil, err
}

defer client.Close()

resp, err := client.ResumeVM(ctx, req)
if err != nil {
s.logger.WithError(err).Error()
return nil, err
}

return resp, nil
}

func (s *local) waitForShimToExit(ctx context.Context, vmID string) error {
socketAddr, err := fcShim.SocketAddress(ctx, vmID)
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions firecracker-control/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ func (s *service) CreateVM(ctx context.Context, req *proto.CreateVMRequest) (*pr
return s.local.CreateVM(ctx, req)
}

func (s *service) PauseVM(ctx context.Context, req *proto.PauseVMRequest) (*empty.Empty, error) {
log.G(ctx).Debugf("pause VM request: %+v", req)
return s.local.PauseVM(ctx, req)
}

func (s *service) ResumeVM(ctx context.Context, req *proto.ResumeVMRequest) (*empty.Empty, error) {
log.G(ctx).Debugf("resume VM request: %+v", req)
return s.local.ResumeVM(ctx, req)
}

func (s *service) StopVM(ctx context.Context, req *proto.StopVMRequest) (*empty.Empty, error) {
log.G(ctx).Debugf("stop VM: %+v", req)
return s.local.StopVM(ctx, req)
Expand Down
13 changes: 7 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/firecracker-microvm/firecracker-containerd
require (
github.com/Microsoft/go-winio v0.4.14 // indirect
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
github.com/awslabs/tc-redirect-tap v0.0.0-20200708224642-a0300978797d
github.com/containerd/cgroups v0.0.0-20181105182409-82cb49fc1779 // indirect
github.com/containerd/console v0.0.0-20191219165238-8375c3424e4d // indirect
github.com/containerd/containerd v1.3.8-0.20200824223617-f99bb2cc4483
Expand All @@ -11,21 +12,21 @@ require (
github.com/containerd/go-runc v0.0.0-20190226155025-7d11b49dc076
github.com/containerd/ttrpc v0.0.0-20190613183316-1fb3814edf44
github.com/containerd/typeurl v0.0.0-20181015155603-461401dc8f19
github.com/containernetworking/cni v0.7.2-0.20190807151350-8c6c47d1c7fc
github.com/containernetworking/plugins v0.8.6
github.com/containernetworking/cni v0.8.0
github.com/containernetworking/plugins v0.8.7
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/go-events v0.0.0-20170721190031-9461782956ad // indirect
github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 // indirect
github.com/firecracker-microvm/firecracker-go-sdk v0.21.1-0.20200811001213-ee1e7c41b7bd
github.com/firecracker-microvm/firecracker-go-sdk v0.22.1-0.20201117001223-cd822c0d457c
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/godbus/dbus v0.0.0-20181025153459-66d97aec3384 // indirect
github.com/gofrs/uuid v3.3.0+incompatible
github.com/gogo/googleapis v1.1.0 // indirect
github.com/gogo/protobuf v1.3.0
github.com/golang/protobuf v1.3.1
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/go-multierror v1.1.0
github.com/imdario/mergo v0.3.8 // indirect
github.com/mdlayher/vsock v0.0.0-20190329173812-a92c53d5dcab
github.com/miekg/dns v1.1.16
Expand All @@ -37,13 +38,13 @@ require (
github.com/prometheus/client_golang v0.9.2 // indirect
github.com/shirou/gopsutil v2.18.12+incompatible
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/sirupsen/logrus v1.6.0
github.com/sirupsen/logrus v1.7.0
github.com/stretchr/testify v1.6.1
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 // indirect
github.com/urfave/cli v1.20.0 // indirect
github.com/vishvananda/netlink v1.1.0
go.etcd.io/bbolt v1.3.1-etcd.8 // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
google.golang.org/genproto v0.0.0-20181109154231-b5d43981345b // indirect
google.golang.org/grpc v1.21.0
Expand Down
Loading