Skip to content

Commit 886b20a

Browse files
committed
Extended LoadSnapshot and Offload
Signed-off-by: Plamen Petrov <[email protected]>
1 parent b973d80 commit 886b20a

File tree

5 files changed

+128
-4
lines changed

5 files changed

+128
-4
lines changed

internal/common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const (
3434
// FirecrackerVSockName is the name of the Firecracker VSock unix path used for communication
3535
// between the runtime and the agent
3636
FirecrackerVSockName = "firecracker.vsock"
37+
// FirecrackerUPFSockName is the name of the Firecracker UPF socker
38+
FirecrackerUPFSockName = "firecracker.upfsock"
3739
// FirecrackerLogFifoName is the name of the Firecracker VMM log FIFO
3840
FirecrackerLogFifoName = "fc-logs.fifo"
3941
// FirecrackerMetricsFifoName is the name of the Firecracker VMM metrics FIFO

internal/vm/dir.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ func (d Dir) FirecrackerSockRelPath() (string, error) {
9595
return relPathTo(d.FirecrackerSockPath())
9696
}
9797

98+
// FirecrackerUPFSockPath returns the path to the user page faults
99+
// socket of the firecracker process
100+
func (d Dir) FirecrackerUPFSockPath() string {
101+
return filepath.Join(d.RootPath(), internal.FirecrackerUPFSockName)
102+
}
103+
98104
// FirecrackerVSockPath returns the path to the vsock unix socket that the runtime uses
99105
// to communicate with the VM agent.
100106
func (d Dir) FirecrackerVSockPath() string {

proto/firecracker.pb.go

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

proto/firecracker.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ message LoadSnapshotRequest {
113113
string VMID = 1;
114114
string SnapshotFilePath = 2;
115115
string MemFilePath = 3;
116+
bool EnableUserPF = 4;
116117
}
117118

118119
message OffloadRequest {

runtime/service.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ var (
106106
_ shim.Init = NewService
107107
)
108108

109+
type loadSnapReq struct {
110+
SnapshotPath string `json:"snapshot_path"`
111+
MemFilePath string `json:"mem_file_path"`
112+
SendSockAddr string `json:"sock_file_path"`
113+
EnableUserPageFaults bool `json:"enable_user_page_faults"`
114+
}
115+
109116
// implements shimapi
110117
type service struct {
111118
taskManager vm.TaskManager
@@ -1770,13 +1777,16 @@ func formPauseReq() (*http.Request, error) {
17701777
return req, nil
17711778
}
17721779

1773-
func formLoadSnapReq(snapshotPath, memPath string) (*http.Request, error) {
1780+
func formLoadSnapReq(snapshotPath, memPath, sendSockAddr string, isUpf bool) (*http.Request, error) {
17741781
var req *http.Request
17751782

1776-
data := map[string]string{
1777-
"snapshot_path": snapshotPath,
1778-
"mem_file_path": memPath,
1783+
data := loadSnapReq{
1784+
SnapshotPath: snapshotPath,
1785+
MemFilePath: memPath,
1786+
SendSockAddr: sendSockAddr,
1787+
EnableUserPageFaults: isUpf,
17791788
}
1789+
17801790
json, err := json.Marshal(data)
17811791
if err != nil {
17821792
logrus.WithError(err).Error("Failed to marshal json data")

0 commit comments

Comments
 (0)