Skip to content

Commit

Permalink
add compatibility with offloading
Browse files Browse the repository at this point in the history
Signed-off-by: Amory Hoste <[email protected]>
  • Loading branch information
amohoste committed Mar 21, 2022
1 parent aff3d2b commit 6d3265d
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 106 deletions.
10 changes: 6 additions & 4 deletions firecracker-control/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,12 @@ func (s *local) CreateSnapshot(ctx context.Context, req *proto.CreateSnapshotReq
func (s *local) LoadSnapshot(ctx context.Context, req *proto.LoadSnapshotRequest) (*proto.LoadResponse, error) {
var err error

// Create shim if not exists yet
code, err := s.CreateShim(ctx, req.GetVMID())
if err != nil && code != codes.AlreadyExists {
return nil, err
// Create shim if not exists yet for non-offloaded snapshots
if ! req.Offloaded {
code, err := s.CreateShim(ctx, req.GetVMID())
if err != nil && code != codes.AlreadyExists {
return nil, err
}
}

client, err := s.shimFirecrackerClient(ctx, req.VMID)
Expand Down
2 changes: 1 addition & 1 deletion proto/events.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

162 changes: 90 additions & 72 deletions proto/firecracker.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions proto/firecracker.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ message CreateVMRequest {
FirecrackerBalloonDevice BalloonDevice = 14;

string NetworkNamespace = 15;
bool OffloadEnabled = 16;
}

message CreateVMResponse {
Expand Down Expand Up @@ -121,6 +122,7 @@ message LoadSnapshotRequest {
bool EnableUserPF = 4;
string NetworkNamespace = 5;
string NewSnapshotPath = 6;
bool Offloaded = 7;
}

message LoadResponse {
Expand Down
8 changes: 8 additions & 0 deletions runtime/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func networkConfigFromProto(nwIface *proto.FirecrackerNetworkInterface, vmID str
// netNSFromProto returns the name and handle of the network namespace set, if any in the protobuf
// message.
func netNSFromProto(request *proto.CreateVMRequest) (string, ns.NetNS) {
if request.NetworkNamespace == "" {
return "", nil
}

if request != nil {
netNS, err := ns.GetNS(request.NetworkNamespace)
if err != nil {
Expand All @@ -138,6 +142,10 @@ func netNSFromProto(request *proto.CreateVMRequest) (string, ns.NetNS) {
// netNSFromProto returns the name and handle of the network namespace set, if any in the protobuf
// message.
func netNSFromSnapRequest(request *proto.LoadSnapshotRequest) (string, ns.NetNS) {
if request.NetworkNamespace == "" {
return "", nil
}

if request != nil {
netNS, err := ns.GetNS(request.NetworkNamespace)
if err != nil {
Expand Down
Loading

0 comments on commit 6d3265d

Please sign in to comment.