Skip to content

[WIP] Add basic restore implementation#3429

Draft
nayuta723 wants to merge 4 commits intoyouki-dev:mainfrom
nayuta723:add-restore
Draft

[WIP] Add basic restore implementation#3429
nayuta723 wants to merge 4 commits intoyouki-dev:mainfrom
nayuta723:add-restore

Conversation

@nayuta723
Copy link
Copy Markdown
Contributor

@nayuta723 nayuta723 commented Feb 27, 2026

Description

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test updates
  • CI/CD related changes
  • Other (please describe):

Testing

  • Added new unit tests
  • Added new integration tests
  • Ran existing test suite
  • Tested manually (please provide steps)
$ sudo podman run --runtime youki -dt fedora bash -c "v=0;while true;do sleep 1; echo \"\$v\"; let \"v++\";do
ne;"
DEBUG youki: started by user 0 with ArgsOs { inner: ["/usr/local/bin/youki", "start", "cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32"] }
DEBUG libcontainer::notify_socket: notify container start
DEBUG libcontainer::notify_socket: notify finished
DEBUG libcontainer::container::container: Save container status: Container { state: State { oci_version: "v1.0.2", id: "cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32", status: Running, pid: Some(80124), bundle: "/var/lib/containers/storage/overlay-containers/cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32/userdata", annotations: Some({"org.opencontainers.image.stopSignal": "15", "io.container.manager": "libpod"}), created: Some(2026-01-12T07:43:28.114251896Z), creator: Some(0), use_systemd: true, clean_up_intel_rdt_subdirectory: Some(false) }, root: "/run/youki/cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32", criu_version: None } in "/run/youki/cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32"
cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32
$ sudo podman attach cb2f992ddbbe --detach-keys=a
DEBUG youki: started by user 0 with ArgsOs { inner: ["/usr/local/bin/youki", "kill", "cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32", "28"] }
                      DEBUG libcontainer::container::container_kill: kill signal SIGWINCH to 80124
                             ERROR libcontainer::container::container_kill: failed to kill process id="cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32" err=EACCES pid=Pid(80124) signal=SIGWINCH
   ERROR youki: error in executing command: failed to kill container

                                                                    Caused by:
             0: syscall error
                                 1: EACCES: Permission denied
                                                             error in executing command: failed to kill container

                                            Caused by:
                                                          0: syscall error
         1: EACCES: Permission denied
                                     Error: failed to kill container

                                                                    Caused by:
             0: syscall error
                                 1: EACCES: Permission denied
                                                             WARN[0000] Unable to send SIGWINCH to container cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32 after attach: sending signal to container cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32: `/usr/local/bin/youki kill cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32 28` failed: exit status 1 
14
$ sudo podman container checkpoint cb2f992ddbbe
DEBUG youki: started by user 0 with ArgsOs { inner: ["/usr/local/bin/youki", "checkpoint", "--image-path", "/var/lib/containers/storage/overlay-containers/cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32/userdata/checkpoint", "--work-path", "/var/lib/containers/storage/overlay-containers/cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32/userdata", "cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32"] }
DEBUG youki::commands::checkpoint: start checkpointing container cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32
DEBUG libcontainer::container::container_criu: adding external namespace for checkpoint external="net[4026532371]:extRootNetNS"
DEBUG libcontainer::container::container: Save container status: Container { state: State { oci_version: "v1.0.2", id: "cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32", status: Stopped, pid: Some(80124), bundle: "/var/lib/containers/storage/overlay-containers/cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32/userdata", annotations: Some({"io.container.manager": "libpod", "org.opencontainers.image.stopSignal": "15"}), created: Some(2026-01-12T07:43:28.114251896Z), creator: Some(0), use_systemd: true, clean_up_intel_rdt_subdirectory: Some(false) }, root: "/run/youki/cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32", criu_version: Some(40200) } in "/run/youki/cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32"
DEBUG libcontainer::container::container_checkpoint: container cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32 checkpointed
DEBUG youki: started by user 0 with ArgsOs { inner: ["/usr/local/bin/youki", "delete", "--force", "cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32"] }
DEBUG youki::commands::delete: start deleting cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32
DEBUG libcontainer::container::container_delete: container status: Stopped
DEBUG libcontainer::container::container_delete: config: YoukiConfig { hooks: None, cgroup_path: "machine.slice:libpod:cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32" }
 INFO libcgroups::common: systemd cgroup manager with system bus true will be used
DEBUG libcgroups::systemd::manager: remove libpod-cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32.scope
DEBUG libcontainer::container::container_delete: remove dir "/run/youki/cb2f992ddbbe56435225c177f9ad5dd6d8eccec92bffcfd88737a9a77dd81d32"
cb2f992ddbbe
$ sudo podman container restore cb2f992ddbbe
cb2f992ddbbe
$ sudo podman ps
CONTAINER ID  IMAGE                                     COMMAND               CREATED         STATUS         PORTS       NAMES
cb2f992ddbbe  registry.fedoraproject.org/fedora:latest  bash -c v=0;while...  56 minutes ago  Up 56 minutes              peaceful_agnesi

Related Issues

closed #2335

Additional Context

ToDo

  • Add contest for checkpoint/restore
  • Use the correct import path for rust-criu

@nayuta723 nayuta723 changed the title Add restore Add basic restore implementation Feb 27, 2026
@nayuta723 nayuta723 changed the title Add basic restore implementation [WIP] Add basic restore implementation Mar 1, 2026
Update rust-criu rev to f405cdc1401f642a0640d3704be54618872b7811 and
refactor restore/criu code to match its changed API:

- Replace Notify trait impl with NotifyCallback fn pointer; use
  thread_local! RESTORE_CTX to share container state and console socket
  across the fn pointer boundary
- Remove RestoreOpts and restore_notify(); call criu.restore() directly
- Replace set_inherit_fd(key, fd) with add_inherit_fd(fd, &key) and
  remove manual fd offset calculation
- Clear FD_CLOEXEC on namespace fds so CRIU inherits them via fork/exec,
  since the new rust-criu passes the original fd number in the protobuf
  and relies on fd inheritance rather than SCM_RIGHTS for inherit_fd

Signed-off-by: nayuta723 <nayuta723@gmail.com>
…ased TODOs

Replace the inline runc-based TODO comment block with a doc string on
Container::checkpoint() that documents what is currently implemented and
lists unimplemented features as TODO items based on crun's
libcrun_container_checkpoint_linux_criu implementation.

Signed-off-by: nayuta723 <nayuta723@gmail.com>
… fd)

Update rust-criu from f405cdc to fd2fe0a (add-orphan-pts-console-socket-callback
branch). The new version changes the NotifyCallback signature:
- fds: &[RawFd] -> fd: Option<RawFd>
- set_external() renamed to add_external()
- add_inherit_fd() now returns Result

Update call sites accordingly.

Signed-off-by: nayuta723 <nayuta723@gmail.com>
The lifecycle checkpoint test was passing "checkpointt" (double 't')
as the subcommand when running against the youki runtime, which would
cause checkpoint tests to fail. Remove the runtime-specific match
expression and use the correct "checkpoint" subcommand uniformly.

Also reformat a long import in container_checkpoint.rs for clarity.

Signed-off-by: nayuta723 <nayuta723@gmail.com>
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.

Implement container restore functionality

1 participant