Skip to content

Commit

Permalink
checkpoint: resolve symlink for external bind mount
Browse files Browse the repository at this point in the history
runc resolves symlink before doing bind mount. So
we should save original path while formatting CriuReq for
checkpoint.

Signed-off-by: Liu Hua <[email protected]>
  • Loading branch information
Liu Hua committed Apr 25, 2021
1 parent 2d38476 commit da22625
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,9 @@ const descriptorsFilename = "descriptors.json"

func (c *linuxContainer) addCriuDumpMount(req *criurpc.CriuReq, m *configs.Mount) {
mountDest := strings.TrimPrefix(m.Destination, c.config.Rootfs)
if dest, err := securejoin.SecureJoin(c.config.Rootfs, mountDest); err == nil {
mountDest = dest[len(c.config.Rootfs):]
}
extMnt := &criurpc.ExtMountMap{
Key: proto.String(mountDest),
Val: proto.String(mountDest),
Expand Down
13 changes: 12 additions & 1 deletion tests/integration/checkpoint.bats
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,18 @@ function simple_cr() {
done
}

@test "checkpoint and restore " {
@test "checkpoint and restore" {
simple_cr
}

@test "checkpoint and restore (bind mount, destination is symlink)" {
mkdir -p rootfs/real/conf
ln -s /real/conf rootfs/conf
update_config ' .mounts += [{
source: ".",
destination: "/conf",
options: ["bind"]
}]'
simple_cr
}

Expand Down

0 comments on commit da22625

Please sign in to comment.