Skip to content

sys_restore prototype

Serge E. Hallyn containers 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2introduce sys_restorearch/x86/kernel/process_32.c arch/x86/kernel/syscall_table_32.S kernel/fork.c+55 -00 replies
2/2sys_restore: set the pid numberkernel/fork.c kernel/pid.c+24 -02 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] sys_restore prototype

We were talking this morning about what trivial patchset to begin with to get a start on checkpoint and restart. We thought that rather than start with checkpoint, maybe we should start with something that reads a "checkpoint file" and "restarts" a single task. In this case, restart means it sets the process id and executes the file which are found in the checkpoint file.

So here's what we whipped up for a half hour this morning, and during some of Mark's talk this afternoon.

It refuses to run if it isn't the container init, so you must unshare your pidns before calling sys_restore().

To test, I did:

[root@kvm-f9 ~]# cat mycheckpoint
99 /root/whoami
[root@kvm-f9 ~]# cat restore.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main()

{
        int ret;
        char *argv[3];
        char *envp[1];

        //argv[0] = argv[1] = "/bin/bash";
        //argv[2] = envp[0] = NULL;
        argv[0] = "/root/whoami";
        argv[1] = envp[0] = NULL;
        int fd = open("/root/mycheckpoint", O_RDONLY);
        if (fd < 0)
                perror("open checkpoint file");
        ret = syscall(327, fd, argv, envp);
        printf("syscall returned %d\n", ret);
        perror("syscall for checkpoint");
        close(fd);
        return ret;
}

[root@kvm-f9 ~]# cat whoami.c
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main()

{
        printf("I am %d\n", getpid());
        return 0;
}

Next, I create a new pid namespace, remount /proc, and
execute 'restore' using 'exec' so that pid 1 is doing it:

[root@kvm-f9 ~]# /home/hallyn/cryo/utils/ns_exec -cp /bin/bash about to clone with 20020000
[root@kvm-f9 ~]# mount -t proc none /proc [root@kvm-f9 ~]# ps -ef

UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  1 18:46 pts/0    00:00:00 /bin/bash
root        26     1  0 18:46 pts/0    00:00:00 ps -ef

[root@kvm-f9 ~]# exec ./restore
I am 99

Seems to work.

-serge