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