@@ -28,7 +28,7 @@ import (
2828 "github.com/ease-lab/vhive/ctriface"
2929 "github.com/ease-lab/vhive/metrics"
3030 "github.com/ease-lab/vhive/snapshotting"
31- "github.com/ease-lab/vhive/snapshotting/deduplicated "
31+ "github.com/ease-lab/vhive/snapshotting/fulllocal "
3232 "github.com/ease-lab/vhive/snapshotting/regular"
3333 "github.com/pkg/errors"
3434 "strconv"
@@ -77,9 +77,9 @@ func newFirecrackerCoordinator(
7777 }
7878
7979 if isFullLocal {
80- c .snapshotManager = snapshotting .NewSnapshotManager (deduplicated .NewSnapshotManager (snapshotsDir , snapsCapacityMiB ))
80+ c .snapshotManager = snapshotting .NewSnapshotManager (fulllocal .NewSnapshotManager (snapshotsDir , snapsCapacityMiB ))
8181 } else {
82- c .snapshotManager = snapshotting .NewSnapshotManager (regular .NewRegularSnapshotManager (snapshotsDir ))
82+ c .snapshotManager = snapshotting .NewSnapshotManager (regular .NewSnapshotManager (snapshotsDir ))
8383 }
8484
8585 for _ , opt := range opts {
@@ -142,7 +142,8 @@ func (c *coordinator) stopVM(ctx context.Context, containerID string) error {
142142 }
143143
144144 if funcInst .snapBooted {
145- defer c .snapshotManager .ReleaseSnapshot (id )
145+ // Release snapshot after the VM has been stopped / offloaded
146+ defer func () { _ = c .snapshotManager .ReleaseSnapshot (id ) }()
146147 } else {
147148 // Create snapshot
148149 err := c .orchCreateSnapshot (ctx , funcInst )
@@ -204,7 +205,7 @@ func (c *coordinator) orchStartVM(ctx context.Context, image, revision string, m
204205
205206 if ! c .withoutOrchestrator {
206207 trackDirtyPages := c .isSparseSnaps
207- resp , _ , err = c .orch .StartVM (ctxTimeout , vmID , image , memSizeMib , vCPUCount , trackDirtyPages , c . isFullLocal )
208+ resp , _ , err = c .orch .StartVM (ctxTimeout , vmID , image , memSizeMib , vCPUCount , trackDirtyPages )
208209 if err != nil {
209210 logger .WithError (err ).Error ("coordinator failed to start VM" )
210211 }
@@ -242,7 +243,7 @@ func (c *coordinator) orchStartVMSnapshot(
242243 ctxTimeout , cancel := context .WithTimeout (ctx , time .Second * 30 )
243244 defer cancel ()
244245
245- resp , _ , err = c .orch .LoadSnapshot (ctxTimeout , vmID , snap , c . isFullLocal )
246+ resp , _ , err = c .orch .LoadSnapshot (ctxTimeout , vmID , snap )
246247 if err != nil {
247248 logger .WithError (err ).Error ("failed to load VM" )
248249 return nil , err
@@ -273,7 +274,7 @@ func (c *coordinator) orchCreateSnapshot(ctx context.Context, funcInst *FuncInst
273274 id = funcInst .revisionId
274275 }
275276
276- removeContainerSnaps , snap , err := c .snapshotManager .InitSnapshot (
277+ _ , snap , err := c .snapshotManager .InitSnapshot (
277278 id ,
278279 funcInst .image ,
279280 funcInst .coldStartTimeMs ,
@@ -286,13 +287,14 @@ func (c *coordinator) orchCreateSnapshot(ctx context.Context, funcInst *FuncInst
286287 return nil
287288 }
288289
289- if c .isFullLocal && removeContainerSnaps != nil {
290+ // This call is only necessary if the alternative approach in devicemapper with thin-delta is used.
291+ /*if c.isFullLocal && removeContainerSnaps != nil {
290292 for _, cleanupSnapId := range *removeContainerSnaps {
291293 if err := c.orch.CleanupSnapshot(ctx, cleanupSnapId); err != nil {
292294 return errors.Wrap(err, "removing devmapper revision snapshot")
293295 }
294296 }
295- }
297+ }*/
296298
297299 ctxTimeout , cancel := context .WithTimeout (ctx , time .Second * 60 )
298300 defer cancel ()
@@ -305,12 +307,18 @@ func (c *coordinator) orchCreateSnapshot(ctx context.Context, funcInst *FuncInst
305307 return nil
306308 }
307309
308- err = c .orch .CreateSnapshot (ctxTimeout , funcInst .vmID , snap , c . isFullLocal )
310+ err = c .orch .CreateSnapshot (ctxTimeout , funcInst .vmID , snap )
309311 if err != nil {
310312 funcInst .logger .WithError (err ).Error ("failed to create snapshot" )
311313 return nil
312314 }
313315
316+ // TODO: StopVM does not work for fullLocal snapshots without resuming. Might be the same for offloaded since
317+ // those are never stopped
318+ if c .isFullLocal {
319+ _ , err = c .orch .ResumeVM (ctx , funcInst .vmID )
320+ }
321+
314322 if err := c .snapshotManager .CommitSnapshot (id ); err != nil {
315323 funcInst .logger .WithError (err ).Error ("failed to commit snapshot" )
316324 return err
@@ -324,7 +332,7 @@ func (c *coordinator) orchOffloadVM(ctx context.Context, funcInst *FuncInstance)
324332 return nil
325333 }
326334
327- if err := c .orch .OffloadVM (ctx , funcInst .vmID , c . isFullLocal ); err != nil {
335+ if err := c .orch .OffloadVM (ctx , funcInst .vmID ); err != nil {
328336 funcInst .logger .WithError (err ).Error ("failed to offload VM" )
329337 return err
330338 }
@@ -337,7 +345,7 @@ func (c *coordinator) orchStopVM(ctx context.Context, funcInst *FuncInstance) er
337345 return nil
338346 }
339347
340- if err := c .orch .StopSingleVM (ctx , funcInst .vmID , c . isFullLocal ); err != nil {
348+ if err := c .orch .StopSingleVM (ctx , funcInst .vmID ); err != nil {
341349 funcInst .logger .WithError (err ).Error ("failed to stop VM for instance" )
342350 return err
343351 }
0 commit comments