checkpoint: validate parent path

`--parent-path` needs to be relative path of `--image-path`,
and points to previous checkpoint directory.

Signed-off-by: Liu Hua <weldonliu@tencent.com>
This commit is contained in:
Liu Hua
2021-04-21 20:08:08 +08:00
parent aa62272382
commit 23e3794d9c
3 changed files with 49 additions and 5 deletions
+4 -3
View File
@@ -121,14 +121,15 @@ using the runc checkpoint command.`,
}
func criuOptions(context *cli.Context) *libcontainer.CriuOpts {
imagePath := getCheckpointImagePath(context)
if err := os.MkdirAll(imagePath, 0755); err != nil {
imagePath, parentPath, err := prepareImagePaths(context)
if err != nil {
fatal(err)
}
return &libcontainer.CriuOpts{
ImagesDirectory: imagePath,
WorkDirectory: context.String("work-path"),
ParentImage: context.String("parent-path"),
ParentImage: parentPath,
LeaveRunning: context.Bool("leave-running"),
TcpEstablished: context.Bool("tcp-established"),
ExternalUnixConnections: context.Bool("ext-unix-sk"),