mirror of https://github.com/docker/docs.git
Update to libcontainer eb74393a3d2daeafbef4f5f27c0
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
27602f2a21
commit
6b04d9342c
|
@ -68,7 +68,7 @@ if [ "$1" = '--go' ]; then
|
||||||
mv tmp-tar src/code.google.com/p/go/src/pkg/archive/tar
|
mv tmp-tar src/code.google.com/p/go/src/pkg/archive/tar
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clone git github.com/docker/libcontainer 1d3b2589d734dc94a1719a3af40b87ed8319f329
|
clone git github.com/docker/libcontainer eb74393a3d2daeafbef4f5f27c0821cbdd67559c
|
||||||
# see src/github.com/docker/libcontainer/update-vendor.sh which is the "source of truth" for libcontainer deps (just like this file)
|
# see src/github.com/docker/libcontainer/update-vendor.sh which is the "source of truth" for libcontainer deps (just like this file)
|
||||||
rm -rf src/github.com/docker/libcontainer/vendor
|
rm -rf src/github.com/docker/libcontainer/vendor
|
||||||
eval "$(grep '^clone ' src/github.com/docker/libcontainer/update-vendor.sh | grep -v 'github.com/codegangsta/cli')"
|
eval "$(grep '^clone ' src/github.com/docker/libcontainer/update-vendor.sh | grep -v 'github.com/codegangsta/cli')"
|
||||||
|
|
|
@ -124,11 +124,17 @@ func Freeze(c *cgroups.Cgroup, state cgroups.FreezerState) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prevState := c.Freezer
|
||||||
c.Freezer = state
|
c.Freezer = state
|
||||||
|
|
||||||
freezer := subsystems["freezer"]
|
freezer := subsystems["freezer"]
|
||||||
|
err = freezer.Set(d)
|
||||||
|
if err != nil {
|
||||||
|
c.Freezer = prevState
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return freezer.Set(d)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPids(c *cgroups.Cgroup) ([]int, error) {
|
func GetPids(c *cgroups.Cgroup) ([]int, error) {
|
||||||
|
|
|
@ -73,6 +73,11 @@ func ExecIn(container *libcontainer.Config, state *libcontainer.State, userArgs
|
||||||
return terminate(err)
|
return terminate(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// finish cgroups' setup, unblock the child process.
|
||||||
|
if _, err := parent.WriteString("1"); err != nil {
|
||||||
|
return terminate(err)
|
||||||
|
}
|
||||||
|
|
||||||
if err := json.NewEncoder(parent).Encode(container); err != nil {
|
if err := json.NewEncoder(parent).Encode(container); err != nil {
|
||||||
return terminate(err)
|
return terminate(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ void get_args(int *argc, char ***argv)
|
||||||
pr_perror("Unable to open /proc/self/cmdline");
|
pr_perror("Unable to open /proc/self/cmdline");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the whole commandline.
|
// Read the whole commandline.
|
||||||
ssize_t contents_size = 0;
|
ssize_t contents_size = 0;
|
||||||
ssize_t contents_offset = 0;
|
ssize_t contents_offset = 0;
|
||||||
|
@ -98,13 +97,12 @@ void nsenter()
|
||||||
if (strncmp(argv[0], kNsEnter, strlen(kNsEnter)) != 0) {
|
if (strncmp(argv[0], kNsEnter, strlen(kNsEnter)) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef PR_SET_CHILD_SUBREAPER
|
||||||
#ifdef PR_SET_CHILD_SUBREAPER
|
|
||||||
if (prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0) == -1) {
|
if (prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0) == -1) {
|
||||||
pr_perror("Failed to set child subreaper");
|
pr_perror("Failed to set child subreaper");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
{"nspid", required_argument, NULL, 'n'},
|
{"nspid", required_argument, NULL, 'n'},
|
||||||
|
@ -155,6 +153,12 @@ void nsenter()
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// blocking until the parent placed the process inside correct cgroups.
|
||||||
|
unsigned char s;
|
||||||
|
if (read(3, &s, 1) != 1 || s != '1') {
|
||||||
|
pr_perror("failed to receive synchronization data from parent");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
// Setns on all supported namespaces.
|
// Setns on all supported namespaces.
|
||||||
char ns_dir[PATH_MAX];
|
char ns_dir[PATH_MAX];
|
||||||
memset(ns_dir, 0, PATH_MAX);
|
memset(ns_dir, 0, PATH_MAX);
|
||||||
|
@ -173,7 +177,8 @@ void nsenter()
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
// A zombie process has links on namespaces, but they can't be opened
|
// A zombie process has links on namespaces, but they can't be opened
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (fstatat(ns_dir_fd, namespaces[i], &st, AT_SYMLINK_NOFOLLOW) == -1) {
|
if (fstatat(ns_dir_fd, namespaces[i], &st, AT_SYMLINK_NOFOLLOW)
|
||||||
|
== -1) {
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
continue;
|
continue;
|
||||||
pr_perror("Failed to stat ns file %s for ns %s",
|
pr_perror("Failed to stat ns file %s for ns %s",
|
||||||
|
|
|
@ -12,15 +12,29 @@ import (
|
||||||
|
|
||||||
func TestNsenterAlivePid(t *testing.T) {
|
func TestNsenterAlivePid(t *testing.T) {
|
||||||
args := []string{"nsenter-exec", "--nspid", fmt.Sprintf("%d", os.Getpid())}
|
args := []string{"nsenter-exec", "--nspid", fmt.Sprintf("%d", os.Getpid())}
|
||||||
|
r, w, err := os.Pipe()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to create pipe %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
cmd := &exec.Cmd{
|
cmd := &exec.Cmd{
|
||||||
Path: os.Args[0],
|
Path: os.Args[0],
|
||||||
Args: args,
|
Args: args,
|
||||||
|
ExtraFiles: []*os.File{r},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := cmd.Run()
|
if err := cmd.Start(); err != nil {
|
||||||
if err != nil {
|
t.Fatalf("nsenter failed to start %v", err)
|
||||||
t.Fatal("nsenter exits with a non-zero exit status")
|
}
|
||||||
|
r.Close()
|
||||||
|
|
||||||
|
// unblock the child process
|
||||||
|
if _, err := w.WriteString("1"); err != nil {
|
||||||
|
t.Fatalf("parent failed to write synchronization data %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := cmd.Wait(); err != nil {
|
||||||
|
t.Fatalf("nsenter exits with a non-zero exit status")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue