From 032bd10012e89df32c437b386eccf425162d93f4 Mon Sep 17 00:00:00 2001 From: Amory Hoste Date: Sat, 22 Jan 2022 12:16:35 +0000 Subject: [PATCH] add compatibility with offloading Signed-off-by: Amory Hoste --- firecracker-control/local.go | 10 ++- proto/events.pb.go | 2 +- proto/firecracker.pb.go | 162 +++++++++++++++++++---------------- proto/firecracker.proto | 2 + runtime/service.go | 46 ++++------ 5 files changed, 118 insertions(+), 104 deletions(-) diff --git a/firecracker-control/local.go b/firecracker-control/local.go index f4db712d0..c9cd6120b 100644 --- a/firecracker-control/local.go +++ b/firecracker-control/local.go @@ -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) diff --git a/proto/events.pb.go b/proto/events.pb.go index 0a691ae6f..a191bfd61 100644 --- a/proto/events.pb.go +++ b/proto/events.pb.go @@ -111,4 +111,4 @@ var fileDescriptor_8f22242cb04491f9 = []byte{ 0xe0, 0x0c, 0x02, 0xb3, 0x95, 0x64, 0xb8, 0xd8, 0x40, 0xd2, 0xf9, 0x05, 0xd8, 0x64, 0x93, 0xd8, 0xc0, 0x66, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf6, 0x83, 0xd8, 0x3c, 0x53, 0x00, 0x00, 0x00, -} \ No newline at end of file +} diff --git a/proto/firecracker.pb.go b/proto/firecracker.pb.go index acd83d7a4..839d4f21a 100644 --- a/proto/firecracker.pb.go +++ b/proto/firecracker.pb.go @@ -75,6 +75,7 @@ type CreateVMRequest struct { MetricsFifoPath string `protobuf:"bytes,13,opt,name=MetricsFifoPath,proto3" json:"MetricsFifoPath,omitempty"` BalloonDevice *FirecrackerBalloonDevice `protobuf:"bytes,14,opt,name=BalloonDevice,proto3" json:"BalloonDevice,omitempty"` NetworkNamespace string `protobuf:"bytes,15,opt,name=NetworkNamespace,proto3" json:"NetworkNamespace,omitempty"` + OffloadEnabled bool `protobuf:"varint,16,opt,name=OffloadEnabled,proto3" json:"OffloadEnabled,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -209,6 +210,13 @@ func (m *CreateVMRequest) GetNetworkNamespace() string { return "" } +func (m *CreateVMRequest) GetOffloadEnabled() bool { + if m != nil { + return m.OffloadEnabled + } + return false +} + type CreateVMResponse struct { VMID string `protobuf:"bytes,1,opt,name=VMID,proto3" json:"VMID,omitempty"` SocketPath string `protobuf:"bytes,2,opt,name=SocketPath,proto3" json:"SocketPath,omitempty"` @@ -762,6 +770,7 @@ type LoadSnapshotRequest struct { EnableUserPF bool `protobuf:"varint,4,opt,name=EnableUserPF,proto3" json:"EnableUserPF,omitempty"` NetworkNamespace string `protobuf:"bytes,5,opt,name=NetworkNamespace,proto3" json:"NetworkNamespace,omitempty"` NewSnapshotPath string `protobuf:"bytes,6,opt,name=NewSnapshotPath,proto3" json:"NewSnapshotPath,omitempty"` + Offloaded bool `protobuf:"varint,7,opt,name=Offloaded,proto3" json:"Offloaded,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -833,6 +842,13 @@ func (m *LoadSnapshotRequest) GetNewSnapshotPath() string { return "" } +func (m *LoadSnapshotRequest) GetOffloaded() bool { + if m != nil { + return m.Offloaded + } + return false +} + type LoadResponse struct { FirecrackerPID string `protobuf:"bytes,1,opt,name=FirecrackerPID,proto3" json:"FirecrackerPID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1410,76 +1426,78 @@ func init() { func init() { proto.RegisterFile("firecracker.proto", fileDescriptor_a73317e9fb8da571) } var fileDescriptor_a73317e9fb8da571 = []byte{ - // 1136 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0xcd, 0x6e, 0xe3, 0x36, - 0x17, 0xfd, 0x34, 0x8a, 0xf3, 0x73, 0x1d, 0x27, 0x0e, 0xbf, 0x64, 0x46, 0x33, 0x18, 0x04, 0x86, - 0xd0, 0x4e, 0x8d, 0xa0, 0x0d, 0xd0, 0xa4, 0x28, 0x8a, 0x6e, 0x3a, 0x8e, 0x1d, 0x67, 0x3c, 0x33, - 0x76, 0x0c, 0x3a, 0x09, 0xd0, 0x76, 0xc5, 0x28, 0xd7, 0x8e, 0x1a, 0x59, 0x74, 0x45, 0x2a, 0x99, - 0x3c, 0x4c, 0x9f, 0xa2, 0x6f, 0xd2, 0x67, 0xe8, 0x0b, 0x74, 0xd1, 0x5d, 0x17, 0x05, 0x29, 0xda, - 0x92, 0x65, 0xc7, 0x13, 0xa0, 0x8b, 0xa2, 0x2b, 0x93, 0x87, 0x87, 0xbc, 0x47, 0xe7, 0x5e, 0xfe, - 0x18, 0xb6, 0xfa, 0x7e, 0x84, 0x5e, 0xc4, 0xbc, 0x1b, 0x8c, 0xf6, 0x47, 0x11, 0x97, 0xfc, 0x45, - 0x51, 0xde, 0x8f, 0x50, 0x24, 0x1d, 0xf7, 0xf7, 0x02, 0x6c, 0xd6, 0x23, 0x64, 0x12, 0x2f, 0xda, - 0x14, 0x7f, 0x8e, 0x51, 0x48, 0x42, 0x60, 0xe9, 0xa2, 0xdd, 0x6a, 0x38, 0x56, 0xc5, 0xaa, 0xae, - 0x51, 0xdd, 0x26, 0xaf, 0x01, 0xda, 0xcc, 0xbb, 0xf6, 0x43, 0xac, 0xf7, 0x07, 0xce, 0x93, 0x8a, - 0x55, 0x2d, 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, 0x9c, 0x2e, 0x0f, 0x02, 0x3f, 0x1c, 0xe8, 0x07, 0xef, 0x2d, 0x0b, 0xc6, 0x89, 0x9f, - 0x3f, 0xb8, 0xf7, 0xd9, 0x9c, 0x4d, 0x4a, 0x56, 0x61, 0xa9, 0x7e, 0xda, 0xfd, 0xbe, 0xfc, 0x3f, - 0xd5, 0x3a, 0x6a, 0x75, 0x1a, 0x65, 0xeb, 0x68, 0xe5, 0x87, 0x82, 0xfe, 0xb7, 0x72, 0xb9, 0xac, - 0x7f, 0x0e, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xc7, 0x98, 0x36, 0xdc, 0xd6, 0x0c, 0x00, 0x00, + // 1162 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0xd1, 0x6e, 0x1a, 0x47, + 0x17, 0xfe, 0xd7, 0x6b, 0x30, 0x1c, 0x8c, 0x8d, 0xe7, 0xb7, 0x93, 0x4d, 0x14, 0x45, 0x68, 0xd5, + 0xa6, 0xc8, 0x6a, 0x2d, 0x35, 0xa9, 0xaa, 0xaa, 0x37, 0x0d, 0x81, 0xe0, 0x90, 0x04, 0x82, 0x06, + 0x3b, 0x52, 0xdb, 0xab, 0xf1, 0x72, 0xc0, 0x5b, 0x2f, 0x3b, 0x74, 0x67, 0xd6, 0x89, 0xdf, 0xa1, + 0x52, 0x9f, 0xa0, 0x4f, 0xd1, 0x37, 0xe9, 0xbb, 0xf4, 0xae, 0x17, 0xd5, 0xcc, 0x0e, 0xec, 0xb2, + 0x10, 0x62, 0xa9, 0x17, 0x55, 0xaf, 0x98, 0xf9, 0xe6, 0x9b, 0x39, 0x67, 0xbe, 0x73, 0xe6, 0xec, + 0x01, 0x0e, 0xc6, 0x7e, 0x84, 0x5e, 0xc4, 0xbc, 0x2b, 0x8c, 0x4e, 0x66, 0x11, 0x97, 0xfc, 0x7e, + 0x45, 0xde, 0xcc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9, 0x30, 0x52, 0x88, 0xdc, 0x81, 0xe2, 0xf0, 0x1d, 0x9b, 0x75, 0x43, 0xdd, 0xed, + 0xd9, 0xd4, 0xcc, 0x88, 0x03, 0x3b, 0x6a, 0xf4, 0x26, 0x96, 0xba, 0xa3, 0xb3, 0xe9, 0x7c, 0xaa, + 0x94, 0x3f, 0x63, 0xd1, 0x04, 0x75, 0xb6, 0xed, 0x26, 0xca, 0x2f, 0x00, 0x65, 0x31, 0x99, 0x24, + 0xca, 0x57, 0x13, 0x8b, 0x19, 0x48, 0x33, 0xb8, 0x64, 0x81, 0x11, 0x6c, 0xcf, 0x30, 0x52, 0xc8, + 0x45, 0xb8, 0xb7, 0x94, 0xfb, 0x1f, 0x4b, 0x14, 0xf2, 0x15, 0x1c, 0x69, 0xce, 0x80, 0x07, 0x81, + 0x1f, 0x4e, 0x74, 0xdb, 0x7c, 0xcd, 0x82, 0x79, 0xe0, 0xd7, 0x2f, 0x1e, 0x7f, 0xb6, 0xe6, 0x91, + 0x92, 0x12, 0x6c, 0xb7, 0xde, 0x0c, 0xbe, 0xaf, 0xfd, 0x4f, 0x8d, 0x9e, 0x75, 0xfb, 0xed, 0x9a, + 0xf5, 0x6c, 0xe7, 0x87, 0x82, 0xfe, 0xcf, 0x73, 0x51, 0xd4, 0x3f, 0x4f, 0xfe, 0x0e, 0x00, 0x00, + 0xff, 0xff, 0x18, 0x5c, 0x8d, 0x4a, 0x1c, 0x0d, 0x00, 0x00, } diff --git a/proto/firecracker.proto b/proto/firecracker.proto index 898b3529e..c82a46853 100644 --- a/proto/firecracker.proto +++ b/proto/firecracker.proto @@ -43,6 +43,7 @@ message CreateVMRequest { FirecrackerBalloonDevice BalloonDevice = 14; string NetworkNamespace = 15; + bool OffloadEnabled = 16; } message CreateVMResponse { @@ -121,6 +122,7 @@ message LoadSnapshotRequest { bool EnableUserPF = 4; string NetworkNamespace = 5; string NewSnapshotPath = 6; + bool Offloaded = 7; } message LoadResponse { diff --git a/runtime/service.go b/runtime/service.go index 98791d517..ff6ea2e3a 100644 --- a/runtime/service.go +++ b/runtime/service.go @@ -177,6 +177,7 @@ type service struct { taskDrivePathOnHost string snapLoaded bool + offloadEnabled bool networkNamespace string netNS ns.NetNS } @@ -274,7 +275,7 @@ func (s *service) startEventForwarders(remotePublisher shim.Publisher) { go func() { <-s.vmReady - if s.snapLoaded { + if !s.offloadEnabled && s.snapLoaded { return } @@ -496,6 +497,8 @@ func (s *service) CreateVM(requestCtx context.Context, request *proto.CreateVMRe resp proto.CreateVMResponse ) + s.offloadEnabled = request.OffloadEnabled + s.vmStartOnce.Do(func() { err = s.createVM(ctxWithTimeout, request) createRan = true @@ -521,7 +524,9 @@ func (s *service) CreateVM(requestCtx context.Context, request *proto.CreateVMRe } // Cancels the shim - go s.monitorVMExit() + if ! s.offloadEnabled { + go s.monitorVMExit() + } // let all the other methods know that the VM is ready for tasks close(s.vmReady) @@ -1916,7 +1921,7 @@ func formCreateSnapReq(snapshotPath, memPath, snapshotType string) (*http.Reques return req, nil } -func (s *service) startFirecrackerProcess() error { +func (s *service) startFirecrackerProcess(offload bool) error { firecPath, err := exec.LookPath("firecracker") if err != nil { logrus.WithError(err).Error("failed to look up firecracker binary") @@ -1953,7 +1958,9 @@ func (s *service) startFirecrackerProcess() error { firecrackerCmd.Dir = s.shimDir.RootPath() // Make sure all child processes get killed - firecrackerCmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} + if ! offload { + firecrackerCmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} + } if err := firecrackerCmd.Start(); err != nil { logrus.WithError(err).Error("Failed to start firecracker process") @@ -2079,7 +2086,7 @@ func (s *service) LoadSnapshot(ctx context.Context, req *proto.LoadSnapshotReque s.networkNamespace, s.netNS = netNSFromSnapRequest(req) s.snapLoaded = true - if err := s.startFirecrackerProcess(); err != nil { + if err := s.startFirecrackerProcess(req.Offloaded); err != nil { s.logger.WithError(err).Error("startFirecrackerProcess returned an error") return nil, err } @@ -2120,7 +2127,9 @@ func (s *service) LoadSnapshot(ctx context.Context, req *proto.LoadSnapshotReque return nil, err } - close(s.vmReady) + if ! req.Offloaded { + close(s.vmReady) + } return &proto.LoadResponse{FirecrackerPID: strconv.Itoa(s.firecrackerPid)}, nil } @@ -2180,25 +2189,12 @@ func (s *service) SendCreateSnapRequest(createSnapReq *http.Request) error { } // Offload Shuts down a VM and deletes the corresponding firecracker socket -// and vsock. All of the other resources will persist. DEPRECATED! +// and vsock. All of the other resources will persist. func (s *service) Offload(ctx context.Context, req *proto.OffloadRequest) (*empty.Empty, error) { - if !s.snapLoaded { - _, err := s.agentClient.Shutdown(ctx, &taskAPI.ShutdownRequest{Now: true}) - if err != nil { - return nil, err - } - - if err := syscall.Kill(s.firecrackerPid, 9); err != nil { - s.logger.WithError(err).Error("Failed to kill firecracker process") - return nil, err - } - } else { - // Make sure to kill child process if snaploaded - if err := syscall.Kill(-s.firecrackerPid, 9); err != nil { - s.logger.WithError(err).Error("Failed to kill firecracker process") - return nil, err - } + if err := syscall.Kill(s.firecrackerPid, 9); err != nil { + s.logger.WithError(err).Error("Failed to kill firecracker process") + return nil, err } if err := os.RemoveAll(s.shimDir.FirecrackerSockPath()); err != nil { @@ -2216,9 +2212,5 @@ func (s *service) Offload(ctx context.Context, req *proto.OffloadRequest) (*empt return nil, err } - if err := s.cleanup(); err != nil { - s.logger.WithError(err).Error("failed to clean up the VM") - } - return &empty.Empty{}, nil }