Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

[RFC] Support for running hyperstart without 9pfs #344

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 16 additions & 4 deletions src/container.c
Original file line number Diff line number Diff line change
@@ -579,6 +579,7 @@ static int hyper_setup_container_rootfs(void *data)
goto fail;
}

sprintf(rootfs, "%s/%s/", root, container->rootfs);
if (container->fstype) {
char dev[128];
char *options = NULL;
@@ -614,10 +615,21 @@ static int hyper_setup_container_rootfs(void *data)
sprintf(path, "%s/%s/", SHARED_DIR, container->image);
fprintf(stdout, "src directory %s\n", path);

if (mount(path, root, NULL, MS_BIND, NULL) < 0) {
perror("mount src dir failed");
goto fail;

if (arg->pod->share_tag == NULL) {
hyper_mkdir(rootfs, 0755);
if (mount("/dev/sda", rootfs, "ext4", MS_MGC_VAL| MS_NODEV, "") < 0) {
perror("mount src dir failed");
goto fail;
}
} else {
if (mount(path, root, NULL, MS_BIND, NULL) < 0) {
perror("mount src dir failed");
goto fail;
}
}


if (container->readonly && mount(NULL, root, NULL, MS_BIND | MS_REMOUNT | MS_RDONLY, NULL) < 0) {
perror("mount src dir readonly failed");
goto fail;
@@ -627,7 +639,7 @@ static int hyper_setup_container_rootfs(void *data)
fprintf(stdout, "root directory for container is %s/%s, init task %s\n",
root, container->rootfs, container->exec.argv[0]);

sprintf(rootfs, "%s/%s/", root, container->rootfs);

if (mount(rootfs, rootfs, NULL, MS_BIND|MS_REC, NULL) < 0) {
perror("failed to bind rootfs");
goto fail;
9 changes: 9 additions & 0 deletions src/portmapping.c
Original file line number Diff line number Diff line change
@@ -167,6 +167,15 @@ int hyper_setup_portmapping(struct hyper_pod *pod)
int hyper_setup_container_portmapping(struct hyper_container *c, struct hyper_pod *pod)
{
// only allow network request from internal white list

//Disabling it for now for no 9p case.
//TODO - iptables file is generated after VM is booted,
//so this needs to be addressed later by rearranging the way
//iptables file is generated.
if (pod->share_tag == NULL) {
return 0;
}

int i = 0, j = 0;
char rule[128] = {0};
char iptables_restore[512];