Skip to content

Commit 6e1d476

Browse files
committed
runc: remove --criu option
This was introduced in an initial commit, back in the day when criu was a highly experimental thing. Today it's not; most users who need it have it packaged by their distro vendor. The usual way to run a binary is to look it up in directories listed in $PATH. This is flexible enough and allows for multiple scenarios (custom binaries, extra binaries, etc.). This is the way criu should be run. Make --criu a hidden option (thus removing it from help). Remove the option from man pages, integration tests, etc. Remove all traces of CriuPath from data structures. Add a warning that --criu is ignored and will be removed. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 403cda1 commit 6e1d476

File tree

9 files changed

+37
-51
lines changed

9 files changed

+37
-51
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Deprecated
10+
11+
* `runc` option `--criu` is now ignored (with a warning), and the option will
12+
be removed entirely in a future release. Users who need a non-standard
13+
`criu` binary should rely on the standard way of looking up binaries in
14+
`$PATH`. (#3316)
15+
916
### Changed
1017

1118
* When Intel RDT feature is not available, its initialization is skipped,

contrib/completions/bash/runc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,11 @@ _runc_runc() {
231231
--log
232232
--log-format
233233
--root
234-
--criu
235234
--rootless
236235
"
237236

238237
case "$prev" in
239-
--log | --root | --criu)
238+
--log | --root)
240239
case "$cur" in
241240
*:*) ;; # TODO somehow do _filedir for stuff inside the image, if it's already specified (which is also somewhat difficult to determine)
242241
'')

libcontainer/container_linux.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ type linuxContainer struct {
4545
initArgs []string
4646
initProcess parentProcess
4747
initProcessStartTime uint64
48-
criuPath string
4948
newuidmapPath string
5049
newgidmapPath string
5150
m sync.Mutex
@@ -829,7 +828,6 @@ func (c *linuxContainer) checkCriuVersion(minVersion int) error {
829828
}
830829

831830
criu := criu.MakeCriu()
832-
criu.SetCriuPath(c.criuPath)
833831
var err error
834832
c.criuVersion, err = criu.GetCriuVersion()
835833
if err != nil {
@@ -1602,13 +1600,12 @@ func (c *linuxContainer) criuSwrk(process *Process, req *criurpc.CriuReq, opts *
16021600
criuServer := os.NewFile(uintptr(fds[1]), "criu-transport-server")
16031601
defer criuServer.Close()
16041602

1605-
args := []string{"swrk", "3"}
16061603
if c.criuVersion != 0 {
16071604
// If the CRIU Version is still '0' then this is probably
16081605
// the initial CRIU run to detect the version. Skip it.
1609-
logrus.Debugf("Using CRIU %d at: %s", c.criuVersion, c.criuPath)
1606+
logrus.Debugf("Using CRIU %d", c.criuVersion)
16101607
}
1611-
cmd := exec.Command(c.criuPath, args...)
1608+
cmd := exec.Command("criu", "swrk", "3")
16121609
if process != nil {
16131610
cmd.Stdin = process.Stdin
16141611
cmd.Stdout = process.Stdout

libcontainer/factory_linux.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ func TmpfsRoot(l *LinuxFactory) error {
7676
return nil
7777
}
7878

79-
// CriuPath returns an option func to configure a LinuxFactory with the
80-
// provided criupath
81-
func CriuPath(criupath string) func(*LinuxFactory) error {
82-
return func(l *LinuxFactory) error {
83-
l.CriuPath = criupath
84-
return nil
85-
}
86-
}
87-
8879
// New returns a linux based container factory based in the root directory and
8980
// configures the factory with the provided option funcs.
9081
func New(root string, options ...func(*LinuxFactory) error) (Factory, error) {
@@ -98,7 +89,6 @@ func New(root string, options ...func(*LinuxFactory) error) (Factory, error) {
9889
InitPath: "/proc/self/exe",
9990
InitArgs: []string{os.Args[0], "init"},
10091
Validator: validate.New(),
101-
CriuPath: "criu",
10292
}
10393

10494
for _, opt := range options {
@@ -125,10 +115,6 @@ type LinuxFactory struct {
125115
// a container.
126116
InitArgs []string
127117

128-
// CriuPath is the path to the criu binary used for checkpoint and restore of
129-
// containers.
130-
CriuPath string
131-
132118
// New{u,g}idmapPath is the path to the binaries used for mapping with
133119
// rootless containers.
134120
NewuidmapPath string
@@ -204,7 +190,6 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
204190
config: config,
205191
initPath: l.InitPath,
206192
initArgs: l.InitArgs,
207-
criuPath: l.CriuPath,
208193
newuidmapPath: l.NewuidmapPath,
209194
newgidmapPath: l.NewgidmapPath,
210195
cgroupManager: cm,
@@ -248,7 +233,6 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
248233
config: &state.Config,
249234
initPath: l.InitPath,
250235
initArgs: l.InitArgs,
251-
criuPath: l.CriuPath,
252236
newuidmapPath: l.NewuidmapPath,
253237
newgidmapPath: l.NewgidmapPath,
254238
cgroupManager: cm,

main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ func main() {
101101
Usage: "root directory for storage of container state (this should be located in tmpfs)",
102102
},
103103
cli.StringFlag{
104-
Name: "criu",
105-
Value: "criu",
106-
Usage: "path to the criu binary used for checkpoint and restore",
104+
Name: "criu",
105+
Usage: "(obsoleted; do not use)",
106+
Hidden: true,
107107
},
108108
cli.BoolFlag{
109109
Name: "systemd-cgroup",
@@ -151,6 +151,10 @@ func main() {
151151
if err := reviseRootDir(context); err != nil {
152152
return err
153153
}
154+
// TODO: remove this in runc 1.3.0.
155+
if context.IsSet("criu") {
156+
fmt.Fprintln(os.Stderr, "WARNING: --criu ignored (criu binary from $PATH is used); do not use")
157+
}
154158

155159
return configLogrus(context)
156160
}

man/runc.8.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ These options can be used with any command, and must precede the **command**.
110110
located on tmpfs. Default is */run/runc*, or *$XDG_RUNTIME_DIR/runc* for
111111
rootless containers.
112112

113-
**--criu** _path_
114-
: Set the path to the **criu**(8) binary used for checkpoint and restore.
115-
Default is **criu**.
116-
117113
**--systemd-cgroup**
118114
: Enable systemd cgroup support. If this is set, the container spec
119115
(_config.json_) is expected to have **cgroupsPath** value in the

tests/integration/checkpoint.bats

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function runc_restore_with_pipes() {
8484
shift
8585

8686
ret=0
87-
__runc --criu "$CRIU" restore -d --work-path "$workdir" --image-path ./image-dir "$@" "$name" <&${in_r} >&${out_w} 2>&${err_w} || ret=$?
87+
__runc restore -d --work-path "$workdir" --image-path ./image-dir "$@" "$name" <&${in_r} >&${out_w} 2>&${err_w} || ret=$?
8888
if [ "$ret" -ne 0 ]; then
8989
echo "__runc restore $name failed (status: $ret)"
9090
exec {err_w}>&-
@@ -109,15 +109,15 @@ function simple_cr() {
109109

110110
for _ in $(seq 2); do
111111
# checkpoint the running container
112-
runc --criu "$CRIU" "$@" checkpoint --work-path ./work-dir test_busybox
112+
runc "$@" checkpoint --work-path ./work-dir test_busybox
113113
grep -B 5 Error ./work-dir/dump.log || true
114114
[ "$status" -eq 0 ]
115115

116116
# after checkpoint busybox is no longer running
117117
testcontainer test_busybox checkpointed
118118

119119
# restore from checkpoint
120-
runc --criu "$CRIU" "$@" restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
120+
runc "$@" restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
121121
grep -B 5 Error ./work-dir/restore.log || true
122122
[ "$status" -eq 0 ]
123123

@@ -162,12 +162,12 @@ function simple_cr() {
162162
testcontainer test_busybox running
163163

164164
# runc should fail with absolute parent image path.
165-
runc --criu "$CRIU" checkpoint --parent-path "$(pwd)"/parent-dir --work-path ./work-dir --image-path ./image-dir test_busybox
165+
runc checkpoint --parent-path "$(pwd)"/parent-dir --work-path ./work-dir --image-path ./image-dir test_busybox
166166
[[ "${output}" == *"--parent-path"* ]]
167167
[ "$status" -ne 0 ]
168168

169169
# runc should fail with invalid parent image path.
170-
runc --criu "$CRIU" checkpoint --parent-path ./parent-dir --work-path ./work-dir --image-path ./image-dir test_busybox
170+
runc checkpoint --parent-path ./parent-dir --work-path ./work-dir --image-path ./image-dir test_busybox
171171
[[ "${output}" == *"--parent-path"* ]]
172172
[ "$status" -ne 0 ]
173173
}
@@ -178,7 +178,7 @@ function simple_cr() {
178178

179179
#test checkpoint pre-dump
180180
mkdir parent-dir
181-
runc --criu "$CRIU" checkpoint --pre-dump --image-path ./parent-dir test_busybox
181+
runc checkpoint --pre-dump --image-path ./parent-dir test_busybox
182182
[ "$status" -eq 0 ]
183183

184184
# busybox should still be running
@@ -187,7 +187,7 @@ function simple_cr() {
187187
# checkpoint the running container
188188
mkdir image-dir
189189
mkdir work-dir
190-
runc --criu "$CRIU" checkpoint --parent-path ../parent-dir --work-path ./work-dir --image-path ./image-dir test_busybox
190+
runc checkpoint --parent-path ../parent-dir --work-path ./work-dir --image-path ./image-dir test_busybox
191191
grep -B 5 Error ./work-dir/dump.log || true
192192
[ "$status" -eq 0 ]
193193

@@ -203,7 +203,7 @@ function simple_cr() {
203203

204204
@test "checkpoint --lazy-pages and restore" {
205205
# check if lazy-pages is supported
206-
if ! "${CRIU}" check --feature uffd-noncoop; then
206+
if ! criu check --feature uffd-noncoop; then
207207
skip "this criu does not support lazy migration"
208208
fi
209209

@@ -224,7 +224,7 @@ function simple_cr() {
224224
# TCP port for lazy migration
225225
port=27277
226226

227-
__runc --criu "$CRIU" checkpoint --lazy-pages --page-server 0.0.0.0:${port} --status-fd ${lazy_w} --work-path ./work-dir --image-path ./image-dir test_busybox &
227+
__runc checkpoint --lazy-pages --page-server 0.0.0.0:${port} --status-fd ${lazy_w} --work-path ./work-dir --image-path ./image-dir test_busybox &
228228
cpt_pid=$!
229229

230230
# wait for lazy page server to be ready
@@ -242,7 +242,7 @@ function simple_cr() {
242242
[ -e image-dir/inventory.img ]
243243

244244
# Start CRIU in lazy-daemon mode
245-
${CRIU} lazy-pages --page-server --address 127.0.0.1 --port ${port} -D image-dir &
245+
criu lazy-pages --page-server --address 127.0.0.1 --port ${port} -D image-dir &
246246
lp_pid=$!
247247

248248
# Restore lazily from checkpoint.
@@ -264,7 +264,7 @@ function simple_cr() {
264264

265265
@test "checkpoint and restore in external network namespace" {
266266
# check if external_net_ns is supported; only with criu 3.10++
267-
if ! "${CRIU}" check --feature external_net_ns; then
267+
if ! criu check --feature external_net_ns; then
268268
# this criu does not support external_net_ns; skip the test
269269
skip "this criu does not support external network namespaces"
270270
fi
@@ -290,15 +290,15 @@ function simple_cr() {
290290
for _ in $(seq 2); do
291291
# checkpoint the running container; this automatically tells CRIU to
292292
# handle the network namespace defined in config.json as an external
293-
runc --criu "$CRIU" checkpoint --work-path ./work-dir test_busybox
293+
runc checkpoint --work-path ./work-dir test_busybox
294294
grep -B 5 Error ./work-dir/dump.log || true
295295
[ "$status" -eq 0 ]
296296

297297
# after checkpoint busybox is no longer running
298298
testcontainer test_busybox checkpointed
299299

300300
# restore from checkpoint; this should restore the container into the existing network namespace
301-
runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
301+
runc restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
302302
grep -B 5 Error ./work-dir/restore.log || true
303303
[ "$status" -eq 0 ]
304304

@@ -341,7 +341,7 @@ function simple_cr() {
341341
testcontainer test_busybox running
342342

343343
# checkpoint the running container
344-
runc --criu "$CRIU" checkpoint --work-path ./work-dir test_busybox
344+
runc checkpoint --work-path ./work-dir test_busybox
345345
grep -B 5 Error ./work-dir/dump.log || true
346346
[ "$status" -eq 0 ]
347347
! test -f ./work-dir/"$tmplog1"
@@ -352,7 +352,7 @@ function simple_cr() {
352352

353353
test -f ./work-dir/"$tmplog2" && unlink ./work-dir/"$tmplog2"
354354
# restore from checkpoint
355-
runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
355+
runc restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
356356
grep -B 5 Error ./work-dir/restore.log || true
357357
[ "$status" -eq 0 ]
358358
! test -f ./work-dir/"$tmplog1"
@@ -386,7 +386,7 @@ function simple_cr() {
386386
testcontainer test_busybox running
387387

388388
# checkpoint the running container
389-
runc --criu "$CRIU" checkpoint --work-path ./work-dir test_busybox
389+
runc checkpoint --work-path ./work-dir test_busybox
390390
grep -B 5 Error ./work-dir/dump.log || true
391391
[ "$status" -eq 0 ]
392392

@@ -398,7 +398,7 @@ function simple_cr() {
398398
rm -rf "${bind1:?}"/*
399399

400400
# restore from checkpoint
401-
runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
401+
runc restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
402402
grep -B 5 Error ./work-dir/restore.log || true
403403
[ "$status" -eq 0 ]
404404

tests/integration/helpers.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ SECCOMP_AGENT="${INTEGRATION_ROOT}/../../contrib/cmd/seccompagent/seccompagent"
2323
# shellcheck disable=SC2034
2424
TESTDATA="${INTEGRATION_ROOT}/testdata"
2525

26-
# CRIU PATH
27-
CRIU="$(which criu 2>/dev/null || true)"
26+
# Whether we have criu binary.
27+
command -v criu &>/dev/null && HAVE_CRIU=yes
2828

2929
# Kernel version
3030
KERNEL_VERSION="$(uname -r)"
@@ -350,7 +350,7 @@ function requires() {
350350
local skip_me
351351
case $var in
352352
criu)
353-
if [ ! -e "$CRIU" ]; then
353+
if [ -n "$HAVE_CRIU" ]; then
354354
skip_me=1
355355
fi
356356
;;

utils_linux.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func loadFactory(context *cli.Context) (libcontainer.Factory, error) {
4747
}
4848

4949
return libcontainer.New(abs, intelRdtManager,
50-
libcontainer.CriuPath(context.GlobalString("criu")),
5150
libcontainer.NewuidmapPath(newuidmap),
5251
libcontainer.NewgidmapPath(newgidmap))
5352
}

0 commit comments

Comments
 (0)