All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Linux Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: [PATCH 0/2] sys_restore prototype
Date: Fri, 25 Jul 2008 17:56:56 -0500	[thread overview]
Message-ID: <20080725225655.GA28276@us.ibm.com> (raw)

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

             reply	other threads:[~2008-07-25 22:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-25 22:56 Serge E. Hallyn [this message]
     [not found] ` <20080725225655.GA28276-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-07-25 22:58   ` [PATCH 1/2] introduce sys_restore Serge E. Hallyn
2008-07-25 22:59   ` [PATCH 2/2] sys_restore: set the pid number Serge E. Hallyn
     [not found]     ` <20080725225935.GB28764-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-07-27  2:33       ` [Devel] " Pavel Emelyanov
     [not found]         ` <488BDE7D.7090602-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2008-07-29 18:31           ` Serge E. Hallyn
2008-07-28 22:00   ` [PATCH 0/2] sys_restore prototype Eric W. Biederman
     [not found]     ` <m1sktthdp3.fsf-B27657KtZYmhTnVgQlOflh2eb7JE58TQ@public.gmane.org>
2008-07-29 18:27       ` Serge E. Hallyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080725225655.GA28276@us.ibm.com \
    --to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.