Skip to content

Commit 6f66aa6

Browse files
Add support for firecracker VM snapshot-restore
In order to support firecracker snapshot-restore we need to make the following changes: * add a new CreateSnapshot request; * add new parameters for snapshot loading to the CreateVM request (following the firecracker Golang SDK design, snapshot loading is essentially creating a VM with additional snapshot options). When a VM is created by loading a snapshot, it's container snapshot drives are already mounted, so the drive mount stub creation and mounting is skipped. Also add a NetNS (network namespace) parameter to the CreateVM request, since the current NetNS parameter nested in the JailerConfig parameter requires specifying the entire jailer configuration, which is not convenient. Signed-off-by: Georgiy Lebedev <[email protected]>
1 parent 57ac852 commit 6f66aa6

File tree

11 files changed

+352
-148
lines changed

11 files changed

+352
-148
lines changed

Diff for: .gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
url = https://github.com/opencontainers/runc
44
[submodule "firecracker"]
55
path = _submodules/firecracker
6-
url = https://github.com/firecracker-microvm/firecracker.git
6+
url = https://github.com/vhive-serverless/firecracker.git
77
[submodule "stargz-snapshotter"]
88
path = _submodules/stargz-snapshotter
99
url = https://github.com/containerd/stargz-snapshotter

Diff for: _submodules/firecracker

Submodule firecracker updated 574 files

Diff for: firecracker-control/local.go

+18
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,24 @@ func (s *local) PauseVM(ctx context.Context, req *proto.PauseVMRequest) (*types.
265265
return resp, nil
266266
}
267267

268+
// CreateSnapshot creates a snapshot of a VM.
269+
func (s *local) CreateSnapshot(ctx context.Context, req *proto.CreateSnapshotRequest) (*types.Empty, error) {
270+
client, err := s.shimFirecrackerClient(ctx, req.VMID)
271+
if err != nil {
272+
return nil, err
273+
}
274+
275+
defer client.Close()
276+
277+
resp, err := client.CreateSnapshot(ctx, req)
278+
if err != nil {
279+
s.logger.WithError(err).Error()
280+
return nil, err
281+
}
282+
283+
return resp, nil
284+
}
285+
268286
// ResumeVM resumes a VM
269287
func (s *local) ResumeVM(ctx context.Context, req *proto.ResumeVMRequest) (*types.Empty, error) {
270288
client, err := s.shimFirecrackerClient(ctx, req.VMID)

Diff for: firecracker-control/service.go

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ func (s *service) ResumeVM(ctx context.Context, req *proto.ResumeVMRequest) (*ty
8282
return s.local.ResumeVM(ctx, req)
8383
}
8484

85+
func (s *service) CreateSnapshot(ctx context.Context, req *proto.CreateSnapshotRequest) (*types.Empty, error) {
86+
log.G(ctx).Debugf("create snapshot request: %+v", req)
87+
return s.local.CreateSnapshot(ctx, req)
88+
}
89+
8590
func (s *service) StopVM(ctx context.Context, req *proto.StopVMRequest) (*types.Empty, error) {
8691
log.G(ctx).Debugf("stop VM: %+v", req)
8792
return s.local.StopVM(ctx, req)

Diff for: go.mod

+14-13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module github.com/firecracker-microvm/firecracker-containerd
22

33
go 1.17
44

5+
replace github.com/firecracker-microvm/firecracker-go-sdk => github.com/vhive-serverless/firecracker-go-sdk v0.0.0-20230910093528-55ab6c76ad40
6+
57
require (
68
github.com/awslabs/tc-redirect-tap v0.0.0-20211025175357-e30dfca224c2
79
github.com/containerd/containerd v1.6.20
@@ -10,7 +12,7 @@ require (
1012
github.com/containerd/go-runc v1.0.0
1113
github.com/containerd/ttrpc v1.1.2
1214
github.com/containerd/typeurl v1.0.2
13-
github.com/containernetworking/cni v1.1.1
15+
github.com/containernetworking/cni v1.1.2
1416
github.com/containernetworking/plugins v1.1.1
1517
github.com/firecracker-microvm/firecracker-go-sdk v0.22.1-0.20220427214706-47505a9cf951
1618
github.com/gofrs/uuid v3.3.0+incompatible
@@ -24,12 +26,12 @@ require (
2426
github.com/opencontainers/runtime-spec v1.0.3-0.20210910115017-0d6cc581aeea
2527
github.com/pelletier/go-toml v1.9.5
2628
github.com/shirou/gopsutil v2.18.12+incompatible
27-
github.com/sirupsen/logrus v1.8.1
29+
github.com/sirupsen/logrus v1.9.0
2830
github.com/stretchr/testify v1.8.1
2931
github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5
3032
go.uber.org/goleak v1.1.12
3133
golang.org/x/sync v0.1.0
32-
golang.org/x/sys v0.6.0
34+
golang.org/x/sys v0.10.0
3335
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
3436
google.golang.org/grpc v1.47.0
3537
)
@@ -64,16 +66,15 @@ require (
6466
github.com/go-logr/stdr v1.2.2 // indirect
6567
github.com/go-ole/go-ole v1.2.4 // indirect
6668
github.com/go-openapi/analysis v0.21.2 // indirect
67-
github.com/go-openapi/errors v0.20.2 // indirect
69+
github.com/go-openapi/errors v0.20.3 // indirect
6870
github.com/go-openapi/jsonpointer v0.19.5 // indirect
6971
github.com/go-openapi/jsonreference v0.19.6 // indirect
7072
github.com/go-openapi/loads v0.21.1 // indirect
71-
github.com/go-openapi/runtime v0.23.3 // indirect
73+
github.com/go-openapi/runtime v0.24.0 // indirect
7274
github.com/go-openapi/spec v0.20.4 // indirect
73-
github.com/go-openapi/strfmt v0.21.2 // indirect
75+
github.com/go-openapi/strfmt v0.21.3 // indirect
7476
github.com/go-openapi/swag v0.21.1 // indirect
75-
github.com/go-openapi/validate v0.21.0 // indirect
76-
github.com/go-stack/stack v1.8.1 // indirect
77+
github.com/go-openapi/validate v0.22.0 // indirect
7778
github.com/godbus/dbus/v5 v5.0.6 // indirect
7879
github.com/gogo/googleapis v1.4.1 // indirect
7980
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
@@ -119,17 +120,17 @@ require (
119120
github.com/urfave/cli v1.22.2 // indirect
120121
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
121122
go.etcd.io/bbolt v1.3.6 // indirect
122-
go.mongodb.org/mongo-driver v1.8.3 // indirect
123+
go.mongodb.org/mongo-driver v1.10.0 // indirect
123124
go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1 // indirect
124125
go.opencensus.io v0.23.0 // indirect
125126
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.28.0 // indirect
126127
go.opentelemetry.io/otel v1.3.0 // indirect
127128
go.opentelemetry.io/otel/trace v1.3.0 // indirect
128-
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
129-
golang.org/x/net v0.8.0 // indirect
129+
golang.org/x/crypto v0.11.0 // indirect
130+
golang.org/x/net v0.12.0 // indirect
130131
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
131-
golang.org/x/term v0.6.0 // indirect
132-
golang.org/x/text v0.8.0 // indirect
132+
golang.org/x/term v0.10.0 // indirect
133+
golang.org/x/text v0.11.0 // indirect
133134
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
134135
google.golang.org/appengine v1.6.7 // indirect
135136
google.golang.org/protobuf v1.28.0 // indirect

0 commit comments

Comments
 (0)