diff --git a/create.go b/create.go index 5f3ac6095..a27e7c45f 100644 --- a/create.go +++ b/create.go @@ -55,14 +55,7 @@ command(s) that get executed on start, edit the args parameter of the spec. See if err := checkArgs(context, 1, exactArgs); err != nil { return err } - if err := revisePidFile(context); err != nil { - return err - } - spec, err := setupSpec(context) - if err != nil { - return err - } - status, err := startContainer(context, spec, CT_ACT_CREATE, nil) + status, err := startContainer(context, CT_ACT_CREATE, nil) if err != nil { return err } diff --git a/restore.go b/restore.go index 4e2841ba2..5f6c72d0d 100644 --- a/restore.go +++ b/restore.go @@ -104,15 +104,11 @@ using the runc checkpoint command.`, logrus.Warn("runc checkpoint is untested with rootless containers") } - spec, err := setupSpec(context) - if err != nil { - return err - } options := criuOptions(context) if err := setEmptyNsMask(context, options); err != nil { return err } - status, err := startContainer(context, spec, CT_ACT_RESTORE, options) + status, err := startContainer(context, CT_ACT_RESTORE, options) if err != nil { return err } diff --git a/run.go b/run.go index c3b184716..4c46f4f6c 100644 --- a/run.go +++ b/run.go @@ -68,14 +68,7 @@ command(s) that get executed on start, edit the args parameter of the spec. See if err := checkArgs(context, 1, exactArgs); err != nil { return err } - if err := revisePidFile(context); err != nil { - return err - } - spec, err := setupSpec(context) - if err != nil { - return err - } - status, err := startContainer(context, spec, CT_ACT_RUN, nil) + status, err := startContainer(context, CT_ACT_RUN, nil) if err == nil { // exit with the container's exit status so any external supervisor is // notified of the exit with the correct exit status. diff --git a/utils_linux.go b/utils_linux.go index 5404f2eb9..11957f781 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -395,7 +395,15 @@ const ( CT_ACT_RESTORE ) -func startContainer(context *cli.Context, spec *specs.Spec, action CtAct, criuOpts *libcontainer.CriuOpts) (int, error) { +func startContainer(context *cli.Context, action CtAct, criuOpts *libcontainer.CriuOpts) (int, error) { + if err := revisePidFile(context); err != nil { + return -1, err + } + spec, err := setupSpec(context) + if err != nil { + return -1, err + } + id := context.Args().First() if id == "" { return -1, errEmptyID