restore: fix bind mounts with a relative source, nested bind mounts - #2240
Merged
Merged
Conversation
kolyshkin
force-pushed
the
cr-restore-relative-bind
branch
from
September 11, 2026 01:46
c6e1a1b to
dcef41d
Compare
Member
|
there is a conflict |
A relative bind mount source is relative to the bundle, but it is passed to CRIU as is, and so CRIU resolves it relative to its own working directory, failing with something like: Error (criu/mount-v2.c:319): mnt-v2: Failed to open_tree ./tmp.opElJ45fj6: No such file or directory Make the source absolute before passing it to CRIU. Found by the "checkpoint and restore with nested bind mounts" runc integration test. Signed-off-by: Kir Kolyshkin <[email protected]>
Before restore, crun recreates the mountpoints which do not exist in the container rootfs, as it is done on the container creation. Yet, unlike the container creation, the bind mounts are not mounted at this time, so the mountpoint of a mount which is inside a bind mount (e.g. a nested bind mount) is created in the rootfs underneath the bind mount, rather than in the bind mount source. As a result, if the mountpoint does not exist in the source, restore fails with something like: Error (criu/mount-v2.c:634): mnt-v2: Can't stat mountpoint /tmp/.criu.mntns.bAeDM2/mnt-0000000147/for/nested: No such file or directory Do what runc does: temporarily mount the bind mounts while creating the mountpoints, and unmount them afterwards, as CRIU restores the mounts itself. Unlike runc, do not use recursive bind mounts: the source might contain the restore root itself (e.g. when it is the bundle directory, as crun mounts the rootfs under the bundle for CRIU), resulting in a mess which brings down the restore root when unmounted. Found by the "checkpoint and restore with nested bind mounts" runc integration test. Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin
force-pushed
the
cr-restore-relative-bind
branch
from
September 11, 2026 16:13
dcef41d to
b5c8fdf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
restore: fix bind mounts with a relative source
A relative bind mount source is relative to the bundle, but it is passed to CRIU as is, and so CRIU resolves it relative to its own working directory, failing with something like:
Make the source absolute before passing it to CRIU.
restore: create mountpoints inside bind mount sources
Before restore, crun recreates the mountpoints which do not exist in the container rootfs, as it is done on the container creation. Yet, unlike the container creation, the bind mounts are not mounted at this time, so the mountpoint of a mount which is inside a bind mount (e.g. a nested bind mount) is created in the rootfs underneath the bind mount, rather than in the bind mount source. As a result, if the mountpoint does not exist in the source, restore fails with something like:
Do what runc does: temporarily mount the bind mounts while creating the mountpoints, and unmount them afterwards, as CRIU restores the mounts itself.
Unlike runc, do not use recursive bind mounts: the source might contain the restore root itself (e.g. when it is the bundle directory, as crun mounts the rootfs under the bundle for CRIU), resulting in a mess which brings down the restore root when unmounted.
Found by the "checkpoint and restore with nested bind mounts" runc integration test (see #2238).