diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-12-23 10:44:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-23 10:44:10 +0100 |
commit | 1415b0732d07f62a6146c16167d38411242436b3 (patch) | |
tree | 0ebb9e18e87142ee164b8c7e4e41da25a58e3a5e /libpod | |
parent | 74a58faf2a54a9a063efc69371af7d81d335ba21 (diff) | |
parent | 207823eb058b3a518b1a1182d27c216714c814cd (diff) | |
download | podman-1415b0732d07f62a6146c16167d38411242436b3.tar.gz podman-1415b0732d07f62a6146c16167d38411242436b3.tar.bz2 podman-1415b0732d07f62a6146c16167d38411242436b3.zip |
Merge pull request #12665 from rst0git/dev-shm
Enable checkpoint/restore of /dev/shm content
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_internal_linux.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 0226f30c7..62e198d7c 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -990,6 +990,7 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error { includeFiles := []string{ "artifacts", + metadata.DevShmCheckpointTar, metadata.ConfigDumpFile, metadata.SpecDumpFile, metadata.NetworkStatusFile, @@ -1143,6 +1144,29 @@ func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointO return nil, 0, err } + // Keep the content of /dev/shm directory + if c.config.ShmDir != "" && c.state.BindMounts["/dev/shm"] == c.config.ShmDir { + shmDirTarFileFullPath := filepath.Join(c.bundlePath(), metadata.DevShmCheckpointTar) + + shmDirTarFile, err := os.Create(shmDirTarFileFullPath) + if err != nil { + return nil, 0, err + } + defer shmDirTarFile.Close() + + input, err := archive.TarWithOptions(c.config.ShmDir, &archive.TarOptions{ + Compression: archive.Uncompressed, + IncludeSourceDir: true, + }) + if err != nil { + return nil, 0, err + } + + if _, err = io.Copy(shmDirTarFile, input); err != nil { + return nil, 0, err + } + } + // Save network.status. This is needed to restore the container with // the same IP. Currently limited to one IP address in a container // with one interface. @@ -1486,6 +1510,24 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti } } + // Restore /dev/shm content + if c.config.ShmDir != "" && c.state.BindMounts["/dev/shm"] == c.config.ShmDir { + shmDirTarFileFullPath := filepath.Join(c.bundlePath(), metadata.DevShmCheckpointTar) + if _, err := os.Stat(shmDirTarFileFullPath); err != nil { + logrus.Debug("Container checkpoint doesn't contain dev/shm: ", err.Error()) + } else { + shmDirTarFile, err := os.Open(shmDirTarFileFullPath) + if err != nil { + return nil, 0, err + } + defer shmDirTarFile.Close() + + if err := archive.UntarUncompressed(shmDirTarFile, c.config.ShmDir, nil); err != nil { + return nil, 0, err + } + } + } + // Cleanup for a working restore. if err := c.removeConmonFiles(); err != nil { return nil, 0, err |