Skip to content

Commit a97c49f

Browse files
kolyshkinlifubang
authored andcommitted
criu: ignore cgroup early in prepareCriuRestoreMounts
It makes sense to ignore cgroup mounts much early in the code, saving some time on unnecessary operations. Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit b8aa548) Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 017d6b6 commit a97c49f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

libcontainer/criu_linux.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -527,19 +527,8 @@ func (c *Container) restoreNetwork(req *criurpc.CriuReq, criuOpts *CriuOpts) {
527527
// restore using CRIU. This function is inspired from the code in
528528
// rootfs_linux.go.
529529
func (c *Container) makeCriuRestoreMountpoints(m *configs.Mount) error {
530-
if m.Device == "cgroup" {
531-
// No mount point(s) need to be created:
532-
//
533-
// * for v1, mount points are saved by CRIU because
534-
// /sys/fs/cgroup is a tmpfs mount
535-
//
536-
// * for v2, /sys/fs/cgroup is a real mount, but
537-
// the mountpoint appears as soon as /sys is mounted
538-
return nil
539-
}
540530
// TODO: pass srcFD? Not sure if criu is impacted by issue #2484.
541531
me := mountEntry{Mount: m}
542-
// For all other filesystems, just make the target.
543532
if _, err := createMountpoint(c.config.Rootfs, me); err != nil {
544533
return fmt.Errorf("create criu restore mountpoint for %s mount: %w", me.Destination, err)
545534
}
@@ -589,6 +578,14 @@ func (c *Container) prepareCriuRestoreMounts(mounts []*configs.Mount) error {
589578
}()
590579
// Now go through all mounts and create the required mountpoints.
591580
for _, m := range mounts {
581+
// No cgroup mount point(s) need to be created:
582+
// * for v1, mount points are saved by CRIU because
583+
// /sys/fs/cgroup is a tmpfs mount;
584+
// * for v2, /sys/fs/cgroup is a real mount, but
585+
// the mountpoint appears as soon as /sys is mounted.
586+
if m.Device == "cgroup" {
587+
continue
588+
}
592589
// If the mountpoint is on a tmpfs, skip it as CRIU will
593590
// restore the complete tmpfs content from its checkpoint.
594591
if isPathInPrefixList(m.Destination, tmpfs) {

0 commit comments

Comments
 (0)