Skip to content

Fixup "criu: support mounts where dest is a symlink" #1758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2025

Conversation

kolyshkin
Copy link
Collaborator

@kolyshkin kolyshkin commented May 22, 2025

This fixes issues brought by #1747, and also cherry-picks #1756 so that the changes can be tested.

Summary by Sourcery

Fix CRIU checkpoint and restore procedures to support bind mounts where the destination in rootfs is a symlink

Bug Fixes:

  • Fall back to using the original mount destination when chroot_realpath fails with ENOENT instead of erroring out

Enhancements:

  • Resolve mount destinations against status->rootfs directly and remove redundant path concatenation in restore
  • Rename internal rootfs variable to path in checkpoint function

kolyshkin added 2 commits May 21, 2025 20:00
Commit e0b0158 "criu: support mounts where dest is a symlink" brought
in a few issues.

First, the concatenation of status->bundle and status->rootfs do not
make any sense (and I'm not yet sure why it is used as CRIU root).
Revert to using status->rootfs directly.

Second, if chroot_resolve returns ENOENT, it is OK (not all paths are
visible from the host -- some are only inside the mount namespace).
In this case, use the destination as is.

This should fix podman checkpoint failures.

Signed-off-by: Kir Kolyshkin <[email protected]>
This reverts commit 55498c1.

Signed-off-by: Kir Kolyshkin <[email protected]>
Copy link

sourcery-ai bot commented May 22, 2025

Reviewer's Guide

Refactor CRIU root path handling by renaming internal variables, remove redundant rootfs setup in restore, and improve external bind mount resolution to handle symlink destinations and missing paths gracefully.

Sequence Diagram: Updated External Mount Path Resolution in CRIU Checkpoint

sequenceDiagram
    participant C as libcrun_container_checkpoint_linux_criu
    participant CRR as chroot_realpath
    participant LCW as libcriu_wrapper

    C->>CRR: Call chroot_realpath(status->rootfs, mount->destination, buf)
    CRR-->>C: Return resolved_path_absolute or NULL
    alt resolved_path_absolute is NULL
        C->>C: Check errno
        alt errno is ENOENT
            C->>C: dest_in_root = mount->destination
        else errno is not ENOENT
            C->>C: Handle error (unable to resolve mount)
        end
    else resolved_path_absolute is not NULL
        C->>C: dest_in_root = resolved_path_absolute + strlen(status->rootfs)
    end
    C->>LCW: criu_add_ext_mount(dest_in_root, dest_in_root)
Loading

Sequence Diagram: Updated External Mount Path Resolution in CRIU Restore

sequenceDiagram
    participant R as libcrun_container_restore_linux_criu
    participant CRR as chroot_realpath
    participant LCW as libcriu_wrapper

    R->>CRR: Call chroot_realpath(status->rootfs, mount->destination, buf)
    CRR-->>R: Return resolved_path_absolute or NULL
    alt resolved_path_absolute is NULL
        R->>R: Check errno
        alt errno is ENOENT
            R->>R: dest_in_root = mount->destination
        else errno is not ENOENT
            R->>R: Handle error (unable to resolve mount)
        end
    else resolved_path_absolute is not NULL
        R->>R: dest_in_root = resolved_path_absolute + strlen(status->rootfs)
    end
    R->>LCW: criu_add_ext_mount(dest_in_root, mount->source)
Loading

File-Level Changes

Change Details Files
Rename and consolidate CRIU root path variable in checkpoint
  • Rename cleanup_free char *rootfs to cleanup_free char *path
  • Update append_paths invocation to populate path
  • Change criu_set_root calls and error messages to reference path
src/libcrun/criu.c
Enhance external bind mount resolution logic
  • Switch chroot_realpath base from previous root variable to status->rootfs
  • Introduce ENOENT branch to fallback to original destination when not under rootfs
  • Adjust dest_in_root pointer arithmetic accordingly
  • Refine error messages for mount resolution failures
src/libcrun/criu.c
Remove redundant rootfs setup in restore function
  • Eliminate local rootfs variable and its append_paths call in restore
  • Simplify restore mount loop to use status->rootfs directly
src/libcrun/criu.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

`podman checkpoint...` tests depend on crun as well so they should be
included in the TMT system test runs. These are currently failing on
podman upstream PRs, for example: [0], [1] and [2].

[0]: https://artifacts.dev.testing-farm.io/fd5c08eb-2b0d-4ea8-9c33-ac9bf3447bd8/
[1]: https://artifacts.dev.testing-farm.io/e227ef00-c5c4-43e6-9785-0b5b5fcd2908/
[2]: https://artifacts.dev.testing-farm.io/c4ef6e7a-3b5d-4afc-91b9-dd477ef699e3/

Signed-off-by: Lokesh Mandvekar <[email protected]>
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kolyshkin - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

TMT tests failed. @containers/packit-build please check.

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@lsm5 lsm5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podman checkpoint tests pass. So, LGTM from me.

@lsm5
Copy link
Member

lsm5 commented May 22, 2025

Looks like centos stream 10 has issues with criu. I remember we've had issues with criu in the past on centos targets. Maybe we can ignore it here and I'll remove centos job in another PR.

@lsm5
Copy link
Member

lsm5 commented May 22, 2025

/packit retest-failed

Copy link

Account lsm5 has no write access nor is author of PR!

@lsm5
Copy link
Member

lsm5 commented May 22, 2025

Looks like centos stream 10 has issues with criu.

It's only x86_64 failing, so let me know how you'd prefer to deal with that. I don't have access to retry the failed test.

@giuseppe
Copy link
Member

Looks like centos stream 10 has issues with criu.

It's only x86_64 failing, so let me know how you'd prefer to deal with that. I don't have access to retry the failed test.

does not look like a flake, I've retried it

@lsm5
Copy link
Member

lsm5 commented May 22, 2025

I suggest we get this PR in asap as that would make CI green in podman and some other places where I'm trying to get revdep testing with podman. Maybe the cs10 test failure can be done elsewhere? I'd be happy to disable it for the time being if that helps.

@giuseppe giuseppe merged commit b973373 into containers:main May 22, 2025
78 of 80 checks passed
lsm5 added a commit to lsm5/crun that referenced this pull request May 22, 2025
lsm5 added a commit to lsm5/crun that referenced this pull request May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants