Skip to content

Commit 775734f

Browse files
committed
update proto and add pause, resume
Signed-off-by: Plamen Petrov <[email protected]>
1 parent 056fce3 commit 775734f

File tree

11 files changed

+333
-81
lines changed

11 files changed

+333
-81
lines changed

Makefile

+1-5
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,13 @@ FIREWALL_BIN?=$(BINPATH)/firewall
235235
$(FIREWALL_BIN):
236236
GOBIN=$(dir $@) GO111MODULE=off go get -u github.com/containernetworking/plugins/plugins/meta/firewall
237237

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

242239
TEST_BRIDGED_TAP_BIN?=$(BINPATH)/test-bridged-tap
243240
$(TEST_BRIDGED_TAP_BIN): $(shell find internal/cmd/test-bridged-tap -name *.go) $(GOMOD) $(GOSUM)
244241
go build -o $@ $(CURDIR)/internal/cmd/test-bridged-tap
245242

246243
.PHONY: cni-bins
247-
cni-bins: $(BRIDGE_BIN) $(PTP_BIN) $(HOSTLOCAL_BIN) $(FIREWALL_BIN) $(TC_REDIRECT_TAP_BIN)
244+
cni-bins: $(BRIDGE_BIN) $(PTP_BIN) $(HOSTLOCAL_BIN) $(FIREWALL_BIN)
248245

249246
.PHONY: test-cni-bins
250247
test-cni-bins: $(TEST_BRIDGED_TAP_BIN)
@@ -255,7 +252,6 @@ install-cni-bins: cni-bins $(CNI_BIN_ROOT)
255252
install -D -o root -g root -m755 -t $(CNI_BIN_ROOT) $(PTP_BIN)
256253
install -D -o root -g root -m755 -t $(CNI_BIN_ROOT) $(HOSTLOCAL_BIN)
257254
install -D -o root -g root -m755 -t $(CNI_BIN_ROOT) $(FIREWALL_BIN)
258-
install -D -o root -g root -m755 -t $(CNI_BIN_ROOT) $(TC_REDIRECT_TAP_BIN)
259255

260256
.PHONY: install-test-cni-bins
261257
install-test-cni-bins: test-cni-bins $(CNI_BIN_ROOT)

firecracker-control/local.go

+36
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,42 @@ func (s *local) StopVM(requestCtx context.Context, req *proto.StopVMRequest) (*e
252252
return resp, multierror.Append(shimErr, waitErr).ErrorOrNil()
253253
}
254254

255+
// PauseVM pauses a VM
256+
func (s *local) PauseVM(ctx context.Context, req *proto.PauseVMRequest) (*empty.Empty, error) {
257+
client, err := s.shimFirecrackerClient(ctx, req.VMID)
258+
if err != nil {
259+
return nil, err
260+
}
261+
262+
defer client.Close()
263+
264+
resp, err := client.PauseVM(ctx, req)
265+
if err != nil {
266+
s.logger.WithError(err).Error()
267+
return nil, err
268+
}
269+
270+
return resp, nil
271+
}
272+
273+
// ResumeVM resumes a VM
274+
func (s *local) ResumeVM(ctx context.Context, req *proto.ResumeVMRequest) (*empty.Empty, error) {
275+
client, err := s.shimFirecrackerClient(ctx, req.VMID)
276+
if err != nil {
277+
return nil, err
278+
}
279+
280+
defer client.Close()
281+
282+
resp, err := client.ResumeVM(ctx, req)
283+
if err != nil {
284+
s.logger.WithError(err).Error()
285+
return nil, err
286+
}
287+
288+
return resp, nil
289+
}
290+
255291
func (s *local) waitForShimToExit(ctx context.Context, vmID string) error {
256292
socketAddr, err := fcShim.SocketAddress(ctx, vmID)
257293
if err != nil {

firecracker-control/service.go

+10
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ func (s *service) CreateVM(ctx context.Context, req *proto.CreateVMRequest) (*pr
7272
return s.local.CreateVM(ctx, req)
7373
}
7474

75+
func (s *service) PauseVM(ctx context.Context, req *proto.PauseVMRequest) (*empty.Empty, error) {
76+
log.G(ctx).Debugf("pause VM request: %+v", req)
77+
return s.local.PauseVM(ctx, req)
78+
}
79+
80+
func (s *service) ResumeVM(ctx context.Context, req *proto.ResumeVMRequest) (*empty.Empty, error) {
81+
log.G(ctx).Debugf("resume VM request: %+v", req)
82+
return s.local.ResumeVM(ctx, req)
83+
}
84+
7585
func (s *service) StopVM(ctx context.Context, req *proto.StopVMRequest) (*empty.Empty, error) {
7686
log.G(ctx).Debugf("stop VM: %+v", req)
7787
return s.local.StopVM(ctx, req)

go.mod

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/firecracker-microvm/firecracker-containerd
33
require (
44
github.com/Microsoft/go-winio v0.4.14 // indirect
55
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
6+
github.com/awslabs/tc-redirect-tap v0.0.0-20200708224642-a0300978797d
67
github.com/containerd/cgroups v0.0.0-20181105182409-82cb49fc1779 // indirect
78
github.com/containerd/console v0.0.0-20191219165238-8375c3424e4d // indirect
89
github.com/containerd/containerd v1.3.8-0.20200824223617-f99bb2cc4483
@@ -11,22 +12,23 @@ require (
1112
github.com/containerd/go-runc v0.0.0-20190226155025-7d11b49dc076
1213
github.com/containerd/ttrpc v0.0.0-20190613183316-1fb3814edf44
1314
github.com/containerd/typeurl v0.0.0-20181015155603-461401dc8f19
14-
github.com/containernetworking/cni v0.7.2-0.20190807151350-8c6c47d1c7fc
15-
github.com/containernetworking/plugins v0.8.6
15+
github.com/containernetworking/cni v0.8.0
16+
github.com/containernetworking/plugins v0.8.7
1617
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 // indirect
1718
github.com/docker/distribution v2.7.1+incompatible // indirect
1819
github.com/docker/go-events v0.0.0-20170721190031-9461782956ad // indirect
1920
github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 // indirect
20-
github.com/firecracker-microvm/firecracker-go-sdk v0.21.1-0.20200811001213-ee1e7c41b7bd
21+
github.com/firecracker-microvm/firecracker-go-sdk v0.22.1-0.20201117001223-cd822c0d457c
2122
github.com/go-ole/go-ole v1.2.4 // indirect
2223
github.com/godbus/dbus v0.0.0-20181025153459-66d97aec3384 // indirect
2324
github.com/gofrs/uuid v3.3.0+incompatible
2425
github.com/gogo/googleapis v1.1.0 // indirect
2526
github.com/gogo/protobuf v1.3.0
2627
github.com/golang/protobuf v1.3.1
2728
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
28-
github.com/hashicorp/go-multierror v1.0.0
29+
github.com/hashicorp/go-multierror v1.1.0
2930
github.com/imdario/mergo v0.3.8 // indirect
31+
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
3032
github.com/mdlayher/vsock v0.0.0-20190329173812-a92c53d5dcab
3133
github.com/miekg/dns v1.1.16
3234
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
@@ -37,13 +39,13 @@ require (
3739
github.com/prometheus/client_golang v0.9.2 // indirect
3840
github.com/shirou/gopsutil v2.18.12+incompatible
3941
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
40-
github.com/sirupsen/logrus v1.6.0
42+
github.com/sirupsen/logrus v1.7.0
4143
github.com/stretchr/testify v1.6.1
4244
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 // indirect
4345
github.com/urfave/cli v1.20.0 // indirect
4446
github.com/vishvananda/netlink v1.1.0
4547
go.etcd.io/bbolt v1.3.1-etcd.8 // indirect
46-
golang.org/x/sync v0.0.0-20190423024810-112230192c58
48+
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
4749
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
4850
google.golang.org/genproto v0.0.0-20181109154231-b5d43981345b // indirect
4951
google.golang.org/grpc v1.21.0

0 commit comments

Comments
 (0)