Skip to content

Commit 6d3265d

Browse files
committed
add compatibility with offloading
Signed-off-by: Amory Hoste <[email protected]>
1 parent aff3d2b commit 6d3265d

File tree

6 files changed

+129
-106
lines changed

6 files changed

+129
-106
lines changed

firecracker-control/local.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,12 @@ func (s *local) CreateSnapshot(ctx context.Context, req *proto.CreateSnapshotReq
633633
func (s *local) LoadSnapshot(ctx context.Context, req *proto.LoadSnapshotRequest) (*proto.LoadResponse, error) {
634634
var err error
635635

636-
// Create shim if not exists yet
637-
code, err := s.CreateShim(ctx, req.GetVMID())
638-
if err != nil && code != codes.AlreadyExists {
639-
return nil, err
636+
// Create shim if not exists yet for non-offloaded snapshots
637+
if ! req.Offloaded {
638+
code, err := s.CreateShim(ctx, req.GetVMID())
639+
if err != nil && code != codes.AlreadyExists {
640+
return nil, err
641+
}
640642
}
641643

642644
client, err := s.shimFirecrackerClient(ctx, req.VMID)

proto/events.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/firecracker.pb.go

Lines changed: 90 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/firecracker.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ message CreateVMRequest {
4343
FirecrackerBalloonDevice BalloonDevice = 14;
4444

4545
string NetworkNamespace = 15;
46+
bool OffloadEnabled = 16;
4647
}
4748

4849
message CreateVMResponse {
@@ -121,6 +122,7 @@ message LoadSnapshotRequest {
121122
bool EnableUserPF = 4;
122123
string NetworkNamespace = 5;
123124
string NewSnapshotPath = 6;
125+
bool Offloaded = 7;
124126
}
125127

126128
message LoadResponse {

runtime/helpers.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ func networkConfigFromProto(nwIface *proto.FirecrackerNetworkInterface, vmID str
123123
// netNSFromProto returns the name and handle of the network namespace set, if any in the protobuf
124124
// message.
125125
func netNSFromProto(request *proto.CreateVMRequest) (string, ns.NetNS) {
126+
if request.NetworkNamespace == "" {
127+
return "", nil
128+
}
129+
126130
if request != nil {
127131
netNS, err := ns.GetNS(request.NetworkNamespace)
128132
if err != nil {
@@ -138,6 +142,10 @@ func netNSFromProto(request *proto.CreateVMRequest) (string, ns.NetNS) {
138142
// netNSFromProto returns the name and handle of the network namespace set, if any in the protobuf
139143
// message.
140144
func netNSFromSnapRequest(request *proto.LoadSnapshotRequest) (string, ns.NetNS) {
145+
if request.NetworkNamespace == "" {
146+
return "", nil
147+
}
148+
141149
if request != nil {
142150
netNS, err := ns.GetNS(request.NetworkNamespace)
143151
if err != nil {

0 commit comments

Comments
 (0)