Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ static int container_setup_mount(struct hyper_container *container)
return -1;
}

if (mount("tmpfs", "./dev/shm/", "tmpfs", MS_NOSUID| MS_NODEV, NULL) < 0) {
perror("mount shm failed");
if (mount("/tmp/hyper/shm", "./dev/shm/", "tmpfs", MS_BIND, NULL) < 0) {
perror("bind mount shared shm failed");
return -1;
}

Expand Down
29 changes: 29 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,30 @@ int hyper_enter_sandbox(struct hyper_pod *pod, int pid_efd)
return ret;
}

/*
* All containers in the pod share the same ipc namespace. However,
* posix ipc primitives are shm_open() family whose behaviors
* implemented in glibc are to create&share the shm objects within
* /dev/shm (or scans /proceed/mounts for any tmpfs if /dev/shm
* is not tmpfs).
* So we have to create the only one tmpfs mount and share it
* to all the containers.
*/
static int hyper_setup_shm(struct hyper_pod *pod)
{
if (hyper_mkdir("/tmp/hyper/shm", 0755) < 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it good to be placed in /tmp? how about /var/lib or somewhere like?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in hyperstart, all pod/containers related things are created on /tmp/hyper

perror("create shared shm directory failed");
return -1;
}

if (mount("tmpfs", "/tmp/hyper/shm", "tmpfs", MS_NOSUID| MS_NODEV, NULL) < 0) {
perror("mount shm failed");
return -1;
}

return 0;
}

#ifdef WITH_VBOX

#define MAX_HOST_NAME 256
Expand Down Expand Up @@ -535,6 +559,11 @@ static int hyper_setup_pod(struct hyper_pod *pod)
return -1;
}

if (hyper_setup_shm(pod) < 0) {
fprintf(stderr, "setup shared shm failed\n");
return -1;
}

if (hyper_setup_pod_init(pod) < 0) {
fprintf(stderr, "start container failed\n");
return -1;
Expand Down