mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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 <tiwei.btw@antgroup.com>
This commit is contained in:
@@ -29,15 +29,6 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/sentry/vfs"
|
||||
)
|
||||
|
||||
type saveRestoreContextID int
|
||||
|
||||
const (
|
||||
// CtxRestoreServerFDMap is a Context.Value key for a map[string]int
|
||||
// mapping filesystem unique IDs (cf. InternalFilesystemOptions.UniqueID)
|
||||
// to host FDs.
|
||||
CtxRestoreServerFDMap saveRestoreContextID = iota
|
||||
)
|
||||
|
||||
// +stateify savable
|
||||
type savedDentryRW struct {
|
||||
read bool
|
||||
@@ -181,7 +172,7 @@ func (d *dentry) loadParent(parent *dentry) {
|
||||
// CompleteRestore implements
|
||||
// vfs.FilesystemImplSaveRestoreExtension.CompleteRestore.
|
||||
func (fs *filesystem) CompleteRestore(ctx context.Context, opts vfs.CompleteRestoreOptions) error {
|
||||
fdmapv := ctx.Value(CtxRestoreServerFDMap)
|
||||
fdmapv := ctx.Value(vfs.CtxRestoreFilesystemFDMap)
|
||||
if fdmapv == nil {
|
||||
return fmt.Errorf("no server FD map available")
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ const (
|
||||
|
||||
// CtxRoot is a Context.Value key for a VFS root.
|
||||
CtxRoot
|
||||
|
||||
// CtxRestoreFilesystemFDMap is a Context.Value key for a map[string]int
|
||||
// mapping filesystem unique IDs (cf. gofer.InternalFilesystemOptions.UniqueID)
|
||||
// to host FDs.
|
||||
CtxRestoreFilesystemFDMap
|
||||
)
|
||||
|
||||
// MountNamespaceFromContext returns the MountNamespace used by ctx. If ctx is
|
||||
|
||||
+1
-1
@@ -1087,7 +1087,7 @@ func (c *containerMounter) configureRestore(ctx context.Context) (context.Contex
|
||||
fdmap[submount.mount.Destination] = submount.goferFD.Release()
|
||||
}
|
||||
}
|
||||
return context.WithValue(ctx, gofer.CtxRestoreServerFDMap, fdmap), nil
|
||||
return context.WithValue(ctx, vfs.CtxRestoreFilesystemFDMap, fdmap), nil
|
||||
}
|
||||
|
||||
func createDeviceFiles(ctx context.Context, creds *auth.Credentials, info *containerInfo, vfsObj *vfs.VirtualFilesystem, root vfs.VirtualDentry) error {
|
||||
|
||||
Reference in New Issue
Block a user