diff options
author | Adrian Reber <areber@redhat.com> | 2019-02-28 17:24:08 +0000 |
---|---|---|
committer | Adrian Reber <adrian@lisas.de> | 2019-03-01 08:08:55 +0100 |
commit | 43fe2bf064a4c7e7e24f35abd76acc5add6cc09a (patch) | |
tree | e11d7076521a0302b6385c55e7b20a728972a1f6 /libpod/oci.go | |
parent | 5afae0b25bba4e2274747b32cf8b3bc929daf06e (diff) | |
download | podman-43fe2bf064a4c7e7e24f35abd76acc5add6cc09a.tar.gz podman-43fe2bf064a4c7e7e24f35abd76acc5add6cc09a.tar.bz2 podman-43fe2bf064a4c7e7e24f35abd76acc5add6cc09a.zip |
Verify that used OCI runtime supports checkpoint
To be able to use OCI runtimes which do not implement checkpoint/restore
this adds a check to the checkpoint code path and the checkpoint/restore
tests to see if it knows about the checkpoint subcommand. If the used
OCI runtime does not implement checkpoint/restore the tests are skipped
and the actual 'podman container checkpoint' returns an error.
Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'libpod/oci.go')
-rw-r--r-- | libpod/oci.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libpod/oci.go b/libpod/oci.go index 26d2c6ef1..e4ed66928 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -890,3 +890,16 @@ func (r *OCIRuntime) checkpointContainer(ctr *Container, options ContainerCheckp args = append(args, ctr.ID()) return utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, nil, r.path, args...) } + +func (r *OCIRuntime) featureCheckCheckpointing() bool { + // Check if the runtime implements checkpointing. Currently only + // runc's checkpoint/restore implementation is supported. + cmd := exec.Command(r.path, "checkpoint", "-h") + if err := cmd.Start(); err != nil { + return false + } + if err := cmd.Wait(); err == nil { + return true + } + return false +} |