100 Commits

Author SHA1 Message Date
Lai Jiangshan b654a0fbd3 Merge pull request #42 from gao-feng/free
fix possible access memory after free
2016-02-01 10:56:40 +08:00
Gao feng db33f31dc1 fix possible access memory after free
For tasks created by clone_VM, they share the memory with parent,
so when parent frees the stack, children may still access to this
stack. so don't free stack when children is still using the stack.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2016-01-31 19:24:07 +08:00
Lai Jiangshan 1ce35da941 enable hot adding cpu/mem
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
2016-01-28 15:48:43 +08:00
Lai Jiangshan 213a00ec5e handle all escaped character correctly
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
2016-01-15 22:36:12 +08:00
Gao feng 73849713e8 handle escaped characters
./hyper run --rm ubuntu echo xxxx\>\"\\aadasd\"\>\<\>\<\<\<\\\\\\\"\as
POD id is pod-nvpvjBScdB
xxxx>"\aadasd"><><<<\\\"as

echo xxxx\>\"\\aadasd\"\>\<\>\<\<\<\\\\\\\"\as
xxxx>"\aadasd"><><<<\\\"as

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2016-01-14 11:12:33 +08:00
Gao feng 29efaadf0a send out exec exit code
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2016-01-06 00:12:30 +08:00
feisky 02ba85f8e0 Merge pull request #36 from gao-feng/scsi
find scsi disk device if scsi addr is given
2015-12-25 10:36:11 +08:00
Gao feng d563b3ecb0 Merge pull request #34 from wcwxyz/master
Use configure script to check setns function
2015-12-24 16:05:37 +08:00
Gao feng ce0ab6b836 find scsi disk device if scsi addr is given
scsi disk name is not consistent with scsi addr. find the
device through scsi addr.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-12-24 15:59:05 +08:00
Gao feng c14737f39c do not close pipe in write side
hyper_container_stage0 shares fd table with init, right now stage0
may close pipe before init read the pipe. this will cause container
fail to start.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-12-23 17:07:07 +08:00
WANG Chao 4b6375a4a4 Use configure script to check setns function
I happen to find out on centos6.7, glibc-headers does have SYS_setns
defined, but previous release doesn't.

It's better to use configure script to check setns function.

Signed-off-by: WANG Chao <wcwxyz@gmail.com>
2015-12-22 15:58:45 +08:00
Gao feng d34656475e kill process in destroy pod
hyper send destroy pod to shutdown vm, we should
give process a chance to handle TERM signal.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-12-10 15:13:12 +08:00
Gao feng 2b1edeceb4 introduce hyper_send_msg_block
the control serial port is opened as unblock fd, set
is as block fd to make sure sending successfully.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-12-10 14:57:16 +08:00
WANG Chao ee697391d6 define setns syscall wrapper to fix build issue
For example on centos6.x, glibc doesn't contain setns syscall wrapper,
but kernel has setns. We can write a wrapper to simulate the glibc
behavior to fix compile issue.

NOTE: In such case, we will need kernel-headers to get syscall number.

Signed-off-by: WANG Chao <wcwxyz@gmail.com>
2015-12-03 15:50:15 +08:00
Gao feng 545258bd26 send out ack if pod already finished
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-24 10:17:40 +08:00
Gao feng 0887e9a6de support kill container
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-18 18:50:07 +08:00
Gao feng a2086298f6 rename FINISH to PODFINISHED
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-16 15:13:57 +08:00
Gao feng b7c88467e2 Add remains when start container successfully
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-16 12:10:01 +08:00
Gao feng 0c997dbe85 use list to store containers
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-13 16:32:12 +08:00
Gao feng 6d3265a7fb free tty of winsize is parse failed
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-13 14:44:36 +08:00
Gao feng a46092a90a free allocated memory in parse_container
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-13 11:59:43 +08:00
Gao feng 25da342f75 introduce hyper_free_container
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-13 10:56:51 +08:00
Gao feng c3160aea0a refactor parsing json
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-12 22:42:15 +08:00
Gao feng 1958e11f45 remove the codes of restart pod
hyper had implemented this function, these codes are useless.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-12 16:04:17 +08:00
Gao feng 738a11dcdc initialize container in parse_new_container
fix the possible free incorrect memory.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-12 16:02:28 +08:00
Lai Jiangshan 280bc617d0 Merge pull request #24 from gao-feng/error
add the check of memory allocation
2015-11-12 15:08:00 +08:00
Lai Jiangshan 4361f071e8 move newcontainers to dyn_containers list and fix realloc bug
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
2015-11-12 14:14:25 +08:00
Lai Jiangshan 7ef8099916 split hyper_cleanup_container()
as hyper_cleanup_container() and hyper_cleanup_containers().

Also fix the bug that the iterator "i" is corruption.

Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
2015-11-11 09:52:22 +08:00
Gao feng 1558b44495 add the check of memory allocation
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-09 16:44:42 +08:00
Gao feng 51f2a45217 export hyper_parse_new_container
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-06 16:38:54 +08:00
Gao feng 3b0ff1d7ca Merge pull request #21 from laijs/new-container
New container
2015-11-05 15:14:46 +08:00
Lai Jiangshan 62dea1454d enable inserting new container
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
2015-11-05 11:57:30 +08:00
Gao feng b5f8137499 Merge pull request #19 from gao-feng/exec
send eof message to hyper before shutdown vm
2015-11-03 15:26:30 +08:00
Gao feng 99ee15c731 send eof message to hyper before shutdown vm
When hyperstart received destory-vm message, some execs are still
running, send eof message immediately.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-11-03 15:17:37 +08:00
Lai Jiangshan dfa392edb7 start the container stage0 one by one
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
2015-11-02 15:13:27 +08:00
Lai Jiangshan 7075847ef4 rename pod->tag to pod->share_tag
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
2015-11-02 14:16:34 +08:00
Gao feng 19da0a2068 add mount option for filesystems
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-29 10:06:53 +08:00
Gao feng 180339f16b Mount /dev/shm by default
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-29 10:05:19 +08:00
Gao feng c86afd1a5c rename hyper_send_exec_eof
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-24 18:34:28 +08:00
Gao feng 18abe7d9e1 do not cleanup exec in cleanup pod
Let pts loop or signal loop do the cleanup job. fix the
possible double free of exec.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-23 23:27:53 +08:00
Gao feng ae5338bde5 do not remove lo device in cleanup net
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-23 23:27:53 +08:00
Gao feng 7843001aa7 initialize errev fd
it can not be 0, 0 is an useful fd, this will cause weird
closing of ptmx fd.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-23 23:27:53 +08:00
Gao feng cff19ec212 remove pts event from epoll when get hup event
fix the multi hup event problem.
seams like close event fd doesn't frobid hup event being triggered
again.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-23 23:27:53 +08:00
Gao feng c126e40795 use reference to protect exec structure
stdout, stderr and signal loop will try to access exec struct.
right now, we don't have reference of exec for stderr handler.

so in stderr epoll handler, it may access to the already released
exec resource.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-23 23:27:53 +08:00
Gao feng 11c4d7311b Dont accept input when cmd alreay exited
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-23 23:27:53 +08:00
Gao feng 1f2b1f5880 watch up pty fd before exec cmd
exec cmd may exit before hyper init watching it's ptmx fd,
so the hup event of ptmx may miss, this will cause the eof
message fail to send out.

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-23 23:27:53 +08:00
Gao feng 14f9ba5c3f fix incorrect cleanup when exec failed
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-23 23:27:53 +08:00
Gao feng 26183926a3 do not close ptyfd after set window size
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-23 23:27:53 +08:00
Gao feng 350997b03c support configure sysctl for container
{
	"id": "test-container-sysctl",
	"containers" : [{
	    "name": "ubuntu",
	    "image": "ubuntu:latest",
	    "workdir": "/",
	    "command": ["/bin/bash"],
	    "sysctl":{"net.ipv4.ip_forward": "1", "net.core.somaxconn": "256"}
	}],
	"resource": {
	    "vcpu": 1,
	    "memory": 512
	},
	"tty": true
}

Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-19 17:03:28 +08:00
Gao feng 08fcf381e8 remove useless code
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
2015-10-10 23:20:26 +08:00