From 45e303eea556a3b0a1f33642588262e9d6eca330 Mon Sep 17 00:00:00 2001 From: jerryzhuang Date: Wed, 6 Sep 2023 16:17:38 +0800 Subject: [PATCH] task: expose criu work path opt Signed-off-by: jerryzhuang --- task_opts.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/task_opts.go b/task_opts.go index 77554cee9..9dd8fcd02 100644 --- a/task_opts.go +++ b/task_opts.go @@ -92,7 +92,7 @@ func WithCheckpointImagePath(path string) CheckpointTaskOpts { } opts, ok := r.Options.(*options.CheckpointOptions) if !ok { - return errors.New("invalid v2 shim checkpoint options format") + return errors.New("invalid runtime v2 checkpoint options format") } opts.ImagePath = path return nil @@ -107,13 +107,28 @@ func WithRestoreImagePath(path string) NewTaskOpts { } opts, ok := ti.Options.(*options.Options) if !ok { - return errors.New("invalid v2 shim create options format") + return errors.New("invalid runtime v2 options format") } opts.CriuImagePath = path return nil } } +// WithRestoreWorkPath sets criu work path for create option +func WithRestoreWorkPath(path string) NewTaskOpts { + return func(ctx context.Context, c *Client, ti *TaskInfo) error { + if ti.Options == nil { + ti.Options = &options.Options{} + } + opts, ok := ti.Options.(*options.Options) + if !ok { + return errors.New("invalid runtime v2 options format") + } + opts.CriuWorkPath = path + return nil + } +} + // ProcessDeleteOpts allows the caller to set options for the deletion of a task type ProcessDeleteOpts func(context.Context, Process) error