mirror of
https://github.com/opencontainers/runc.git
synced 2025-09-27 03:46:19 +08:00
criu: improve prepareCriuRestoreMounts
1. Replace the big "if !" block with the if block and continue,
simplifying the code flow.
2. Move comments closer to the code, improving readability.
This commit is best reviewed with --ignore-all-space or similar.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 0c93d41c65
)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -572,9 +572,6 @@ func (c *Container) prepareCriuRestoreMounts(mounts []*configs.Mount) error {
|
||||
tmpfs = append(tmpfs, m.Destination)
|
||||
}
|
||||
}
|
||||
// Now go through all mounts and create the mountpoints
|
||||
// if the mountpoints are not on a tmpfs, as CRIU will
|
||||
// restore the complete tmpfs content from its checkpoint.
|
||||
umounts := []string{}
|
||||
defer func() {
|
||||
for _, u := range umounts {
|
||||
@@ -590,8 +587,13 @@ func (c *Container) prepareCriuRestoreMounts(mounts []*configs.Mount) error {
|
||||
})
|
||||
}
|
||||
}()
|
||||
// Now go through all mounts and create the required mountpoints.
|
||||
for _, m := range mounts {
|
||||
if !isPathInPrefixList(m.Destination, tmpfs) {
|
||||
// If the mountpoint is on a tmpfs, skip it as CRIU will
|
||||
// restore the complete tmpfs content from its checkpoint.
|
||||
if isPathInPrefixList(m.Destination, tmpfs) {
|
||||
continue
|
||||
}
|
||||
if err := c.makeCriuRestoreMountpoints(m); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -613,7 +615,6 @@ func (c *Container) prepareCriuRestoreMounts(mounts []*configs.Mount) error {
|
||||
umounts = append(umounts, m.Destination)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user