Commit Graph

54 Commits

Author SHA1 Message Date
Gao feng 684e85cc5e recyle resources of process which created by clone
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-24 16:58:42 +08:00
Gao feng d45be919cd change socketpair to pipe
If one pair of pipe created by socketpair closed, the other side
will receice error, so other side cannot know the exec result of
peer.

Use pipe to replace socketpair.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-24 14:38:46 +08:00
Gao feng 5c3bd1b19f initialize ptyfd and eventfd for exec
initialize them to -1

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-24 11:02:45 +08:00
Gao feng 600e8dd3c8 release exec immediately if exec has no tty
Only signal handler operates the exex struct, we
can release exec immediately

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-24 10:55:57 +08:00
Gao feng 08764d5bbc fix incorrect logic of hyper_send_type_block
It means set fd block first and send out the type.
And fix the access to exec consurrently, hyper init
should be blocked until do_exec_cmd processes the
exec struct.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-24 10:34:12 +08:00
Gao feng 749387bbfa fix possible missing eof data
It happend that pts_loop reads all of the data before the,
SIGCHLD signal being handled, so only hup handler will be triggered,
move the sending eof message to hup handler.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-23 23:07:22 +08:00
Gao feng 88bb908c76 do not handle hup event if get in event
Should handle in event to get reamin data before close fd in hup.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-23 17:01:20 +08:00
Gao feng d260dda29e remove debug message
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-23 10:56:49 +08:00
Gao feng a8362c1a70 hold the fd of container pts device in hyper init
1, Hold the the file description of pts device and ptmx in hyper-init process
2, Dup fd to the stdio of Exec cmd
3, Exec cmd exited, no EPOLLHUP event since the file is still open
4, Try to read ptmx fd before close pts fd
4, signal handler get signal SIGCHLD, close the pts fd to trigger EPOLLHUP event
5, EPOLLHUP event is received, send eof message to ttyfd. release exec.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-23 10:56:49 +08:00
Gao feng 87fa294a42 handle pts epoll hup event
hup means peer closes the pipe, and the exec will exit,
send out all of the outputs of exec.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-23 10:56:37 +08:00
Gao feng 330c46cdb2 enter container namespace with opened ns fd
After process exit,the path of pid ns will disappear,
open it first to prohibit ns being released.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-21 10:52:58 +08:00
Gao feng 27f4b56e71 implement hyper_cmd_read_file
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-17 20:28:31 +08:00
Gao feng 2262bc18fe accept read raw data from write message
It's difficult to encode the json with special characters such as '"', '>'...
encoding and unicoding these characters will change the length of json message,
it's a pain to get bytes contains these characters from json.

This patch allows to read the bytes contains special character outside the json.
for example:
{"container":"c5f67934326d2ecef59fee62148bc9237e2481cd803cc0760a6406da15f4ee60","file":"/tmp/aaa"}sssssss

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-17 16:18:32 +08:00
Gao feng bc0e688f96 implemet hyper_cmd_write_file
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-17 00:44:54 +08:00
Gao feng 2fb02c57b6 set cloexec flag on socket pair
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-16 23:39:01 +08:00
Gao feng bf0f360935 run exec in right pid namespace
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-16 23:19:56 +08:00
Gao feng 6976865176 cleanup
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-16 20:14:48 +08:00
Gao feng c862b89079 running contianers in the pid ns of pod init
manpage of setns says:

>CLONE_NEWPID behaves somewhat differently from the other nstype values: reassociating the calling thread with a PID namespace changes only the PID namespace that child processes of the  caller  will
>be created in; it does not change the PID namespace of the caller itself.  Reassociating with a PID namespace is allowed only if the PID namespace specified by fd is a descendant (child, grandchild,
>etc.)  of the PID namespace of the caller.  For further details on PID namespaces, see pid_namespaces(7).

so clone a temporary process to enter pid ns, and then create containers. and join them to the other nss of pod init.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-16 18:54:56 +08:00
Gao feng 6a15977238 create container process in hyper init
Move most of functions from pod init to hyper init.
this makes logic more clearer

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-16 16:47:43 +08:00
Gao feng 7d6468f70b introduce hyper_parse_read_file
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-15 23:25:25 +08:00
Gao feng ed9a351518 introduce hyper_parse_write_file
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-15 23:22:38 +08:00
Gao feng d4b3e0ad62 introduce WRITE/READFILE command
write data to files or read data from files in contianer.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-09-15 20:11:16 +08:00
Thibault BRONCHAIN 1bd2d3d992 Merge pull request #4 from stigkj/patch-1
Fix spelling
2015-09-02 09:16:18 +08:00
Stig Kleppe-Jørgensen ce452d5759 Fix spelling 2015-09-01 22:43:44 +02:00
Gao feng 56cb24bd0d Merge pull request #3 from gao-feng/fix
fix incorrectly writting to resolv.conf
2015-09-01 17:12:40 +08:00
Gao feng c7b46b71a0 fix incorrectly writting to resolv.conf
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-08-28 20:46:33 +08:00
Lai Jiangshan e7e6b98958 Merge pull request #2 from gao-feng/dns
support setting up dns for container
2015-08-28 18:04:10 +08:00
Gao feng 2f27b48f7b setup dns for container
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-08-27 22:46:14 +08:00
Gao feng 04a501edb7 parse dns from pod file
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-08-27 22:42:57 +08:00
Gao feng 01f07fb952 remove channel in pod
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-08-27 22:42:57 +08:00
Gao feng 6680827faf send kill signal if term is ignored by container process
Fix the bug that stoppod is blocked.

Signed-off-by: Gao feng <feng@hyper.sh>
2015-08-13 16:52:36 +08:00
Gao feng 7699c38b99 ignore cbfs rom
Signed-off-by: Gao feng <feng@hyper.sh>
2015-08-13 16:52:26 +08:00
Gao feng aa265352ff send Next message to hyper in vbox environment
Signed-off-by: Gao feng <feng@hyper.sh>
v0.2
2015-08-06 10:21:05 +08:00
Gao feng 56e5e66f86 remove vbox-bootimage target
Signed-off-by: Gao feng <feng@hyper.sh>
2015-07-30 16:13:06 +08:00
Gao feng 753364bbff remove hyper daemon test program
Signed-off-by: Gao feng <feng@hyper.sh>
2015-07-30 16:09:59 +08:00
Gao feng 8fbb28cc6f make cbfs target recursive
Signed-off-by: Gao feng <feng@hyper.sh>
2015-07-30 16:09:16 +08:00
Gao feng 066ba95737 Update README
no need input password now.

Signed-off-by: Gao feng <feng@hyper.sh>
2015-07-30 15:59:18 +08:00
Gao feng 1b9789937f Add VirtualBox support
Run hyperStart on VirtualBox

Signed-off-by: Gao feng <feng@hyper.sh>
2015-07-30 15:57:44 +08:00
Wang Xu 46ffda72bd add cache parameter for 9p mount
Signed-off-by: Wang Xu <gnawux@gmail.com>
v0.1
2015-07-06 10:41:57 +08:00
Gao feng 5c16805384 make cbfs rom through Makefile
`make cbfs` will generate cbfs.rom under build directory.

Signed-off-by: Gao feng <feng@hyper.sh>
2015-06-29 11:03:04 +08:00
Gao feng a8b61d2706 kernel: add xen guest support
Signed-off-by: Gao feng <feng@hyper.sh>
2015-06-19 23:15:38 +08:00
Gao feng 458795b4b2 shutdown: kill processes before unmount
hmm, down the possibility that process writting block after
unmount.

Signed-off-by: Gao feng <feng@hyper.sh>
2015-06-13 16:14:55 +08:00
Gao feng 9b73bbc9b2 hyper kernel: enable xfs support
the file system of docker images may be xfs.

Signed-off-by: Gao feng <feng@hyper.sh>
2015-06-04 17:31:52 +08:00
Gao feng 2784cb7bab util: move hyper_list_dir into util.c
this function is useful to debug

Signed-off-by: Gao feng <feng@hyper.sh>
2015-06-04 14:34:28 +08:00
Gao feng ed578419da call setns syscall directly
fix the problem that low version glibc doesn't have setns.

Signed-off-by: Gao feng <feng@hyper.sh>
2015-06-03 16:37:46 +08:00
Gao feng a00bdc776c hyperstart is the name of this program
not dvminit or hyperinit.

Signed-off-by: Gao feng <feng@hyper.sh>
2015-06-03 15:59:22 +08:00
Gao feng 820da51e32 Merge pull request #1 from hustcat/fix_configure
Add AM_PROG_CC_C_O for configure
2015-06-03 15:54:48 +08:00
Ye Yin 398667ac23 Add AM_PROG_CC_C_O for configure
Signed-off-by: Ye Yin <eyniy@qq.com>
2015-06-03 03:20:08 +08:00
Gao feng 953cc08de3 container: fix the fail to start bug if container has no tty
BU reported by @henrysher.

    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] setup pty device /dev/null for exec
    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] ioctl pty device for execcmd failed: Inappropriate ioctl for device
    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] setup tty failed
    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] hyper send type 10, len 0
    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] wait for container started failed
    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] container 2e60d916bb16655746830d89e1503c7067ef13560883a6ba62a77f11c44cadc8 init exit code -1

Signed-off-by: Gao feng <feng@hyper.sh>
2015-06-01 15:13:10 +08:00
Gao feng 980f7fda4c Add NOTICE file
Signed-off-by: Gao feng <feng@hyper.sh>
2015-05-29 16:00:25 +08:00