Skip to content

Commit 396d0be

Browse files
committed
vfs: introduce CtxRestoreFilesystemFDMap
This patch introduces CtxRestoreFilesystemFDMap in vfs to replace the CtxRestoreServerFDMap defined in gofer, which is a preparation for adding the checkpoint/restore support in EROFS. It allows the configureRestore() in boot/vfs.go to be agnostic to the filesystems that will be used in the sentry when configuring restore. Signed-off-by: Tiwei Bie <[email protected]>
1 parent 57606c7 commit 396d0be

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

pkg/sentry/fsimpl/gofer/save_restore.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ import (
2929
"gvisor.dev/gvisor/pkg/sentry/vfs"
3030
)
3131

32-
type saveRestoreContextID int
33-
34-
const (
35-
// CtxRestoreServerFDMap is a Context.Value key for a map[string]int
36-
// mapping filesystem unique IDs (cf. InternalFilesystemOptions.UniqueID)
37-
// to host FDs.
38-
CtxRestoreServerFDMap saveRestoreContextID = iota
39-
)
40-
4132
// +stateify savable
4233
type savedDentryRW struct {
4334
read bool
@@ -181,7 +172,7 @@ func (d *dentry) loadParent(parent *dentry) {
181172
// CompleteRestore implements
182173
// vfs.FilesystemImplSaveRestoreExtension.CompleteRestore.
183174
func (fs *filesystem) CompleteRestore(ctx context.Context, opts vfs.CompleteRestoreOptions) error {
184-
fdmapv := ctx.Value(CtxRestoreServerFDMap)
175+
fdmapv := ctx.Value(vfs.CtxRestoreFilesystemFDMap)
185176
if fdmapv == nil {
186177
return fmt.Errorf("no server FD map available")
187178
}

pkg/sentry/vfs/context.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ const (
2727

2828
// CtxRoot is a Context.Value key for a VFS root.
2929
CtxRoot
30+
31+
// CtxRestoreFilesystemFDMap is a Context.Value key for a map[string]int
32+
// mapping filesystem unique IDs (cf. gofer.InternalFilesystemOptions.UniqueID)
33+
// to host FDs.
34+
CtxRestoreFilesystemFDMap
3035
)
3136

3237
// MountNamespaceFromContext returns the MountNamespace used by ctx. If ctx is

runsc/boot/vfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ func (c *containerMounter) configureRestore(ctx context.Context) (context.Contex
10871087
fdmap[submount.mount.Destination] = submount.goferFD.Release()
10881088
}
10891089
}
1090-
return context.WithValue(ctx, gofer.CtxRestoreServerFDMap, fdmap), nil
1090+
return context.WithValue(ctx, vfs.CtxRestoreFilesystemFDMap, fdmap), nil
10911091
}
10921092

10931093
func createDeviceFiles(ctx context.Context, creds *auth.Credentials, info *containerInfo, vfsObj *vfs.VirtualFilesystem, root vfs.VirtualDentry) error {

0 commit comments

Comments
 (0)