Skip to content

vHive reference PR: containerd 1.5, Firecracker v0.24 #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
url = https://github.com/opencontainers/runc
[submodule "firecracker"]
path = _submodules/firecracker
url = https://github.com/firecracker-microvm/firecracker.git
url = https://github.com/ease-lab/firecracker.git
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ demo-network: install-cni-bins $(FCNET_CONFIG)
# Firecracker submodule
##########################
.PHONY: firecracker
firecracker: $(FIRECRACKER_BIN)
firecracker:
_submodules/firecracker/tools/devtool build --release

.PHONY: install-firecracker
install-firecracker: firecracker
Expand Down
2 changes: 1 addition & 1 deletion _submodules/firecracker
Submodule firecracker updated 167 files
2 changes: 1 addition & 1 deletion _submodules/runc
Submodule runc updated 629 files
128 changes: 92 additions & 36 deletions firecracker-control/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,42 +248,6 @@ func (s *local) StopVM(requestCtx context.Context, req *proto.StopVMRequest) (*e
return resp, multierror.Append(shimErr, waitErr).ErrorOrNil()
}

// PauseVM pauses a VM
func (s *local) PauseVM(ctx context.Context, req *proto.PauseVMRequest) (*empty.Empty, error) {
client, err := s.shimFirecrackerClient(ctx, req.VMID)
if err != nil {
return nil, err
}

defer client.Close()

resp, err := client.PauseVM(ctx, req)
if err != nil {
s.logger.WithError(err).Error()
return nil, err
}

return resp, nil
}

// ResumeVM resumes a VM
func (s *local) ResumeVM(ctx context.Context, req *proto.ResumeVMRequest) (*empty.Empty, error) {
client, err := s.shimFirecrackerClient(ctx, req.VMID)
if err != nil {
return nil, err
}

defer client.Close()

resp, err := client.ResumeVM(ctx, req)
if err != nil {
s.logger.WithError(err).Error()
return nil, err
}

return resp, nil
}

func (s *local) waitForShimToExit(ctx context.Context, vmID string) error {
socketAddr, err := shim.SocketAddress(ctx, s.containerdAddress, vmID)
if err != nil {
Expand Down Expand Up @@ -596,3 +560,95 @@ func setShimOOMScore(shimPid int) error {

return nil
}

// PauseVM Pauses a VM
func (s *local) PauseVM(ctx context.Context, req *proto.PauseVMRequest) (*empty.Empty, error) {
client, err := s.shimFirecrackerClient(ctx, req.VMID)
if err != nil {
return nil, err
}

defer client.Close()

resp, err := client.PauseVM(ctx, req)
if err != nil {
s.logger.WithError(err).Error()
return nil, err
}

return resp, nil
}

// ResumeVM Resumes a VM
func (s *local) ResumeVM(ctx context.Context, req *proto.ResumeVMRequest) (*empty.Empty, error) {
client, err := s.shimFirecrackerClient(ctx, req.VMID)
if err != nil {
return nil, err
}

defer client.Close()

resp, err := client.ResumeVM(ctx, req)
if err != nil {
s.logger.WithError(err).Error()
return nil, err
}

return resp, nil
}

// CreateSnapshot Creates a snapshot of a VM
func (s *local) CreateSnapshot(ctx context.Context, req *proto.CreateSnapshotRequest) (*empty.Empty, error) {
client, err := s.shimFirecrackerClient(ctx, req.VMID)
if err != nil {
return nil, err
}

defer client.Close()

resp, err := client.CreateSnapshot(ctx, req)
if err != nil {
s.logger.WithError(err).Error()
return nil, err
}

return resp, nil
}

// LoadSnapshot Loads a snapshot of a VM
func (s *local) LoadSnapshot(ctx context.Context, req *proto.LoadSnapshotRequest) (*proto.LoadResponse, error) {
client, err := s.shimFirecrackerClient(ctx, req.VMID)
if err != nil {
return nil, err
}

defer client.Close()

resp, err := client.LoadSnapshot(ctx, req)
if err != nil {
s.logger.WithError(err).Error()
return nil, err
}

return resp, nil
}

// Offload Shuts down a VM started through the firecracker go sdk and deletes
// the corresponding firecracker socket. All of the other resources (shim, other sockets)
// will persist.
func (s *local) Offload(ctx context.Context, req *proto.OffloadRequest) (*empty.Empty, error) {
client, err := s.shimFirecrackerClient(ctx, req.VMID)
if err != nil {
return nil, err
}

defer client.Close()

resp, err := client.Offload(ctx, req)
if err != nil {
s.logger.WithError(err).Error()
return nil, err
}

return resp, nil
}
15 changes: 15 additions & 0 deletions firecracker-control/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,18 @@ func (s *service) UpdateBalloonStats(ctx context.Context, req *proto.UpdateBallo
log.G(ctx).Debug("Updating balloon device statistics polling interval")
return s.local.UpdateBalloonStats(ctx, req)
}

func (s *service) LoadSnapshot(ctx context.Context, req *proto.LoadSnapshotRequest) (*proto.LoadResponse, error) {
log.G(ctx).Debugf("load snapshot request: %+v", req)
return s.local.LoadSnapshot(ctx, req)
}

func (s *service) CreateSnapshot(ctx context.Context, req *proto.CreateSnapshotRequest) (*empty.Empty, error) {
log.G(ctx).Debugf("create snapshot request: %+v", req)
return s.local.CreateSnapshot(ctx, req)
}

func (s *service) Offload(ctx context.Context, req *proto.OffloadRequest) (*empty.Empty, error) {
log.G(ctx).Debugf("offload request: %+v", req)
return s.local.Offload(ctx, req)
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/sirupsen/logrus v1.8.0
github.com/stretchr/testify v1.6.1
github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
golang.org/x/sys v0.0.0-20210324051608-47abb6519492
Expand Down
Loading