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

Commit 9de9caf

Browse files
authored
Merge pull request #252 from bergwolf/nfs-volume
Nfs volume
2 parents 8484d7e + 76a3730 commit 9de9caf

File tree

9 files changed

+48
-12
lines changed

9 files changed

+48
-12
lines changed

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM centos:7
22
MAINTAINER Hyper Developers <dev@hyper.sh>
33

4-
RUN yum install -y patch gcc ncurses-devel make openssl-devel bc
4+
RUN yum install -y patch gcc ncurses-devel make openssl-devel bc perl
55

66
ENV KERNEL_VERSION 4.4.28
77
ENV LOCALVERSION -hyper

build/kernel

32 Bytes
Binary file not shown.

build/kernel_config

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ CONFIG_NET_ACT_CONNMARK=m
11851185
CONFIG_NET_CLS_IND=y
11861186
CONFIG_NET_SCH_FIFO=y
11871187
CONFIG_DCB=y
1188-
# CONFIG_DNS_RESOLVER is not set
1188+
CONFIG_DNS_RESOLVER=m
11891189
# CONFIG_BATMAN_ADV is not set
11901190
CONFIG_OPENVSWITCH=m
11911191
CONFIG_OPENVSWITCH_GRE=m
@@ -2059,8 +2059,23 @@ CONFIG_TMPFS_XATTR=y
20592059
# CONFIG_CONFIGFS_FS is not set
20602060
# CONFIG_MISC_FILESYSTEMS is not set
20612061
CONFIG_NETWORK_FILESYSTEMS=y
2062-
# CONFIG_NFS_FS is not set
2062+
CONFIG_NFS_FS=m
2063+
CONFIG_NFS_V2=m
2064+
CONFIG_NFS_V3=m
2065+
# CONFIG_NFS_V3_ACL is not set
2066+
CONFIG_NFS_V4=m
2067+
# CONFIG_NFS_SWAP is not set
2068+
# CONFIG_NFS_V4_1 is not set
2069+
# CONFIG_NFS_USE_LEGACY_DNS is not set
2070+
CONFIG_NFS_USE_KERNEL_DNS=y
20632071
# CONFIG_NFSD is not set
2072+
CONFIG_GRACE_PERIOD=m
2073+
CONFIG_LOCKD=m
2074+
CONFIG_LOCKD_V4=y
2075+
CONFIG_NFS_COMMON=y
2076+
CONFIG_SUNRPC=m
2077+
CONFIG_SUNRPC_GSS=m
2078+
# CONFIG_SUNRPC_DEBUG is not set
20642079
# CONFIG_CEPH_FS is not set
20652080
# CONFIG_CIFS is not set
20662081
# CONFIG_NCP_FS is not set
@@ -2484,6 +2499,7 @@ CONFIG_NLATTR=y
24842499
CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
24852500
# CONFIG_CORDIC is not set
24862501
# CONFIG_DDR is not set
2502+
CONFIG_OID_REGISTRY=m
24872503
# CONFIG_SG_SPLIT is not set
24882504
CONFIG_ARCH_HAS_SG_CHAIN=y
24892505
CONFIG_ARCH_HAS_PMEM_API=y

build/make-initrd.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ cp busybox /tmp/hyperstart-rootfs/sbin/
1616
cp iptables /tmp/hyperstart-rootfs/sbin/
1717
cp ipvsadm /tmp/hyperstart-rootfs/sbin/
1818
cp libm.so.6 /tmp/hyperstart-rootfs/lib64/
19+
cp mount.nfs /tmp/hyperstart-rootfs/sbin/mount.nfs4
1920

2021
if [ "$1"x = "aarch64"x ]; then
2122
echo "build hyperstart for aarch64"

build/modules.tar

1.09 MB
Binary file not shown.

build/mount.nfs

112 KB
Binary file not shown.

src/container.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,33 @@ static int container_setup_volume(struct hyper_container *container)
113113
sprintf(path, "/tmp/%s", vol->mountpoint);
114114
sprintf(mountpoint, "./%s", vol->mountpoint);
115115

116-
fprintf(stdout, "mount %s to %s, tmp path %s\n",
117-
dev, vol->mountpoint, path);
118-
119116
if (hyper_mkdir(path, 0755) < 0) {
120117
perror("create volume dir failed");
121118
return -1;
122119
}
123120

124-
if (!strncmp(vol->fstype, "xfs", strlen("xfs")))
125-
options = "nouuid";
121+
if (!strcmp(vol->fstype, "nfs")) {
122+
fprintf(stdout, "mount nfs share %s to %s, tmp path %s\n",
123+
vol->device, vol->mountpoint, path);
126124

127-
if (mount(dev, path, vol->fstype, 0, options) < 0) {
128-
perror("mount volume device failed");
129-
return -1;
125+
if (hyper_mount_nfs(vol->device, path) < 0)
126+
return -1;
127+
/* nfs export has implicitly included _data part of the volume */
128+
sprintf(volume, "/%s/", path);
129+
} else {
130+
fprintf(stdout, "mount %s to %s, tmp path %s\n",
131+
dev, vol->mountpoint, path);
132+
133+
if (!strcmp(vol->fstype, "xfs"))
134+
options = "nouuid";
135+
136+
if (mount(dev, path, vol->fstype, 0, options) < 0) {
137+
perror("mount volume device failed");
138+
return -1;
139+
}
140+
sprintf(volume, "/%s/_data", path);
130141
}
131142

132-
sprintf(volume, "/%s/_data", path);
133143
if (container_check_file_volume(volume, &filevolume) < 0)
134144
return -1;
135145

src/util.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,3 +716,11 @@ ssize_t nonblock_read(int fd, void *buf, size_t count)
716716

717717
return len > 0 ? len : ret;
718718
}
719+
720+
int hyper_mount_nfs(char *server, char *mountpoint)
721+
{
722+
char cmd[512];
723+
snprintf(cmd, sizeof(cmd), "mount.nfs4 -n %s %s", server, mountpoint);
724+
725+
return hyper_cmd(cmd);
726+
}

src/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ struct passwd *hyper_getpwnam(const char *name);
4242
struct group *hyper_getgrnam(const char *name);
4343
int hyper_getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups);
4444
ssize_t nonblock_read(int fd, void *buf, size_t count);
45+
int hyper_mount_nfs(char *server, char *mountpoint);
4546
#endif

0 commit comments

Comments
 (0)