/usr/bin/lxc-test-checkpoint-restore is in lxc-tests 2.0.7-0ubuntu1~16.04.2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #!/bin/sh
# Do an end to end checkpoint and restore with criu.
set -e
FAIL() {
echo -n "Failed " >&2
echo "$*" >&2
exit 1
}
if [ "$(id -u)" != "0" ]; then
echo "ERROR: Must run as root."
exit 1
fi
verlte() {
! [ "$1" = "$(printf "$1\n$2" | sort -V | tail -n1)" ]
}
criu_version="$(criu --version | head -n1 | cut -d' ' -f 2)"
if verlte "$criu_version" "1.3.1"; then
echo "SKIP: skipping test because no (or wrong) criu installed."
exit 0
fi
name=lxc-test-criu
lxc-create -t ubuntu -n $name || FAIL "creating container"
cat >> "$(lxc-config lxc.lxcpath)/$name/config" <<EOF
# hax for criu
lxc.console = none
lxc.tty = 0
lxc.cgroup.devices.deny = c 5:1 rwm
EOF
lxc-start -n $name -d || FAIL "starting container"
lxc-wait -n $name -s RUNNING || FAIL "waiting for container to run"
# Let the container boot and get into a steady state.
sleep 5s
# The first time this usually fails because CRIU cannot checkpoint things with
# data on a socket.
lxc-checkpoint -n $name -v -s -D /tmp/checkpoint || FAIL "failed checkpointing"
lxc-wait -n $name -s STOPPED
lxc-checkpoint -n $name -v -r -D /tmp/checkpoint || FAIL "failed restoring"
lxc-stop -n $name -t 1
lxc-destroy -f -n $name
|