mirror of
https://github.com/clearlinux/hyperstart.git
synced 2026-09-06 05:31:58 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd9623c892 | ||
|
|
00e65b239c | ||
|
|
b654a0fbd3 | ||
|
|
2f757d249d | ||
|
|
db33f31dc1 | ||
|
|
661dcdda07 | ||
|
|
22a65f7666 | ||
|
|
1ce35da941 | ||
|
|
e6cffd9add | ||
|
|
213a00ec5e | ||
|
|
c03c057a42 | ||
|
|
73849713e8 | ||
|
|
0610a4e156 | ||
|
|
29efaadf0a | ||
|
|
02ba85f8e0 | ||
|
|
d563b3ecb0 | ||
|
|
ce0ab6b836 | ||
|
|
feedb0808b | ||
|
|
c14737f39c | ||
|
|
4b6375a4a4 | ||
|
|
bfa1af2101 | ||
|
|
a866e257fd | ||
|
|
d34656475e | ||
|
|
2b1edeceb4 | ||
|
|
f49d1247d2 | ||
|
|
ee697391d6 | ||
|
|
93c02c012f | ||
|
|
545258bd26 | ||
|
|
9611ecf356 | ||
|
|
0887e9a6de | ||
|
|
a2086298f6 | ||
|
|
b7c88467e2 | ||
|
|
0c997dbe85 | ||
|
|
6d3265a7fb | ||
|
|
a46092a90a | ||
|
|
25da342f75 | ||
|
|
c3160aea0a | ||
|
|
7bbc240cae | ||
|
|
1958e11f45 | ||
|
|
738a11dcdc | ||
|
|
280bc617d0 | ||
|
|
252def6bab | ||
|
|
4361f071e8 | ||
|
|
7ef8099916 | ||
|
|
1558b44495 | ||
|
|
0c42ea97a4 | ||
|
|
51f2a45217 | ||
|
|
3b0ff1d7ca | ||
|
|
62dea1454d | ||
|
|
b5f8137499 | ||
|
|
e64268427d | ||
|
|
99ee15c731 | ||
|
|
dfa392edb7 | ||
|
|
7075847ef4 | ||
|
|
19da0a2068 | ||
|
|
180339f16b | ||
|
|
c86afd1a5c | ||
|
|
910a42d647 | ||
|
|
18abe7d9e1 | ||
|
|
ae5338bde5 | ||
|
|
7843001aa7 | ||
|
|
cff19ec212 | ||
|
|
c126e40795 | ||
|
|
11c4d7311b | ||
|
|
1f2b1f5880 | ||
|
|
14f9ba5c3f | ||
|
|
26183926a3 | ||
|
|
a7a3c52c88 | ||
|
|
350997b03c | ||
|
|
48c6e2248a | ||
|
|
08fcf381e8 | ||
|
|
f3f78303b1 | ||
|
|
555bc46d14 | ||
|
|
b14f68378d | ||
|
|
8553460afe | ||
|
|
16cf97584c | ||
|
|
a5680759eb | ||
|
|
b6e073d03c | ||
|
|
d7752ebd8b | ||
|
|
fdc9364062 | ||
|
|
da47929b6a | ||
|
|
3f663e7a4e | ||
|
|
3453f63787 | ||
|
|
8cd46388e5 | ||
|
|
5f819dc68a | ||
|
|
14aa9eaa39 | ||
|
|
c0585278d0 | ||
|
|
d9a36a889e | ||
|
|
788e80ce39 | ||
|
|
68b31dddd5 | ||
|
|
f0d9fc7bce | ||
|
|
684e85cc5e | ||
|
|
d45be919cd | ||
|
|
5c3bd1b19f | ||
|
|
600e8dd3c8 | ||
|
|
08764d5bbc | ||
|
|
749387bbfa | ||
|
|
88bb908c76 | ||
|
|
d260dda29e | ||
|
|
a8362c1a70 | ||
|
|
87fa294a42 | ||
|
|
330c46cdb2 | ||
|
|
27f4b56e71 | ||
|
|
2262bc18fe | ||
|
|
bc0e688f96 | ||
|
|
2fb02c57b6 | ||
|
|
bf0f360935 | ||
|
|
6976865176 | ||
|
|
c862b89079 | ||
|
|
6a15977238 | ||
|
|
7d6468f70b | ||
|
|
ed9a351518 | ||
|
|
d4b3e0ad62 | ||
|
|
1bd2d3d992 | ||
|
|
ce452d5759 | ||
|
|
56cb24bd0d | ||
|
|
c7b46b71a0 | ||
|
|
e7e6b98958 | ||
|
|
2f27b48f7b | ||
|
|
04a501edb7 | ||
|
|
01f07fb952 | ||
|
|
6680827faf | ||
|
|
7699c38b99 | ||
|
|
aa265352ff | ||
|
|
56e5e66f86 | ||
|
|
753364bbff | ||
|
|
8fbb28cc6f | ||
|
|
066ba95737 | ||
|
|
1b9789937f |
@@ -10,7 +10,9 @@
|
||||
init
|
||||
build/hyper_daemon
|
||||
build/hyper-initrd.img
|
||||
build/cbfs.rom
|
||||
build/root/*
|
||||
build/*iso
|
||||
build/daemon
|
||||
build/.*
|
||||
src/.*
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
SUBDIRS=src build
|
||||
|
||||
initrd-local:
|
||||
@echo finish make initrd
|
||||
cbfs-local:
|
||||
@echo finish make cbfs
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
# The init Task for Hyper
|
||||
|
||||
You can get binary installer of Hyper and HyperStart through [The Hyper Page](https://github.com/hyperhq/hyper)
|
||||
You can get the binary installer of Hyper and HyperStart through [The Hyper Page](https://github.com/hyperhq/hyper)
|
||||
|
||||
## Build from source
|
||||
|
||||
clone this repo, and make sure have build-essentials installed. Go into the working copy and
|
||||
clone this repo, and make sure you have build-essentials installed. Go into the working copy and
|
||||
|
||||
> ./autogen.sh
|
||||
> ./configure
|
||||
> make
|
||||
|
||||
Then you can find `hyper-initrd.img` in build directory, together with a pre-build kernel.
|
||||
Then you can find `hyper-initrd.img` in the build directory, together with a pre-built kernel.
|
||||
|
||||
If you want to get the boot disk file for VirtualBox, please reconfigure with flag --with-vbox,
|
||||
|
||||
> ./configure --with-vbox
|
||||
> make
|
||||
|
||||
Then you can find `hyper-vbox-bootimage.iso` in the build directory. Booting from this iso will
|
||||
bring you to the hyper world.
|
||||
|
||||
+8
-3
@@ -1,7 +1,12 @@
|
||||
bin_PROGRAMS=hyper_daemon
|
||||
hyper_daemon_SOURCES=hyper_daemon.c ../src/net.c
|
||||
all-local:
|
||||
all-local: initrd
|
||||
|
||||
if WITH_VBOX
|
||||
initrd-local:
|
||||
bash ./make-initrd.sh vbox
|
||||
else
|
||||
initrd-local:
|
||||
bash ./make-initrd.sh
|
||||
endif
|
||||
|
||||
cbfs-local:
|
||||
bash ./make-initrd.sh cbfs
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <linux/un.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../src/hyper.h"
|
||||
#include "../src/net.h"
|
||||
|
||||
int test_sendmsg(int fd, unsigned int type, unsigned int len, char *message)
|
||||
{
|
||||
uint8_t buf[4096];
|
||||
|
||||
|
||||
/* send hyper info to guest */
|
||||
hyper_set_be32(buf, type);
|
||||
|
||||
len += 8;
|
||||
|
||||
fprintf(stdout, "type is %u, len is %u\n", type, len);
|
||||
hyper_set_be32(buf + 4, len);
|
||||
|
||||
if (message)
|
||||
memcpy(buf + 8, message, len - 8);
|
||||
|
||||
if (write(fd, buf, len) != len) {
|
||||
fprintf(stderr, "send SETDVM MESSAGE failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(stdout, "finish sending\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_sendmsg_from_file(int fd, unsigned int type, char *file)
|
||||
{
|
||||
int file_fd = open(file, O_RDONLY);
|
||||
uint8_t buf[4096];
|
||||
unsigned int len = 0;
|
||||
|
||||
if (file_fd < 0) {
|
||||
perror("fail to open file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (len < 4096) {
|
||||
int size = read(file_fd, buf + len, sizeof(buf) - len);
|
||||
|
||||
fprintf(stdout, "read %d data\n", size);
|
||||
if (size < 0) {
|
||||
perror("fail to read data");
|
||||
return -1;
|
||||
} else if (size == 0) {
|
||||
/* buf[len] = '\0';*/
|
||||
fprintf(stdout, "get buf %s, call sendmsg\n", buf);
|
||||
test_sendmsg(fd, type, len, (char *)buf);
|
||||
break;
|
||||
}
|
||||
|
||||
len += size;
|
||||
}
|
||||
|
||||
close(file_fd);
|
||||
|
||||
if (read(fd, buf, 8) != 8) {
|
||||
fprintf(stderr, "read response failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
type = hyper_get_be32(buf);
|
||||
if (type != ACK) {
|
||||
fprintf(stderr, "incorrect type %d\n", type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int sock, fd = -1;
|
||||
struct sockaddr_un addr;
|
||||
uint8_t buf[8];
|
||||
unsigned int type;
|
||||
|
||||
unlink("/tmp/hyper.sock");
|
||||
|
||||
sock = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
|
||||
if (sock == -1) {
|
||||
perror("create unix socket failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
addr.sun_family = AF_UNIX;
|
||||
strncpy(addr.sun_path, "/tmp/hyper.sock", UNIX_PATH_MAX);
|
||||
addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
|
||||
|
||||
if (bind(sock, ((struct sockaddr *) &addr), sizeof(addr)) == -1) {
|
||||
perror("bind failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (listen(sock, 1) == -1) {
|
||||
perror("bind failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (fd == -1)
|
||||
fd = accept4(sock, NULL, NULL, SOCK_CLOEXEC);
|
||||
|
||||
fprintf(stdout, "connected\n");
|
||||
if (read(fd, buf, 8) != 8) {
|
||||
fprintf(stderr, "read failed, buf %s\n", buf);
|
||||
goto out1;
|
||||
}
|
||||
|
||||
type = hyper_get_be32(buf);
|
||||
fprintf(stdout, "get type %d\n", type);
|
||||
|
||||
if (type != READY) {
|
||||
fprintf(stderr, "incorrect type %d\n", type);
|
||||
goto out1;
|
||||
}
|
||||
|
||||
fprintf(stdout, "get length %d\n", hyper_get_be32(buf + 4));
|
||||
|
||||
/* test_sendmsg_from_file(fd, SETDVM, "sethyper.json"); */
|
||||
if (test_sendmsg_from_file(fd, STARTPOD, "startpod.json") < 0) {
|
||||
fprintf(stderr, "send startpod message failed\n");
|
||||
goto out1;
|
||||
}
|
||||
|
||||
if (test_sendmsg_from_file(fd, EXECCMD, "execcmd.json") < 0) {
|
||||
fprintf(stderr, "send execcmd message failed\n");
|
||||
goto out1;
|
||||
}
|
||||
|
||||
if (test_sendmsg(fd, STOPPOD, 0, NULL) < 0) {
|
||||
fprintf(stderr, "send stoppod message failed\n");
|
||||
goto out1;
|
||||
}
|
||||
|
||||
if (read(fd, buf, 8) != 8) {
|
||||
fprintf(stderr, "read response failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
type = hyper_get_be32(buf);
|
||||
if (type != ACK) {
|
||||
fprintf(stderr, "incorrect type %d\n", type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (read(fd, buf, 8) != 8) {
|
||||
fprintf(stderr, "read response failed\n");
|
||||
return -1;
|
||||
}
|
||||
out1:
|
||||
close(fd);
|
||||
out:
|
||||
close(sock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
+275
-96
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Linux/x86 4.0.4 Kernel Configuration
|
||||
# Linux/x86 4.4.0 Kernel Configuration
|
||||
#
|
||||
CONFIG_64BIT=y
|
||||
CONFIG_X86_64=y
|
||||
@@ -36,10 +36,10 @@ CONFIG_AUDIT_ARCH=y
|
||||
CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
|
||||
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
|
||||
CONFIG_X86_64_SMP=y
|
||||
CONFIG_X86_HT=y
|
||||
CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11"
|
||||
CONFIG_ARCH_SUPPORTS_UPROBES=y
|
||||
CONFIG_FIX_EARLYCON_MEM=y
|
||||
CONFIG_PGTABLE_LEVELS=4
|
||||
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
|
||||
CONFIG_IRQ_WORK=y
|
||||
CONFIG_BUILDTIME_EXTABLE_SORT=y
|
||||
@@ -81,10 +81,11 @@ CONFIG_HAVE_ARCH_AUDITSYSCALL=y
|
||||
#
|
||||
CONFIG_GENERIC_IRQ_PROBE=y
|
||||
CONFIG_GENERIC_IRQ_SHOW=y
|
||||
CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ=y
|
||||
CONFIG_GENERIC_PENDING_IRQ=y
|
||||
CONFIG_IRQ_DOMAIN=y
|
||||
CONFIG_IRQ_DOMAIN_HIERARCHY=y
|
||||
CONFIG_GENERIC_MSI_IRQ=y
|
||||
CONFIG_GENERIC_MSI_IRQ_DOMAIN=y
|
||||
CONFIG_IRQ_FORCED_THREADING=y
|
||||
CONFIG_SPARSE_IRQ=y
|
||||
CONFIG_CLOCKSOURCE_WATCHDOG=y
|
||||
@@ -92,7 +93,6 @@ CONFIG_ARCH_CLOCKSOURCE_DATA=y
|
||||
CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE=y
|
||||
CONFIG_GENERIC_TIME_VSYSCALL=y
|
||||
CONFIG_GENERIC_CLOCKEVENTS=y
|
||||
CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
|
||||
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
|
||||
CONFIG_GENERIC_CLOCKEVENTS_MIN_ADJUST=y
|
||||
CONFIG_GENERIC_CMOS_UPDATE=y
|
||||
@@ -103,18 +103,18 @@ CONFIG_GENERIC_CMOS_UPDATE=y
|
||||
CONFIG_TICK_ONESHOT=y
|
||||
CONFIG_NO_HZ_COMMON=y
|
||||
# CONFIG_HZ_PERIODIC is not set
|
||||
# CONFIG_NO_HZ_IDLE is not set
|
||||
CONFIG_NO_HZ_FULL=y
|
||||
# CONFIG_NO_HZ_FULL_ALL is not set
|
||||
# CONFIG_NO_HZ_FULL_SYSIDLE is not set
|
||||
# CONFIG_NO_HZ is not set
|
||||
# CONFIG_HIGH_RES_TIMERS is not set
|
||||
CONFIG_NO_HZ_IDLE=y
|
||||
# CONFIG_NO_HZ_FULL is not set
|
||||
CONFIG_NO_HZ=y
|
||||
CONFIG_HIGH_RES_TIMERS=y
|
||||
|
||||
#
|
||||
# CPU/Task time and stats accounting
|
||||
#
|
||||
CONFIG_VIRT_CPU_ACCOUNTING=y
|
||||
# CONFIG_TICK_CPU_ACCOUNTING is not set
|
||||
CONFIG_VIRT_CPU_ACCOUNTING_GEN=y
|
||||
# CONFIG_IRQ_TIME_ACCOUNTING is not set
|
||||
CONFIG_BSD_PROCESS_ACCT=y
|
||||
CONFIG_BSD_PROCESS_ACCT_V3=y
|
||||
CONFIG_TASKSTATS=y
|
||||
@@ -126,33 +126,27 @@ CONFIG_TASK_IO_ACCOUNTING=y
|
||||
# RCU Subsystem
|
||||
#
|
||||
CONFIG_TREE_RCU=y
|
||||
# CONFIG_RCU_EXPERT is not set
|
||||
CONFIG_SRCU=y
|
||||
# CONFIG_TASKS_RCU is not set
|
||||
CONFIG_RCU_STALL_COMMON=y
|
||||
CONFIG_CONTEXT_TRACKING=y
|
||||
CONFIG_RCU_USER_QS=y
|
||||
# CONFIG_CONTEXT_TRACKING_FORCE is not set
|
||||
CONFIG_RCU_FANOUT=64
|
||||
CONFIG_RCU_FANOUT_LEAF=16
|
||||
# CONFIG_RCU_FANOUT_EXACT is not set
|
||||
CONFIG_RCU_FAST_NO_HZ=y
|
||||
# CONFIG_TREE_RCU_TRACE is not set
|
||||
CONFIG_RCU_KTHREAD_PRIO=0
|
||||
CONFIG_RCU_NOCB_CPU=y
|
||||
# CONFIG_RCU_NOCB_CPU_NONE is not set
|
||||
# CONFIG_RCU_NOCB_CPU_ZERO is not set
|
||||
CONFIG_RCU_NOCB_CPU_ALL=y
|
||||
# CONFIG_RCU_EXPEDITE_BOOT is not set
|
||||
# CONFIG_BUILD_BIN2C is not set
|
||||
# CONFIG_IKCONFIG is not set
|
||||
CONFIG_LOG_BUF_SHIFT=18
|
||||
CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
|
||||
CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
|
||||
CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
|
||||
CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y
|
||||
CONFIG_ARCH_SUPPORTS_INT128=y
|
||||
# CONFIG_NUMA_BALANCING is not set
|
||||
CONFIG_CGROUPS=y
|
||||
# CONFIG_CGROUP_DEBUG is not set
|
||||
# CONFIG_CGROUP_FREEZER is not set
|
||||
# CONFIG_CGROUP_PIDS is not set
|
||||
# CONFIG_CGROUP_DEVICE is not set
|
||||
# CONFIG_CPUSETS is not set
|
||||
# CONFIG_CGROUP_CPUACCT is not set
|
||||
@@ -188,6 +182,7 @@ CONFIG_SYSCTL_EXCEPTION_TRACE=y
|
||||
CONFIG_HAVE_PCSPKR_PLATFORM=y
|
||||
CONFIG_BPF=y
|
||||
# CONFIG_EXPERT is not set
|
||||
CONFIG_MULTIUSER=y
|
||||
CONFIG_SGETMASK_SYSCALL=y
|
||||
CONFIG_SYSFS_SYSCALL=y
|
||||
# CONFIG_SYSCTL_SYSCALL is not set
|
||||
@@ -206,7 +201,9 @@ CONFIG_EVENTFD=y
|
||||
CONFIG_SHMEM=y
|
||||
CONFIG_AIO=y
|
||||
CONFIG_ADVISE_SYSCALLS=y
|
||||
# CONFIG_USERFAULTFD is not set
|
||||
CONFIG_PCI_QUIRKS=y
|
||||
CONFIG_MEMBARRIER=y
|
||||
# CONFIG_EMBEDDED is not set
|
||||
CONFIG_HAVE_PERF_EVENTS=y
|
||||
|
||||
@@ -218,6 +215,7 @@ CONFIG_VM_EVENT_COUNTERS=y
|
||||
# CONFIG_COMPAT_BRK is not set
|
||||
CONFIG_SLAB=y
|
||||
# CONFIG_SLUB is not set
|
||||
# CONFIG_SYSTEM_DATA_VERIFICATION is not set
|
||||
# CONFIG_PROFILING is not set
|
||||
CONFIG_HAVE_OPROFILE=y
|
||||
CONFIG_OPROFILE_NMI_TIMER=y
|
||||
@@ -236,6 +234,7 @@ CONFIG_HAVE_ARCH_TRACEHOOK=y
|
||||
CONFIG_HAVE_DMA_ATTRS=y
|
||||
CONFIG_HAVE_DMA_CONTIGUOUS=y
|
||||
CONFIG_GENERIC_SMP_IDLE_THREAD=y
|
||||
CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT=y
|
||||
CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
|
||||
CONFIG_HAVE_DMA_API_DEBUG=y
|
||||
CONFIG_HAVE_HW_BREAKPOINT=y
|
||||
@@ -259,9 +258,12 @@ CONFIG_HAVE_CONTEXT_TRACKING=y
|
||||
CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
|
||||
CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
|
||||
CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y
|
||||
CONFIG_HAVE_ARCH_HUGE_VMAP=y
|
||||
CONFIG_HAVE_ARCH_SOFT_DIRTY=y
|
||||
CONFIG_MODULES_USE_ELF_RELA=y
|
||||
CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK=y
|
||||
CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
|
||||
CONFIG_HAVE_COPY_THREAD_TLS=y
|
||||
|
||||
#
|
||||
# GCOV-based kernel profiling
|
||||
@@ -278,7 +280,7 @@ CONFIG_MODVERSIONS=y
|
||||
# CONFIG_MODULE_SRCVERSION_ALL is not set
|
||||
# CONFIG_MODULE_SIG is not set
|
||||
# CONFIG_MODULE_COMPRESS is not set
|
||||
CONFIG_STOP_MACHINE=y
|
||||
CONFIG_MODULES_TREE_LOOKUP=y
|
||||
CONFIG_BLOCK=y
|
||||
CONFIG_BLK_DEV_BSG=y
|
||||
CONFIG_BLK_DEV_BSGLIB=y
|
||||
@@ -310,8 +312,10 @@ CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
|
||||
CONFIG_MUTEX_SPIN_ON_OWNER=y
|
||||
CONFIG_RWSEM_SPIN_ON_OWNER=y
|
||||
CONFIG_LOCK_SPIN_ON_OWNER=y
|
||||
CONFIG_ARCH_USE_QUEUE_RWLOCK=y
|
||||
CONFIG_QUEUE_RWLOCK=y
|
||||
CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
|
||||
CONFIG_QUEUED_SPINLOCKS=y
|
||||
CONFIG_ARCH_USE_QUEUED_RWLOCKS=y
|
||||
CONFIG_QUEUED_RWLOCKS=y
|
||||
CONFIG_FREEZER=y
|
||||
|
||||
#
|
||||
@@ -320,6 +324,7 @@ CONFIG_FREEZER=y
|
||||
CONFIG_ZONE_DMA=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_X86_FEATURE_NAMES=y
|
||||
# CONFIG_X86_X2APIC is not set
|
||||
CONFIG_X86_MPPARSE=y
|
||||
# CONFIG_X86_EXTENDED_PLATFORM is not set
|
||||
# CONFIG_X86_INTEL_LPSS is not set
|
||||
@@ -332,14 +337,13 @@ CONFIG_PARAVIRT=y
|
||||
CONFIG_XEN=y
|
||||
CONFIG_XEN_DOM0=y
|
||||
CONFIG_XEN_PVHVM=y
|
||||
CONFIG_XEN_MAX_DOMAIN_MEMORY=500
|
||||
CONFIG_XEN_512GB=y
|
||||
CONFIG_XEN_SAVE_RESTORE=y
|
||||
CONFIG_XEN_PVH=y
|
||||
CONFIG_KVM_GUEST=y
|
||||
CONFIG_PARAVIRT_TIME_ACCOUNTING=y
|
||||
CONFIG_PARAVIRT_CLOCK=y
|
||||
CONFIG_NO_BOOTMEM=y
|
||||
# CONFIG_MEMTEST is not set
|
||||
# CONFIG_MK8 is not set
|
||||
# CONFIG_MPSC is not set
|
||||
# CONFIG_MCORE2 is not set
|
||||
@@ -367,23 +371,21 @@ CONFIG_SCHED_MC=y
|
||||
CONFIG_PREEMPT_NONE=y
|
||||
# CONFIG_PREEMPT_VOLUNTARY is not set
|
||||
# CONFIG_PREEMPT is not set
|
||||
CONFIG_X86_UP_APIC_MSI=y
|
||||
CONFIG_X86_LOCAL_APIC=y
|
||||
CONFIG_X86_IO_APIC=y
|
||||
CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS=y
|
||||
# CONFIG_X86_MCE is not set
|
||||
# CONFIG_VM86 is not set
|
||||
CONFIG_X86_16BIT=y
|
||||
CONFIG_X86_ESPFIX64=y
|
||||
CONFIG_X86_VSYSCALL_EMULATION=y
|
||||
# CONFIG_I8K is not set
|
||||
# CONFIG_MICROCODE is not set
|
||||
# CONFIG_MICROCODE_INTEL_EARLY is not set
|
||||
# CONFIG_MICROCODE_AMD_EARLY is not set
|
||||
# CONFIG_X86_MSR is not set
|
||||
# CONFIG_X86_CPUID is not set
|
||||
CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
|
||||
CONFIG_ARCH_DMA_ADDR_T_64BIT=y
|
||||
CONFIG_DIRECT_GBPAGES=y
|
||||
CONFIG_X86_DIRECT_GBPAGES=y
|
||||
CONFIG_NUMA=y
|
||||
# CONFIG_AMD_NUMA is not set
|
||||
CONFIG_X86_64_ACPI_NUMA=y
|
||||
@@ -393,6 +395,7 @@ CONFIG_NODES_SHIFT=9
|
||||
CONFIG_ARCH_SPARSEMEM_ENABLE=y
|
||||
CONFIG_ARCH_SPARSEMEM_DEFAULT=y
|
||||
CONFIG_ARCH_SELECT_MEMORY_MODEL=y
|
||||
CONFIG_ARCH_MEMORY_PROBE=y
|
||||
CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000
|
||||
CONFIG_SELECT_MEMORY_MODEL=y
|
||||
CONFIG_SPARSEMEM_MANUAL=y
|
||||
@@ -408,8 +411,9 @@ CONFIG_HAVE_MEMBLOCK_NODE_MAP=y
|
||||
CONFIG_ARCH_DISCARD_MEMBLOCK=y
|
||||
# CONFIG_MOVABLE_NODE is not set
|
||||
# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
|
||||
# CONFIG_MEMORY_HOTPLUG is not set
|
||||
CONFIG_PAGEFLAGS_EXTENDED=y
|
||||
CONFIG_MEMORY_HOTPLUG=y
|
||||
CONFIG_MEMORY_HOTPLUG_SPARSE=y
|
||||
# CONFIG_MEMORY_HOTREMOVE is not set
|
||||
CONFIG_SPLIT_PTLOCK_CPUS=4
|
||||
CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK=y
|
||||
CONFIG_MEMORY_BALLOON=y
|
||||
@@ -429,12 +433,14 @@ CONFIG_DEFAULT_MMAP_MIN_ADDR=65536
|
||||
# CONFIG_ZBUD is not set
|
||||
# CONFIG_ZSMALLOC is not set
|
||||
CONFIG_GENERIC_EARLY_IOREMAP=y
|
||||
CONFIG_ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT=y
|
||||
# CONFIG_DEFERRED_STRUCT_PAGE_INIT is not set
|
||||
# CONFIG_IDLE_PAGE_TRACKING is not set
|
||||
# CONFIG_X86_PMEM_LEGACY is not set
|
||||
# CONFIG_X86_CHECK_BIOS_CORRUPTION is not set
|
||||
CONFIG_X86_RESERVE_LOW=64
|
||||
CONFIG_MTRR=y
|
||||
CONFIG_MTRR_SANITIZER=y
|
||||
CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT=0
|
||||
CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT=1
|
||||
# CONFIG_MTRR_SANITIZER is not set
|
||||
CONFIG_X86_PAT=y
|
||||
CONFIG_ARCH_USES_PG_UNCACHED=y
|
||||
CONFIG_ARCH_RANDOM=y
|
||||
@@ -447,8 +453,9 @@ CONFIG_SECCOMP=y
|
||||
# CONFIG_HZ_300 is not set
|
||||
CONFIG_HZ_1000=y
|
||||
CONFIG_HZ=1000
|
||||
# CONFIG_SCHED_HRTICK is not set
|
||||
CONFIG_SCHED_HRTICK=y
|
||||
# CONFIG_KEXEC is not set
|
||||
# CONFIG_KEXEC_FILE is not set
|
||||
# CONFIG_CRASH_DUMP is not set
|
||||
CONFIG_PHYSICAL_START=0x1000000
|
||||
CONFIG_RELOCATABLE=y
|
||||
@@ -457,9 +464,14 @@ CONFIG_PHYSICAL_ALIGN=0x1000000
|
||||
CONFIG_HOTPLUG_CPU=y
|
||||
# CONFIG_BOOTPARAM_HOTPLUG_CPU0 is not set
|
||||
# CONFIG_DEBUG_HOTPLUG_CPU0 is not set
|
||||
# CONFIG_LEGACY_VSYSCALL_NATIVE is not set
|
||||
CONFIG_LEGACY_VSYSCALL_EMULATE=y
|
||||
# CONFIG_LEGACY_VSYSCALL_NONE is not set
|
||||
# CONFIG_CMDLINE_BOOL is not set
|
||||
CONFIG_MODIFY_LDT_SYSCALL=y
|
||||
CONFIG_HAVE_LIVEPATCH=y
|
||||
CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
|
||||
CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
|
||||
CONFIG_USE_PERCPU_NUMA_NODE_ID=y
|
||||
|
||||
#
|
||||
@@ -478,13 +490,22 @@ CONFIG_PM=y
|
||||
CONFIG_ACPI=y
|
||||
CONFIG_ACPI_LEGACY_TABLES_LOOKUP=y
|
||||
CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC=y
|
||||
CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT=y
|
||||
# CONFIG_ACPI_DEBUGGER is not set
|
||||
# CONFIG_ACPI_PROCFS_POWER is not set
|
||||
CONFIG_ACPI_REV_OVERRIDE_POSSIBLE=y
|
||||
# CONFIG_ACPI_EC_DEBUGFS is not set
|
||||
# CONFIG_ACPI_AC is not set
|
||||
# CONFIG_ACPI_BATTERY is not set
|
||||
# CONFIG_ACPI_BUTTON is not set
|
||||
CONFIG_ACPI_FAN=y
|
||||
# CONFIG_ACPI_DOCK is not set
|
||||
# CONFIG_ACPI_PROCESSOR is not set
|
||||
CONFIG_ACPI_CPU_FREQ_PSS=y
|
||||
CONFIG_ACPI_PROCESSOR_IDLE=y
|
||||
CONFIG_ACPI_PROCESSOR=y
|
||||
CONFIG_ACPI_HOTPLUG_CPU=y
|
||||
# CONFIG_ACPI_PROCESSOR_AGGREGATOR is not set
|
||||
CONFIG_ACPI_THERMAL=y
|
||||
CONFIG_ACPI_NUMA=y
|
||||
CONFIG_ACPI_CUSTOM_DSDT_FILE=""
|
||||
# CONFIG_ACPI_CUSTOM_DSDT is not set
|
||||
@@ -492,11 +513,13 @@ CONFIG_ACPI_CUSTOM_DSDT_FILE=""
|
||||
# CONFIG_ACPI_DEBUG is not set
|
||||
# CONFIG_ACPI_PCI_SLOT is not set
|
||||
CONFIG_X86_PM_TIMER=y
|
||||
# CONFIG_ACPI_CONTAINER is not set
|
||||
CONFIG_ACPI_CONTAINER=y
|
||||
CONFIG_ACPI_HOTPLUG_MEMORY=y
|
||||
CONFIG_ACPI_HOTPLUG_IOAPIC=y
|
||||
# CONFIG_ACPI_SBS is not set
|
||||
# CONFIG_ACPI_HED is not set
|
||||
# CONFIG_ACPI_REDUCED_HARDWARE_ONLY is not set
|
||||
# CONFIG_ACPI_NFIT is not set
|
||||
CONFIG_HAVE_ACPI_APEI=y
|
||||
CONFIG_HAVE_ACPI_APEI_NMI=y
|
||||
# CONFIG_ACPI_APEI is not set
|
||||
@@ -511,8 +534,11 @@ CONFIG_HAVE_ACPI_APEI_NMI=y
|
||||
#
|
||||
# CPU Idle
|
||||
#
|
||||
# CONFIG_CPU_IDLE is not set
|
||||
CONFIG_CPU_IDLE=y
|
||||
CONFIG_CPU_IDLE_GOV_LADDER=y
|
||||
CONFIG_CPU_IDLE_GOV_MENU=y
|
||||
# CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set
|
||||
# CONFIG_INTEL_IDLE is not set
|
||||
|
||||
#
|
||||
# Memory power savings
|
||||
@@ -536,7 +562,9 @@ CONFIG_PCIEASPM_DEFAULT=y
|
||||
# CONFIG_PCIEASPM_POWERSAVE is not set
|
||||
# CONFIG_PCIEASPM_PERFORMANCE is not set
|
||||
CONFIG_PCIE_PME=y
|
||||
CONFIG_PCI_BUS_ADDR_T_64BIT=y
|
||||
CONFIG_PCI_MSI=y
|
||||
CONFIG_PCI_MSI_IRQ_DOMAIN=y
|
||||
CONFIG_PCI_REALLOC_ENABLE_AUTO=y
|
||||
CONFIG_PCI_STUB=y
|
||||
CONFIG_XEN_PCIDEV_FRONTEND=y
|
||||
@@ -567,13 +595,13 @@ CONFIG_HOTPLUG_PCI_CPCI=y
|
||||
# Executable file formats / Emulations
|
||||
#
|
||||
CONFIG_BINFMT_ELF=y
|
||||
CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE=y
|
||||
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
|
||||
CONFIG_BINFMT_SCRIPT=y
|
||||
# CONFIG_HAVE_AOUT is not set
|
||||
CONFIG_BINFMT_MISC=y
|
||||
CONFIG_COREDUMP=y
|
||||
# CONFIG_IA32_EMULATION is not set
|
||||
# CONFIG_X86_X32 is not set
|
||||
CONFIG_X86_DEV_DMA_OPS=y
|
||||
CONFIG_PMC_ATOM=y
|
||||
CONFIG_NET=y
|
||||
@@ -585,11 +613,7 @@ CONFIG_PACKET=y
|
||||
# CONFIG_PACKET_DIAG is not set
|
||||
CONFIG_UNIX=y
|
||||
# CONFIG_UNIX_DIAG is not set
|
||||
CONFIG_XFRM=y
|
||||
# CONFIG_XFRM_USER is not set
|
||||
# CONFIG_XFRM_SUB_POLICY is not set
|
||||
# CONFIG_XFRM_MIGRATE is not set
|
||||
# CONFIG_XFRM_STATISTICS is not set
|
||||
# CONFIG_NET_KEY is not set
|
||||
CONFIG_INET=y
|
||||
# CONFIG_IP_MULTICAST is not set
|
||||
@@ -597,17 +621,15 @@ CONFIG_INET=y
|
||||
# CONFIG_IP_PNP is not set
|
||||
# CONFIG_NET_IPIP is not set
|
||||
# CONFIG_NET_IPGRE_DEMUX is not set
|
||||
CONFIG_NET_IP_TUNNEL=y
|
||||
# CONFIG_NET_IP_TUNNEL is not set
|
||||
# CONFIG_SYN_COOKIES is not set
|
||||
# CONFIG_NET_UDP_TUNNEL is not set
|
||||
# CONFIG_NET_FOU is not set
|
||||
# CONFIG_NET_FOU_IP_TUNNELS is not set
|
||||
# CONFIG_GENEVE is not set
|
||||
# CONFIG_INET_AH is not set
|
||||
# CONFIG_INET_ESP is not set
|
||||
# CONFIG_INET_IPCOMP is not set
|
||||
# CONFIG_INET_XFRM_TUNNEL is not set
|
||||
CONFIG_INET_TUNNEL=y
|
||||
# CONFIG_INET_TUNNEL is not set
|
||||
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
|
||||
# CONFIG_INET_XFRM_MODE_TUNNEL is not set
|
||||
# CONFIG_INET_XFRM_MODE_BEET is not set
|
||||
@@ -624,16 +646,14 @@ CONFIG_IPV6=y
|
||||
# CONFIG_INET6_ESP is not set
|
||||
# CONFIG_INET6_IPCOMP is not set
|
||||
# CONFIG_IPV6_MIP6 is not set
|
||||
# CONFIG_IPV6_ILA is not set
|
||||
# CONFIG_INET6_XFRM_TUNNEL is not set
|
||||
# CONFIG_INET6_TUNNEL is not set
|
||||
CONFIG_INET6_XFRM_MODE_TRANSPORT=y
|
||||
CONFIG_INET6_XFRM_MODE_TUNNEL=y
|
||||
CONFIG_INET6_XFRM_MODE_BEET=y
|
||||
# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
|
||||
# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
|
||||
# CONFIG_INET6_XFRM_MODE_BEET is not set
|
||||
# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
|
||||
# CONFIG_IPV6_VTI is not set
|
||||
CONFIG_IPV6_SIT=y
|
||||
# CONFIG_IPV6_SIT_6RD is not set
|
||||
CONFIG_IPV6_NDISC_NODETYPE=y
|
||||
# CONFIG_IPV6_SIT is not set
|
||||
# CONFIG_IPV6_TUNNEL is not set
|
||||
# CONFIG_IPV6_GRE is not set
|
||||
# CONFIG_IPV6_MULTIPLE_TABLES is not set
|
||||
@@ -667,9 +687,10 @@ CONFIG_HAVE_NET_DSA=y
|
||||
# CONFIG_VSOCKETS is not set
|
||||
# CONFIG_NETLINK_MMAP is not set
|
||||
# CONFIG_NETLINK_DIAG is not set
|
||||
# CONFIG_NET_MPLS_GSO is not set
|
||||
# CONFIG_MPLS is not set
|
||||
# CONFIG_HSR is not set
|
||||
# CONFIG_NET_SWITCHDEV is not set
|
||||
# CONFIG_NET_L3_MASTER_DEV is not set
|
||||
CONFIG_RPS=y
|
||||
CONFIG_RFS_ACCEL=y
|
||||
CONFIG_XPS=y
|
||||
@@ -698,6 +719,7 @@ CONFIG_NET_9P_VIRTIO=y
|
||||
# CONFIG_CAIF is not set
|
||||
# CONFIG_CEPH_LIB is not set
|
||||
# CONFIG_NFC is not set
|
||||
# CONFIG_LWTUNNEL is not set
|
||||
CONFIG_HAVE_BPF_JIT=y
|
||||
|
||||
#
|
||||
@@ -727,10 +749,11 @@ CONFIG_GENERIC_CPU_AUTOPROBE=y
|
||||
#
|
||||
# CONFIG_CONNECTOR is not set
|
||||
# CONFIG_MTD is not set
|
||||
# CONFIG_OF is not set
|
||||
CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
|
||||
# CONFIG_PARPORT is not set
|
||||
CONFIG_PNP=y
|
||||
CONFIG_PNP_DEBUG_MESSAGES=y
|
||||
# CONFIG_PNP_DEBUG_MESSAGES is not set
|
||||
|
||||
#
|
||||
# Protocols
|
||||
@@ -749,7 +772,6 @@ CONFIG_BLK_DEV_LOOP_MIN_COUNT=0
|
||||
# CONFIG_BLK_DEV_CRYPTOLOOP is not set
|
||||
# CONFIG_BLK_DEV_DRBD is not set
|
||||
# CONFIG_BLK_DEV_NBD is not set
|
||||
# CONFIG_BLK_DEV_NVME is not set
|
||||
# CONFIG_BLK_DEV_SKD is not set
|
||||
# CONFIG_BLK_DEV_SX8 is not set
|
||||
CONFIG_BLK_DEV_RAM=y
|
||||
@@ -758,11 +780,11 @@ CONFIG_BLK_DEV_RAM_SIZE=16384
|
||||
# CONFIG_CDROM_PKTCDVD is not set
|
||||
# CONFIG_ATA_OVER_ETH is not set
|
||||
CONFIG_XEN_BLKDEV_FRONTEND=y
|
||||
# CONFIG_XEN_BLKDEV_BACKEND is not set
|
||||
CONFIG_VIRTIO_BLK=y
|
||||
# CONFIG_BLK_DEV_HD is not set
|
||||
# CONFIG_BLK_DEV_RBD is not set
|
||||
# CONFIG_BLK_DEV_RSXX is not set
|
||||
# CONFIG_BLK_DEV_NVME is not set
|
||||
|
||||
#
|
||||
# Misc devices
|
||||
@@ -775,14 +797,13 @@ CONFIG_VIRTIO_BLK=y
|
||||
# CONFIG_TIFM_CORE is not set
|
||||
# CONFIG_ENCLOSURE_SERVICES is not set
|
||||
# CONFIG_HP_ILO is not set
|
||||
# CONFIG_VMWARE_BALLOON is not set
|
||||
# CONFIG_SRAM is not set
|
||||
# CONFIG_C2PORT is not set
|
||||
|
||||
#
|
||||
# EEPROM support
|
||||
#
|
||||
CONFIG_EEPROM_93CX6=m
|
||||
CONFIG_EEPROM_93CX6=y
|
||||
# CONFIG_CB710_CORE is not set
|
||||
|
||||
#
|
||||
@@ -799,6 +820,11 @@ CONFIG_EEPROM_93CX6=m
|
||||
#
|
||||
# CONFIG_INTEL_MIC_BUS is not set
|
||||
|
||||
#
|
||||
# SCIF Bus Driver
|
||||
#
|
||||
# CONFIG_SCIF_BUS is not set
|
||||
|
||||
#
|
||||
# Intel MIC Host Driver
|
||||
#
|
||||
@@ -806,9 +832,19 @@ CONFIG_EEPROM_93CX6=m
|
||||
#
|
||||
# Intel MIC Card Driver
|
||||
#
|
||||
|
||||
#
|
||||
# SCIF Driver
|
||||
#
|
||||
|
||||
#
|
||||
# Intel MIC Coprocessor State Management (COSM) Drivers
|
||||
#
|
||||
# CONFIG_GENWQE is not set
|
||||
# CONFIG_ECHO is not set
|
||||
# CONFIG_CXL_BASE is not set
|
||||
# CONFIG_CXL_KERNEL_API is not set
|
||||
# CONFIG_CXL_EEH is not set
|
||||
CONFIG_HAVE_IDE=y
|
||||
# CONFIG_IDE is not set
|
||||
|
||||
@@ -870,13 +906,14 @@ CONFIG_SCSI_LOWLEVEL=y
|
||||
# CONFIG_MEGARAID_NEWGEN is not set
|
||||
# CONFIG_MEGARAID_LEGACY is not set
|
||||
# CONFIG_MEGARAID_SAS is not set
|
||||
# CONFIG_SCSI_MPT2SAS is not set
|
||||
# CONFIG_SCSI_MPT3SAS is not set
|
||||
# CONFIG_SCSI_MPT2SAS is not set
|
||||
# CONFIG_SCSI_UFSHCD is not set
|
||||
# CONFIG_SCSI_HPTIOP is not set
|
||||
# CONFIG_SCSI_BUSLOGIC is not set
|
||||
# CONFIG_VMWARE_PVSCSI is not set
|
||||
# CONFIG_XEN_SCSI_FRONTEND is not set
|
||||
# CONFIG_SCSI_SNIC is not set
|
||||
# CONFIG_SCSI_DMX3191D is not set
|
||||
# CONFIG_SCSI_EATA is not set
|
||||
# CONFIG_SCSI_FUTURE_DOMAIN is not set
|
||||
@@ -923,6 +960,7 @@ CONFIG_NET_CORE=y
|
||||
# CONFIG_NETPOLL is not set
|
||||
# CONFIG_NET_POLL_CONTROLLER is not set
|
||||
# CONFIG_TUN is not set
|
||||
# CONFIG_TUN_VNET_CROSS_LE is not set
|
||||
# CONFIG_VETH is not set
|
||||
CONFIG_VIRTIO_NET=y
|
||||
# CONFIG_NLMON is not set
|
||||
@@ -936,14 +974,79 @@ CONFIG_VIRTIO_NET=y
|
||||
# Distributed Switch Architecture drivers
|
||||
#
|
||||
# CONFIG_NET_DSA_MV88E6XXX is not set
|
||||
# CONFIG_NET_DSA_MV88E6060 is not set
|
||||
# CONFIG_NET_DSA_MV88E6XXX_NEED_PPU is not set
|
||||
# CONFIG_NET_DSA_MV88E6131 is not set
|
||||
# CONFIG_NET_DSA_MV88E6123_61_65 is not set
|
||||
# CONFIG_NET_DSA_MV88E6171 is not set
|
||||
# CONFIG_NET_DSA_MV88E6352 is not set
|
||||
# CONFIG_NET_DSA_BCM_SF2 is not set
|
||||
# CONFIG_ETHERNET is not set
|
||||
CONFIG_ETHERNET=y
|
||||
# CONFIG_NET_VENDOR_3COM is not set
|
||||
# CONFIG_NET_VENDOR_ADAPTEC is not set
|
||||
# CONFIG_NET_VENDOR_AGERE is not set
|
||||
# CONFIG_NET_VENDOR_ALTEON is not set
|
||||
# CONFIG_ALTERA_TSE is not set
|
||||
# CONFIG_NET_VENDOR_AMD is not set
|
||||
# CONFIG_NET_VENDOR_ARC is not set
|
||||
# CONFIG_NET_VENDOR_ATHEROS is not set
|
||||
# CONFIG_NET_VENDOR_AURORA is not set
|
||||
CONFIG_NET_CADENCE=y
|
||||
# CONFIG_MACB is not set
|
||||
# CONFIG_NET_VENDOR_BROADCOM is not set
|
||||
# CONFIG_NET_VENDOR_BROCADE is not set
|
||||
CONFIG_NET_VENDOR_CAVIUM=y
|
||||
# CONFIG_THUNDER_NIC_PF is not set
|
||||
# CONFIG_THUNDER_NIC_VF is not set
|
||||
# CONFIG_THUNDER_NIC_BGX is not set
|
||||
# CONFIG_LIQUIDIO is not set
|
||||
# CONFIG_NET_VENDOR_CHELSIO is not set
|
||||
# CONFIG_NET_VENDOR_CISCO is not set
|
||||
# CONFIG_CX_ECAT is not set
|
||||
# CONFIG_DNET is not set
|
||||
# CONFIG_NET_VENDOR_DEC is not set
|
||||
# CONFIG_NET_VENDOR_DLINK is not set
|
||||
# CONFIG_NET_VENDOR_EMULEX is not set
|
||||
CONFIG_NET_VENDOR_EZCHIP=y
|
||||
# CONFIG_NET_VENDOR_EXAR is not set
|
||||
# CONFIG_NET_VENDOR_HP is not set
|
||||
CONFIG_NET_VENDOR_INTEL=y
|
||||
# CONFIG_E100 is not set
|
||||
CONFIG_E1000=y
|
||||
# CONFIG_E1000E is not set
|
||||
# CONFIG_IGB is not set
|
||||
# CONFIG_IGBVF is not set
|
||||
# CONFIG_IXGB is not set
|
||||
# CONFIG_IXGBE is not set
|
||||
# CONFIG_IXGBEVF is not set
|
||||
# CONFIG_I40E is not set
|
||||
# CONFIG_I40EVF is not set
|
||||
# CONFIG_FM10K is not set
|
||||
# CONFIG_NET_VENDOR_I825XX is not set
|
||||
# CONFIG_JME is not set
|
||||
# CONFIG_NET_VENDOR_MARVELL is not set
|
||||
# CONFIG_NET_VENDOR_MELLANOX is not set
|
||||
# CONFIG_NET_VENDOR_MICREL is not set
|
||||
# CONFIG_NET_VENDOR_MYRI is not set
|
||||
# CONFIG_FEALNX is not set
|
||||
# CONFIG_NET_VENDOR_NATSEMI is not set
|
||||
# CONFIG_NET_VENDOR_NVIDIA is not set
|
||||
# CONFIG_NET_VENDOR_OKI is not set
|
||||
# CONFIG_ETHOC is not set
|
||||
# CONFIG_NET_PACKET_ENGINE is not set
|
||||
# CONFIG_NET_VENDOR_QLOGIC is not set
|
||||
# CONFIG_NET_VENDOR_QUALCOMM is not set
|
||||
# CONFIG_NET_VENDOR_REALTEK is not set
|
||||
CONFIG_NET_VENDOR_RENESAS=y
|
||||
# CONFIG_NET_VENDOR_RDC is not set
|
||||
# CONFIG_NET_VENDOR_ROCKER is not set
|
||||
# CONFIG_NET_VENDOR_SAMSUNG is not set
|
||||
# CONFIG_NET_VENDOR_SEEQ is not set
|
||||
# CONFIG_NET_VENDOR_SILAN is not set
|
||||
# CONFIG_NET_VENDOR_SIS is not set
|
||||
# CONFIG_SFC is not set
|
||||
# CONFIG_NET_VENDOR_SMSC is not set
|
||||
# CONFIG_NET_VENDOR_STMICRO is not set
|
||||
# CONFIG_NET_VENDOR_SUN is not set
|
||||
CONFIG_NET_VENDOR_SYNOPSYS=y
|
||||
# CONFIG_NET_VENDOR_TEHUTI is not set
|
||||
# CONFIG_NET_VENDOR_TI is not set
|
||||
# CONFIG_NET_VENDOR_VIA is not set
|
||||
# CONFIG_NET_VENDOR_WIZNET is not set
|
||||
# CONFIG_FDDI is not set
|
||||
# CONFIG_HIPPI is not set
|
||||
# CONFIG_NET_SB1000 is not set
|
||||
@@ -961,9 +1064,10 @@ CONFIG_VIRTIO_NET=y
|
||||
#
|
||||
# CONFIG_WAN is not set
|
||||
CONFIG_XEN_NETDEV_FRONTEND=y
|
||||
# CONFIG_XEN_NETDEV_BACKEND is not set
|
||||
# CONFIG_VMXNET3 is not set
|
||||
# CONFIG_FUJITSU_ES is not set
|
||||
# CONFIG_ISDN is not set
|
||||
# CONFIG_NVM is not set
|
||||
|
||||
#
|
||||
# Input device support
|
||||
@@ -995,17 +1099,8 @@ CONFIG_INPUT=y
|
||||
#
|
||||
# Hardware I/O ports
|
||||
#
|
||||
CONFIG_SERIO=y
|
||||
# CONFIG_SERIO is not set
|
||||
CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y
|
||||
CONFIG_SERIO_I8042=y
|
||||
CONFIG_SERIO_SERPORT=y
|
||||
# CONFIG_SERIO_CT82C710 is not set
|
||||
# CONFIG_SERIO_PCIPS2 is not set
|
||||
CONFIG_SERIO_LIBPS2=y
|
||||
CONFIG_SERIO_RAW=m
|
||||
# CONFIG_SERIO_ALTERA_PS2 is not set
|
||||
# CONFIG_SERIO_PS2MULT is not set
|
||||
# CONFIG_SERIO_ARC_PS2 is not set
|
||||
# CONFIG_GAMEPORT is not set
|
||||
|
||||
#
|
||||
@@ -1044,13 +1139,16 @@ CONFIG_SERIAL_8250_MANY_PORTS=y
|
||||
CONFIG_SERIAL_8250_SHARE_IRQ=y
|
||||
# CONFIG_SERIAL_8250_DETECT_IRQ is not set
|
||||
CONFIG_SERIAL_8250_RSA=y
|
||||
# CONFIG_SERIAL_8250_FSL is not set
|
||||
# CONFIG_SERIAL_8250_DW is not set
|
||||
# CONFIG_SERIAL_8250_RT288X is not set
|
||||
# CONFIG_SERIAL_8250_FINTEK is not set
|
||||
# CONFIG_SERIAL_8250_MID is not set
|
||||
|
||||
#
|
||||
# Non-8250 serial port support
|
||||
#
|
||||
# CONFIG_SERIAL_MFD_HSU is not set
|
||||
# CONFIG_SERIAL_UARTLITE is not set
|
||||
CONFIG_SERIAL_CORE=y
|
||||
CONFIG_SERIAL_CORE_CONSOLE=y
|
||||
# CONFIG_SERIAL_JSM is not set
|
||||
@@ -1110,7 +1208,22 @@ CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
|
||||
# CONFIG_POWER_SUPPLY is not set
|
||||
# CONFIG_POWER_AVS is not set
|
||||
# CONFIG_HWMON is not set
|
||||
# CONFIG_THERMAL is not set
|
||||
CONFIG_THERMAL=y
|
||||
# CONFIG_THERMAL_WRITABLE_TRIPS is not set
|
||||
CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
|
||||
# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
|
||||
# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set
|
||||
# CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR is not set
|
||||
# CONFIG_THERMAL_GOV_FAIR_SHARE is not set
|
||||
CONFIG_THERMAL_GOV_STEP_WISE=y
|
||||
# CONFIG_THERMAL_GOV_BANG_BANG is not set
|
||||
# CONFIG_THERMAL_GOV_USER_SPACE is not set
|
||||
# CONFIG_THERMAL_GOV_POWER_ALLOCATOR is not set
|
||||
# CONFIG_THERMAL_EMULATION is not set
|
||||
# CONFIG_INTEL_POWERCLAMP is not set
|
||||
# CONFIG_INTEL_SOC_DTS_THERMAL is not set
|
||||
# CONFIG_INT340X_THERMAL is not set
|
||||
# CONFIG_INTEL_PCH_THERMAL is not set
|
||||
# CONFIG_WATCHDOG is not set
|
||||
CONFIG_SSB_POSSIBLE=y
|
||||
|
||||
@@ -1133,8 +1246,11 @@ CONFIG_BCMA_POSSIBLE=y
|
||||
# CONFIG_HTC_PASIC3 is not set
|
||||
# CONFIG_LPC_ICH is not set
|
||||
# CONFIG_LPC_SCH is not set
|
||||
# CONFIG_MFD_INTEL_LPSS_ACPI is not set
|
||||
# CONFIG_MFD_INTEL_LPSS_PCI is not set
|
||||
# CONFIG_MFD_JANZ_CMODIO is not set
|
||||
# CONFIG_MFD_KEMPLD is not set
|
||||
# CONFIG_MFD_MT6397 is not set
|
||||
# CONFIG_MFD_RDC321X is not set
|
||||
# CONFIG_MFD_RTSX_PCI is not set
|
||||
# CONFIG_MFD_SM501 is not set
|
||||
@@ -1153,10 +1269,6 @@ CONFIG_BCMA_POSSIBLE=y
|
||||
CONFIG_VGA_ARB=y
|
||||
CONFIG_VGA_ARB_MAX_GPUS=16
|
||||
# CONFIG_VGA_SWITCHEROO is not set
|
||||
|
||||
#
|
||||
# Direct Rendering Manager
|
||||
#
|
||||
# CONFIG_DRM is not set
|
||||
|
||||
#
|
||||
@@ -1188,6 +1300,8 @@ CONFIG_USB_OHCI_LITTLE_ENDIAN=y
|
||||
# CONFIG_NEW_LEDS is not set
|
||||
# CONFIG_ACCESSIBILITY is not set
|
||||
# CONFIG_INFINIBAND is not set
|
||||
CONFIG_EDAC_ATOMIC_SCRUB=y
|
||||
CONFIG_EDAC_SUPPORT=y
|
||||
# CONFIG_EDAC is not set
|
||||
CONFIG_RTC_LIB=y
|
||||
# CONFIG_RTC_CLASS is not set
|
||||
@@ -1203,6 +1317,7 @@ CONFIG_VIRTIO=y
|
||||
CONFIG_VIRTIO_PCI=y
|
||||
CONFIG_VIRTIO_PCI_LEGACY=y
|
||||
CONFIG_VIRTIO_BALLOON=y
|
||||
# CONFIG_VIRTIO_INPUT is not set
|
||||
CONFIG_VIRTIO_MMIO=y
|
||||
CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
|
||||
|
||||
@@ -1216,16 +1331,18 @@ CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
|
||||
#
|
||||
# CONFIG_XEN_BALLOON is not set
|
||||
# CONFIG_XEN_DEV_EVTCHN is not set
|
||||
CONFIG_XEN_BACKEND=y
|
||||
# CONFIG_XEN_BACKEND is not set
|
||||
# CONFIG_XENFS is not set
|
||||
# CONFIG_XEN_SYS_HYPERVISOR is not set
|
||||
CONFIG_XEN_XENBUS_FRONTEND=y
|
||||
# CONFIG_XEN_GNTDEV is not set
|
||||
# CONFIG_XEN_GRANT_DEV_ALLOC is not set
|
||||
CONFIG_SWIOTLB_XEN=y
|
||||
CONFIG_XEN_PCIDEV_BACKEND=m
|
||||
CONFIG_XEN_PRIVCMD=m
|
||||
CONFIG_XEN_HAVE_PVMMU=y
|
||||
CONFIG_XEN_AUTO_XLATE=y
|
||||
CONFIG_XEN_ACPI=y
|
||||
CONFIG_XEN_HAVE_VPMU=y
|
||||
# CONFIG_STAGING is not set
|
||||
# CONFIG_X86_PLATFORM_DEVICES is not set
|
||||
# CONFIG_CHROME_PLATFORMS is not set
|
||||
@@ -1260,6 +1377,7 @@ CONFIG_CLKBLD_I8253=y
|
||||
#
|
||||
# SOC (System On Chip) specific Drivers
|
||||
#
|
||||
# CONFIG_SUNXI_SRAM is not set
|
||||
# CONFIG_SOC_TI is not set
|
||||
# CONFIG_PM_DEVFREQ is not set
|
||||
# CONFIG_EXTCON is not set
|
||||
@@ -1276,15 +1394,33 @@ CONFIG_CLKBLD_I8253=y
|
||||
# PHY Subsystem
|
||||
#
|
||||
# CONFIG_GENERIC_PHY is not set
|
||||
# CONFIG_PHY_PXA_28NM_HSIC is not set
|
||||
# CONFIG_PHY_PXA_28NM_USB2 is not set
|
||||
# CONFIG_BCM_KONA_USB2_PHY is not set
|
||||
# CONFIG_POWERCAP is not set
|
||||
# CONFIG_MCB is not set
|
||||
|
||||
#
|
||||
# Performance monitor support
|
||||
#
|
||||
# CONFIG_RAS is not set
|
||||
# CONFIG_THUNDERBOLT is not set
|
||||
|
||||
#
|
||||
# Android
|
||||
#
|
||||
# CONFIG_ANDROID is not set
|
||||
# CONFIG_LIBNVDIMM is not set
|
||||
# CONFIG_NVMEM is not set
|
||||
# CONFIG_STM is not set
|
||||
# CONFIG_STM_DUMMY is not set
|
||||
# CONFIG_STM_SOURCE_CONSOLE is not set
|
||||
# CONFIG_INTEL_TH is not set
|
||||
|
||||
#
|
||||
# FPGA Configuration Support
|
||||
#
|
||||
# CONFIG_FPGA is not set
|
||||
|
||||
#
|
||||
# Firmware Drivers
|
||||
@@ -1306,9 +1442,10 @@ CONFIG_DCACHE_WORD_ACCESS=y
|
||||
# CONFIG_EXT2_FS is not set
|
||||
# CONFIG_EXT3_FS is not set
|
||||
CONFIG_EXT4_FS=y
|
||||
CONFIG_EXT4_USE_FOR_EXT23=y
|
||||
CONFIG_EXT4_USE_FOR_EXT2=y
|
||||
CONFIG_EXT4_FS_POSIX_ACL=y
|
||||
# CONFIG_EXT4_FS_SECURITY is not set
|
||||
# CONFIG_EXT4_ENCRYPTION is not set
|
||||
# CONFIG_EXT4_DEBUG is not set
|
||||
CONFIG_JBD2=y
|
||||
# CONFIG_JBD2_DEBUG is not set
|
||||
@@ -1324,6 +1461,7 @@ CONFIG_XFS_POSIX_ACL=y
|
||||
# CONFIG_GFS2_FS is not set
|
||||
# CONFIG_BTRFS_FS is not set
|
||||
# CONFIG_NILFS2_FS is not set
|
||||
# CONFIG_F2FS_FS is not set
|
||||
# CONFIG_FS_DAX is not set
|
||||
CONFIG_FS_POSIX_ACL=y
|
||||
CONFIG_EXPORTFS=y
|
||||
@@ -1363,6 +1501,7 @@ CONFIG_PROC_FS=y
|
||||
# CONFIG_PROC_KCORE is not set
|
||||
CONFIG_PROC_SYSCTL=y
|
||||
CONFIG_PROC_PAGE_MONITOR=y
|
||||
# CONFIG_PROC_CHILDREN is not set
|
||||
CONFIG_KERNFS=y
|
||||
CONFIG_SYSFS=y
|
||||
CONFIG_TMPFS=y
|
||||
@@ -1385,7 +1524,7 @@ CONFIG_9P_FS_POSIX_ACL=y
|
||||
CONFIG_9P_FS_SECURITY=y
|
||||
CONFIG_NLS=y
|
||||
CONFIG_NLS_DEFAULT="utf8"
|
||||
CONFIG_NLS_CODEPAGE_437=m
|
||||
# CONFIG_NLS_CODEPAGE_437 is not set
|
||||
# CONFIG_NLS_CODEPAGE_737 is not set
|
||||
# CONFIG_NLS_CODEPAGE_775 is not set
|
||||
# CONFIG_NLS_CODEPAGE_850 is not set
|
||||
@@ -1433,7 +1572,7 @@ CONFIG_NLS_CODEPAGE_437=m
|
||||
# CONFIG_NLS_MAC_INUIT is not set
|
||||
# CONFIG_NLS_MAC_ROMANIAN is not set
|
||||
# CONFIG_NLS_MAC_TURKISH is not set
|
||||
CONFIG_NLS_UTF8=m
|
||||
# CONFIG_NLS_UTF8 is not set
|
||||
|
||||
#
|
||||
# Kernel hacking
|
||||
@@ -1457,6 +1596,7 @@ CONFIG_FRAME_WARN=2048
|
||||
# CONFIG_DEBUG_FS is not set
|
||||
# CONFIG_HEADERS_CHECK is not set
|
||||
# CONFIG_DEBUG_SECTION_MISMATCH is not set
|
||||
CONFIG_SECTION_MISMATCH_WARN_ONLY=y
|
||||
CONFIG_ARCH_WANT_FRAME_POINTERS=y
|
||||
# CONFIG_FRAME_POINTER is not set
|
||||
# CONFIG_MAGIC_SYSRQ is not set
|
||||
@@ -1477,6 +1617,8 @@ CONFIG_HAVE_ARCH_KMEMCHECK=y
|
||||
# CONFIG_PANIC_ON_OOPS is not set
|
||||
CONFIG_PANIC_ON_OOPS_VALUE=0
|
||||
CONFIG_PANIC_TIMEOUT=0
|
||||
CONFIG_SCHED_INFO=y
|
||||
# CONFIG_DEBUG_TIMEKEEPING is not set
|
||||
|
||||
#
|
||||
# Lock Debugging (spinlocks, mutexes, etc...)
|
||||
@@ -1487,6 +1629,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
|
||||
#
|
||||
# RCU Debugging
|
||||
#
|
||||
# CONFIG_PROVE_RCU is not set
|
||||
# CONFIG_SPARSE_RCU_POINTER is not set
|
||||
# CONFIG_TORTURE_TEST is not set
|
||||
CONFIG_RCU_CPU_STALL_TIMEOUT=60
|
||||
@@ -1511,6 +1654,7 @@ CONFIG_TRACING_SUPPORT=y
|
||||
# CONFIG_TEST_HEXDUMP is not set
|
||||
# CONFIG_TEST_STRING_HELPERS is not set
|
||||
# CONFIG_TEST_KSTRTOX is not set
|
||||
# CONFIG_TEST_PRINTF is not set
|
||||
# CONFIG_TEST_RHASHTABLE is not set
|
||||
# CONFIG_PROVIDE_OHCI1394_DMA_INIT is not set
|
||||
# CONFIG_DMA_API_DEBUG is not set
|
||||
@@ -1519,12 +1663,15 @@ CONFIG_TRACING_SUPPORT=y
|
||||
# CONFIG_TEST_BPF is not set
|
||||
# CONFIG_TEST_FIRMWARE is not set
|
||||
# CONFIG_TEST_UDELAY is not set
|
||||
# CONFIG_MEMTEST is not set
|
||||
# CONFIG_TEST_STATIC_KEYS is not set
|
||||
# CONFIG_SAMPLES is not set
|
||||
CONFIG_HAVE_ARCH_KGDB=y
|
||||
# CONFIG_STRICT_DEVMEM is not set
|
||||
# CONFIG_X86_VERBOSE_BOOTUP is not set
|
||||
CONFIG_EARLY_PRINTK=y
|
||||
# CONFIG_EARLY_PRINTK_DBGP is not set
|
||||
# CONFIG_X86_PTDUMP_CORE is not set
|
||||
# CONFIG_DEBUG_SET_MODULE_RONX is not set
|
||||
CONFIG_DOUBLEFAULT=y
|
||||
# CONFIG_IOMMU_STRESS is not set
|
||||
@@ -1539,6 +1686,7 @@ CONFIG_IO_DELAY_0X80=y
|
||||
# CONFIG_IO_DELAY_NONE is not set
|
||||
CONFIG_DEFAULT_IO_DELAY_TYPE=0
|
||||
# CONFIG_OPTIMIZE_INLINING is not set
|
||||
# CONFIG_PUNIT_ATOM_DEBUG is not set
|
||||
|
||||
#
|
||||
# Security options
|
||||
@@ -1556,14 +1704,24 @@ CONFIG_CRYPTO=y
|
||||
#
|
||||
CONFIG_CRYPTO_ALGAPI=y
|
||||
CONFIG_CRYPTO_ALGAPI2=y
|
||||
CONFIG_CRYPTO_AEAD2=y
|
||||
CONFIG_CRYPTO_BLKCIPHER2=y
|
||||
CONFIG_CRYPTO_HASH=y
|
||||
CONFIG_CRYPTO_HASH2=y
|
||||
# CONFIG_CRYPTO_MANAGER is not set
|
||||
# CONFIG_CRYPTO_MANAGER2 is not set
|
||||
CONFIG_CRYPTO_RNG=y
|
||||
CONFIG_CRYPTO_RNG2=y
|
||||
CONFIG_CRYPTO_PCOMP2=y
|
||||
CONFIG_CRYPTO_AKCIPHER2=y
|
||||
# CONFIG_CRYPTO_RSA is not set
|
||||
CONFIG_CRYPTO_MANAGER=y
|
||||
CONFIG_CRYPTO_MANAGER2=y
|
||||
# CONFIG_CRYPTO_USER is not set
|
||||
# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
|
||||
# CONFIG_CRYPTO_GF128MUL is not set
|
||||
# CONFIG_CRYPTO_NULL is not set
|
||||
CONFIG_CRYPTO_NULL2=y
|
||||
# CONFIG_CRYPTO_PCRYPT is not set
|
||||
CONFIG_CRYPTO_WORKQUEUE=y
|
||||
# CONFIG_CRYPTO_CRYPTD is not set
|
||||
# CONFIG_CRYPTO_MCRYPTD is not set
|
||||
# CONFIG_CRYPTO_AUTHENC is not set
|
||||
@@ -1574,7 +1732,9 @@ CONFIG_CRYPTO_HASH2=y
|
||||
#
|
||||
# CONFIG_CRYPTO_CCM is not set
|
||||
# CONFIG_CRYPTO_GCM is not set
|
||||
# CONFIG_CRYPTO_CHACHA20POLY1305 is not set
|
||||
# CONFIG_CRYPTO_SEQIV is not set
|
||||
# CONFIG_CRYPTO_ECHAINIV is not set
|
||||
|
||||
#
|
||||
# Block modes
|
||||
@@ -1586,12 +1746,13 @@ CONFIG_CRYPTO_HASH2=y
|
||||
# CONFIG_CRYPTO_LRW is not set
|
||||
# CONFIG_CRYPTO_PCBC is not set
|
||||
# CONFIG_CRYPTO_XTS is not set
|
||||
# CONFIG_CRYPTO_KEYWRAP is not set
|
||||
|
||||
#
|
||||
# Hash modes
|
||||
#
|
||||
# CONFIG_CRYPTO_CMAC is not set
|
||||
# CONFIG_CRYPTO_HMAC is not set
|
||||
CONFIG_CRYPTO_HMAC=y
|
||||
# CONFIG_CRYPTO_XCBC is not set
|
||||
# CONFIG_CRYPTO_VMAC is not set
|
||||
|
||||
@@ -1605,6 +1766,8 @@ CONFIG_CRYPTO_CRC32C=y
|
||||
CONFIG_CRYPTO_CRCT10DIF=y
|
||||
# CONFIG_CRYPTO_CRCT10DIF_PCLMUL is not set
|
||||
# CONFIG_CRYPTO_GHASH is not set
|
||||
# CONFIG_CRYPTO_POLY1305 is not set
|
||||
# CONFIG_CRYPTO_POLY1305_X86_64 is not set
|
||||
# CONFIG_CRYPTO_MD4 is not set
|
||||
# CONFIG_CRYPTO_MD5 is not set
|
||||
# CONFIG_CRYPTO_MICHAEL_MIC is not set
|
||||
@@ -1617,7 +1780,7 @@ CONFIG_CRYPTO_CRCT10DIF=y
|
||||
# CONFIG_CRYPTO_SHA256_SSSE3 is not set
|
||||
# CONFIG_CRYPTO_SHA512_SSSE3 is not set
|
||||
# CONFIG_CRYPTO_SHA1_MB is not set
|
||||
# CONFIG_CRYPTO_SHA256 is not set
|
||||
CONFIG_CRYPTO_SHA256=y
|
||||
# CONFIG_CRYPTO_SHA512 is not set
|
||||
# CONFIG_CRYPTO_TGR192 is not set
|
||||
# CONFIG_CRYPTO_WP512 is not set
|
||||
@@ -1647,6 +1810,8 @@ CONFIG_CRYPTO_AES=y
|
||||
# CONFIG_CRYPTO_KHAZAD is not set
|
||||
# CONFIG_CRYPTO_SALSA20 is not set
|
||||
# CONFIG_CRYPTO_SALSA20_X86_64 is not set
|
||||
# CONFIG_CRYPTO_CHACHA20 is not set
|
||||
# CONFIG_CRYPTO_CHACHA20_X86_64 is not set
|
||||
# CONFIG_CRYPTO_SEED is not set
|
||||
# CONFIG_CRYPTO_SERPENT is not set
|
||||
# CONFIG_CRYPTO_SERPENT_SSE2_X86_64 is not set
|
||||
@@ -1664,6 +1829,7 @@ CONFIG_CRYPTO_AES=y
|
||||
# CONFIG_CRYPTO_DEFLATE is not set
|
||||
# CONFIG_CRYPTO_ZLIB is not set
|
||||
# CONFIG_CRYPTO_LZO is not set
|
||||
# CONFIG_CRYPTO_842 is not set
|
||||
# CONFIG_CRYPTO_LZ4 is not set
|
||||
# CONFIG_CRYPTO_LZ4HC is not set
|
||||
|
||||
@@ -1671,11 +1837,21 @@ CONFIG_CRYPTO_AES=y
|
||||
# Random Number Generation
|
||||
#
|
||||
# CONFIG_CRYPTO_ANSI_CPRNG is not set
|
||||
# CONFIG_CRYPTO_DRBG_MENU is not set
|
||||
CONFIG_CRYPTO_DRBG_MENU=y
|
||||
CONFIG_CRYPTO_DRBG_HMAC=y
|
||||
# CONFIG_CRYPTO_DRBG_HASH is not set
|
||||
# CONFIG_CRYPTO_DRBG_CTR is not set
|
||||
CONFIG_CRYPTO_DRBG=y
|
||||
CONFIG_CRYPTO_JITTERENTROPY=y
|
||||
# CONFIG_CRYPTO_USER_API_HASH is not set
|
||||
# CONFIG_CRYPTO_USER_API_SKCIPHER is not set
|
||||
# CONFIG_CRYPTO_USER_API_RNG is not set
|
||||
# CONFIG_CRYPTO_USER_API_AEAD is not set
|
||||
# CONFIG_CRYPTO_HW is not set
|
||||
|
||||
#
|
||||
# Certificates for signature checking
|
||||
#
|
||||
CONFIG_HAVE_KVM=y
|
||||
# CONFIG_VIRTUALIZATION is not set
|
||||
# CONFIG_BINARY_PRINTF is not set
|
||||
@@ -1685,6 +1861,7 @@ CONFIG_HAVE_KVM=y
|
||||
#
|
||||
CONFIG_BITREVERSE=y
|
||||
# CONFIG_HAVE_ARCH_BITREVERSE is not set
|
||||
CONFIG_RATIONAL=y
|
||||
CONFIG_GENERIC_STRNCPY_FROM_USER=y
|
||||
CONFIG_GENERIC_STRNLEN_USER=y
|
||||
CONFIG_GENERIC_NET_UTILS=y
|
||||
@@ -1720,7 +1897,9 @@ CONFIG_CPU_RMAP=y
|
||||
CONFIG_DQL=y
|
||||
CONFIG_NLATTR=y
|
||||
CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
|
||||
CONFIG_AVERAGE=y
|
||||
# CONFIG_CORDIC is not set
|
||||
# CONFIG_DDR is not set
|
||||
# CONFIG_SG_SPLIT is not set
|
||||
CONFIG_ARCH_HAS_SG_CHAIN=y
|
||||
CONFIG_ARCH_HAS_PMEM_API=y
|
||||
CONFIG_ARCH_HAS_MMIO_FLUSH=y
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
# v4.4
|
||||
afd2ff9b7e1b367172f18ba7f693dfb62bdcb2dc
|
||||
+46
-12
@@ -18,23 +18,57 @@ do
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if [ "$1"x = "vbox"x ]; then
|
||||
echo "build initrd for vbox"
|
||||
cp ./vbox/driver/* ./root
|
||||
fi
|
||||
|
||||
cd ./root && find . | cpio -H newc -o | gzip -9 > ../hyper-initrd.img
|
||||
|
||||
cd ../
|
||||
rm -rf ./root
|
||||
|
||||
if [ "$1" != "cbfs" ]; then
|
||||
if [ "$1"x = "cbfs"x ]; then
|
||||
echo "build cbfs"
|
||||
rm -rf .cbfs
|
||||
rm -rf cbfs.rom
|
||||
|
||||
mkdir .cbfs
|
||||
dd if=/dev/zero of=.cbfs/boot.bin bs=4096 count=1
|
||||
cbfstool .cbfs/cbfs.rom create -s 8128k -B .cbfs/boot.bin -m x86 0x1000
|
||||
cbfstool .cbfs/cbfs.rom add -f kernel -n vmlinuz -t raw
|
||||
cbfstool .cbfs/cbfs.rom add -f hyper-initrd.img -n initrd -t raw
|
||||
echo 'console=ttyS0 panic=1 no_timer_check' > .cbfs/cmdline
|
||||
cbfstool .cbfs/cbfs.rom add -f .cbfs/cmdline -n cmdline -t raw
|
||||
cp .cbfs/cbfs.rom ./
|
||||
rm -rf .cbfs
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd ../
|
||||
if [ "$1"x = "vbox"x ]; then
|
||||
mkdir tmp
|
||||
mkdir -p tmp/images
|
||||
mkdir -p tmp/kernel
|
||||
mkdir -p tmp/isolinux
|
||||
|
||||
echo "build cbfs"
|
||||
rm -rf .cbfs
|
||||
rm -rf cbfs.rom
|
||||
cd tmp
|
||||
cp ../vbox/kernel ./kernel/
|
||||
cp ../hyper-initrd.img ./images/initrd.img
|
||||
cp ../vbox/isolinux/isolinux.bin ./isolinux/
|
||||
cp ../vbox/isolinux/ldlinux.c32 ./isolinux/
|
||||
|
||||
mkdir .cbfs
|
||||
dd if=/dev/zero of=.cbfs/boot.bin bs=4096 count=1
|
||||
cbfstool .cbfs/cbfs.rom create -s 4096k -B .cbfs/boot.bin -m x86 0x1000
|
||||
cbfstool .cbfs/cbfs.rom add -f kernel -n vmlinuz -t raw
|
||||
cbfstool .cbfs/cbfs.rom add -f hyper-initrd.img -n initrd -t raw
|
||||
cp .cbfs/cbfs.rom ./
|
||||
rm -rf .cbfs
|
||||
cat > isolinux/syslinux.cfg <<EOF
|
||||
DEFAULT linux
|
||||
LABEL linux
|
||||
SAY Now booting the kernel from SYSLINUX...
|
||||
KERNEL /kernel/kernel
|
||||
APPEND initrd=/images/initrd.img
|
||||
EOF
|
||||
|
||||
cd ../
|
||||
|
||||
mkisofs -o hyper-vbox-boot.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table tmp
|
||||
|
||||
rm -fr tmp
|
||||
fi
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
+12
-10
@@ -2,9 +2,9 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([hyperstart], [0.1], [www.hyper.sh])
|
||||
AC_INIT([hyperstart], [0.5.0], [www.hyper.sh])
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
||||
AM_EXTRA_RECURSIVE_TARGETS([cbfs])
|
||||
AM_EXTRA_RECURSIVE_TARGETS([initrd cbfs])
|
||||
AC_CONFIG_SRCDIR([src/init.c])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
@@ -32,20 +32,22 @@ AC_TYPE_UINT8_T
|
||||
# Checks for library functions.
|
||||
AC_FUNC_FORK
|
||||
AC_CHECK_FUNCS([dup2 memmove memset mkdir setenv socket strchr strdup strrchr strtoul], [fail=0], [fail=1])
|
||||
AC_CHECK_FUNCS([setns])
|
||||
|
||||
if test "$fail" = "1" ; then
|
||||
AC_MSG_ERROR(Unable to find necessary functions)
|
||||
fi
|
||||
|
||||
AC_ARG_WITH([ttys],
|
||||
[AS_HELP_STRING([--with-ttys],
|
||||
[use pci serial device as container tty])],
|
||||
[],[with_ttys=yes])
|
||||
AC_ARG_WITH([vbox],
|
||||
[AS_HELP_STRING([--with-vbox],
|
||||
[run hyperstart on Virtualbox])],
|
||||
[],[with_vbox=no])
|
||||
|
||||
if test "x$with_ttys" != "xno" ; then
|
||||
AC_DEFINE_UNQUOTED([WITH_TTYS], 1, [where use pci serial device as container tty])
|
||||
if test "x$with_vbox" != "xno" ; then
|
||||
AC_DEFINE_UNQUOTED([WITH_VBOX], 1, [run hyperstart on Virtualbox])
|
||||
fi
|
||||
AM_CONDITIONAL([WITH_TTYS], [test "x$with_ttys" != "xno"])
|
||||
|
||||
AM_CONDITIONAL([WITH_VBOX], [test "x$with_vbox" != "xno"])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
@@ -58,7 +60,7 @@ AC_MSG_RESULT([
|
||||
${PACKAGE} ${VERSION}
|
||||
prefix: ${prefix}
|
||||
|
||||
with-ttys: ${with_ttys}
|
||||
with-vbox: ${with_vbox}
|
||||
|
||||
compiler: ${CC}
|
||||
cflags: ${CFLAGS}
|
||||
|
||||
+226
-137
@@ -16,20 +16,8 @@
|
||||
|
||||
#include "util.h"
|
||||
#include "hyper.h"
|
||||
|
||||
static int container_setup_env(struct hyper_container *container)
|
||||
{
|
||||
int i;
|
||||
struct env *env;
|
||||
|
||||
for (i = 0; i < container->envs_num; i++) {
|
||||
env = &container->envs[i];
|
||||
|
||||
setenv(env->env, env->value, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#include "parse.h"
|
||||
#include "syscall.h"
|
||||
|
||||
static int container_setup_volume(struct hyper_container *container)
|
||||
{
|
||||
@@ -40,29 +28,34 @@ static int container_setup_volume(struct hyper_container *container)
|
||||
for (i = 0; i < container->vols_num; i++) {
|
||||
vol = &container->vols[i];
|
||||
|
||||
if (vol->scsiaddr)
|
||||
hyper_find_sd("/.oldroot", vol->scsiaddr, &vol->device);
|
||||
|
||||
sprintf(dev, "/.oldroot/dev/%s", vol->device);
|
||||
sprintf(path, "/tmp/%s", vol->mountpoint);
|
||||
fprintf(stdout, "mount %s to %s\n", dev, vol->mountpoint);
|
||||
fprintf(stdout, "mount %s to %s, tmp path %s\n",
|
||||
dev, vol->mountpoint, path);
|
||||
|
||||
if (hyper_mkdir(path) < 0 || hyper_mkdir(vol->mountpoint) < 0) {
|
||||
fprintf(stdout, "mountpoint %s\n", vol->mountpoint);
|
||||
perror("create volume dir failed");
|
||||
continue;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mount(dev, path, vol->fstype, 0, NULL) < 0) {
|
||||
perror("mount volume device faled");
|
||||
continue;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mount(path, vol->mountpoint, NULL, MS_BIND, NULL) < 0) {
|
||||
perror("mount volume device faled");
|
||||
continue;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (vol->readonly &&
|
||||
mount(path, vol->mountpoint, NULL, MS_BIND | MS_REMOUNT | MS_RDONLY, NULL) < 0)
|
||||
mount(path, vol->mountpoint, NULL, MS_BIND | MS_REMOUNT | MS_RDONLY, NULL) < 0) {
|
||||
perror("mount fsmap faled");
|
||||
return -1;
|
||||
}
|
||||
|
||||
umount(path);
|
||||
}
|
||||
@@ -110,13 +103,27 @@ static int container_setup_mount(struct hyper_container *container)
|
||||
char src[512];
|
||||
struct fsmap *map;
|
||||
|
||||
if (mount("proc", "/proc", "proc", 0, NULL) < 0 ||
|
||||
mount("sysfs", "/sys", "sysfs", 0, NULL) < 0 ||
|
||||
mount("devtmpfs", "/dev", "devtmpfs", 0, NULL) < 0) {
|
||||
hyper_mkdir("/proc");
|
||||
hyper_mkdir("/sys");
|
||||
hyper_mkdir("/dev");
|
||||
|
||||
if (mount("proc", "/proc", "proc", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0 ||
|
||||
mount("sysfs", "/sys", "sysfs", MS_NOSUID| MS_NODEV| MS_NOEXEC, NULL) < 0 ||
|
||||
mount("devtmpfs", "/dev", "devtmpfs", MS_NOSUID, NULL) < 0) {
|
||||
perror("mount basic filesystem for container failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (hyper_mkdir("/dev/shm") < 0) {
|
||||
fprintf(stderr, "create /dev/shm failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mount("tmpfs", "/dev/shm/", "tmpfs", MS_NOSUID| MS_NODEV, NULL) < 0) {
|
||||
perror("mount shm failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (hyper_mkdir("/dev/pts") < 0) {
|
||||
fprintf(stderr, "create /dev/pts failed\n");
|
||||
return -1;
|
||||
@@ -175,6 +182,78 @@ static int container_setup_mount(struct hyper_container *container)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int container_setup_sysctl(struct hyper_container *container)
|
||||
{
|
||||
int i, size, len, l, fd;
|
||||
struct sysctl *sys;
|
||||
|
||||
for (i = 0; i < container->sys_num; i++) {
|
||||
char path[256];
|
||||
|
||||
len = 0;
|
||||
sys = &container->sys[i];
|
||||
size = strlen(sys->value);
|
||||
|
||||
sprintf(path, "/proc/sys/%s", sys->path);
|
||||
fprintf(stdout, "sysctl %s value %s\n", sys->path, sys->value);
|
||||
|
||||
fd = open(path, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror("open file failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (len < size) {
|
||||
l = write(fd, sys->value + len, size - len);
|
||||
if (l < 0) {
|
||||
perror("fail to write sysctl");
|
||||
close(fd);
|
||||
goto out;
|
||||
}
|
||||
len += l;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
out:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int container_setup_dns(struct hyper_container *container)
|
||||
{
|
||||
int fd;
|
||||
struct stat st;
|
||||
char *src = "/.oldroot/tmp/hyper/resolv.conf";
|
||||
|
||||
if (stat(src, &st) < 0) {
|
||||
if (errno == ENOENT) {
|
||||
fprintf(stdout, "no dns configured\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
perror("stat resolve.conf failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
hyper_mkdir("/etc");
|
||||
|
||||
fd = open("/etc/resolv.conf", O_CREAT| O_WRONLY, 0644);
|
||||
if (fd < 0) {
|
||||
perror("create /etc/resolv.conf failed");
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
if (mount(src, "/etc/resolv.conf", NULL, MS_BIND, NULL) < 0) {
|
||||
perror("bind to /etc/resolv.conf failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int container_setup_workdir(struct hyper_container *container)
|
||||
{
|
||||
if (container->workdir && chdir(container->workdir) < 0) {
|
||||
@@ -237,6 +316,8 @@ static int hyper_rescan_scsi(void)
|
||||
|
||||
struct hyper_container_arg {
|
||||
struct hyper_container *c;
|
||||
int ipcns;
|
||||
int utsns;
|
||||
int pipe[2];
|
||||
};
|
||||
|
||||
@@ -252,12 +333,22 @@ static int hyper_container_init(void *data)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (setns(arg->ipcns, CLONE_NEWIPC) < 0) {
|
||||
perror("setns to ipcns of pod init faild");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (setns(arg->utsns, CLONE_NEWUTS) < 0) {
|
||||
perror("setns to ipcns of pod init faild");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (hyper_rescan_scsi() < 0) {
|
||||
fprintf(stdout, "rescan scsi failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (container_setup_env(container) < 0) {
|
||||
if (hyper_setup_env(container->envs, container->envs_num) < 0) {
|
||||
fprintf(stdout, "setup env failed\n");
|
||||
goto fail;
|
||||
}
|
||||
@@ -283,6 +374,9 @@ static int hyper_container_init(void *data)
|
||||
if (container->fstype) {
|
||||
char dev[128];
|
||||
|
||||
if (container->scsiaddr)
|
||||
hyper_find_sd("", container->scsiaddr, &container->image);
|
||||
|
||||
sprintf(dev, "/dev/%s", container->image);
|
||||
fprintf(stdout, "device %s\n", dev);
|
||||
|
||||
@@ -305,7 +399,6 @@ static int hyper_container_init(void *data)
|
||||
fprintf(stdout, "root directory for container is %s/%s, init task %s\n",
|
||||
root, container->rootfs, container->exec.argv[0]);
|
||||
|
||||
hyper_list_dir(root);
|
||||
sprintf(oldroot, "%s/%s/.oldroot", root, container->rootfs);
|
||||
if (hyper_mkdir(oldroot) < 0) {
|
||||
perror("make oldroot directroy failed");
|
||||
@@ -330,7 +423,17 @@ static int hyper_container_init(void *data)
|
||||
}
|
||||
|
||||
if (container_setup_mount(container) < 0) {
|
||||
fprintf(stderr, "container sets up mount ns failed\n");
|
||||
fprintf(stderr, "container sets up mount failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (container_setup_sysctl(container) < 0) {
|
||||
fprintf(stderr, "container sets up sysctl failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (container_setup_dns(container) < 0) {
|
||||
fprintf(stderr, "container sets up dns failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -348,28 +451,60 @@ static int hyper_container_init(void *data)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
close(arg->pipe[0]);
|
||||
close(arg->pipe[1]);
|
||||
symlink("/proc/self/fd", "/dev/fd");
|
||||
symlink("/proc/self/fd/0", "/dev/stdin");
|
||||
symlink("/proc/self/fd/1", "/dev/stdout");
|
||||
symlink("/proc/self/fd/2", "/dev/stderr");
|
||||
|
||||
execvp(container->exec.argv[0], container->exec.argv);
|
||||
perror("exec container command failed");
|
||||
|
||||
_exit(-1);
|
||||
|
||||
fail:
|
||||
container->exec.code = -1;
|
||||
hyper_send_type_block(arg->pipe[1], ERROR, 0);
|
||||
hyper_send_type(arg->pipe[1], ERROR);
|
||||
_exit(-1);
|
||||
}
|
||||
|
||||
int hyper_start_container(struct hyper_container *container)
|
||||
static int hyper_setup_pty(struct hyper_container *c)
|
||||
{
|
||||
char root[512];
|
||||
|
||||
sprintf(root, "/tmp/hyper/%s/devpts/", c->id);
|
||||
|
||||
if (hyper_mkdir(root) < 0) {
|
||||
perror("make container pts directroy failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mount("devpts", root, "devpts", MS_NOSUID,
|
||||
"newinstance,ptmxmode=0666,mode=0620") < 0) {
|
||||
perror("mount devpts failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (hyper_setup_exec_tty(&c->exec) < 0) {
|
||||
fprintf(stderr, "setup container pts failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_start_container(struct hyper_container *container,
|
||||
int utsns, int ipcns, struct hyper_pod *pod)
|
||||
{
|
||||
int stacksize = getpagesize() * 4;
|
||||
void *stack = malloc(stacksize);
|
||||
struct hyper_container_arg arg = {
|
||||
.c = container,
|
||||
.c = container,
|
||||
.utsns = utsns,
|
||||
.ipcns = ipcns,
|
||||
.pipe = {-1, -1},
|
||||
};
|
||||
int flags = CLONE_NEWNS | SIGCHLD;
|
||||
char path[128];
|
||||
uint32_t type;
|
||||
void *stack;
|
||||
int pid;
|
||||
|
||||
if (container->image == NULL || container->exec.argv == NULL) {
|
||||
@@ -378,151 +513,105 @@ int hyper_start_container(struct hyper_container *container)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (socketpair(PF_UNIX, SOCK_STREAM, 0, arg.pipe) < 0) {
|
||||
if (hyper_setup_pty(container) < 0) {
|
||||
fprintf(stderr, "setup pty device for container failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (pipe2(arg.pipe, O_CLOEXEC) < 0) {
|
||||
perror("create pipe between pod init execcmd failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (hyper_watch_exec_pty(&container->exec, pod) < 0) {
|
||||
fprintf(stderr, "faile to watch container pty\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
stack = malloc(stacksize);
|
||||
if (stack == NULL) {
|
||||
perror("fail to allocate stack for container init");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pid = clone(hyper_container_init, stack + stacksize, flags, &arg);
|
||||
free(stack);
|
||||
if (pid < 0) {
|
||||
perror("create child process failed");
|
||||
goto fail;
|
||||
}
|
||||
sprintf(path, "/proc/%d/ns/mnt", pid);
|
||||
|
||||
container->exec.pid = pid;
|
||||
|
||||
/* wait for ready message */
|
||||
if (hyper_get_type_block(arg.pipe[0], &type) < 0 || type != READY) {
|
||||
fprintf(stdout, "wait for container started failed\n");
|
||||
container->ns = open(path, O_RDONLY | O_CLOEXEC);
|
||||
if (container->ns < 0) {
|
||||
perror("open container mount ns failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* wait for ready message */
|
||||
if (hyper_get_type(arg.pipe[0], &type) < 0 || type != READY) {
|
||||
fprintf(stderr, "wait for container started failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
container->exec.pid = pid;
|
||||
list_add_tail(&container->exec.list, &pod->exec_head);
|
||||
container->exec.ref++;
|
||||
|
||||
close(arg.pipe[0]);
|
||||
close(arg.pipe[1]);
|
||||
|
||||
fprintf(stdout, "container %s init pid is %d\n", container->id, pid);
|
||||
fprintf(stdout, "container %s,init pid %d,ref %d\n", container->id, pid, container->exec.ref);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
close(arg.pipe[0]);
|
||||
close(arg.pipe[1]);
|
||||
close(container->ns);
|
||||
hyper_reset_event(&container->exec.e);
|
||||
hyper_reset_event(&container->exec.errev);
|
||||
container->ns = -1;
|
||||
fprintf(stdout, "container %s init exit code %d\n", container->id, -1);
|
||||
container->exec.code = -1;
|
||||
container->exec.seq = 0;
|
||||
container->exec.ref = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int hyper_start_containers(struct hyper_pod *pod)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* mount new proc directory */
|
||||
if (umount("/proc") < 0) {
|
||||
perror("umount proc filesystem failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mount("proc", "/proc", "proc", 0, NULL) < 0) {
|
||||
perror("mount proc filesystem failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sethostname(pod->hostname, strlen(pod->hostname)) < 0) {
|
||||
perror("set host name failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < pod->c_num; i++)
|
||||
hyper_start_container(&pod->c[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_restart_containers(struct hyper_pod *pod)
|
||||
{
|
||||
int i;
|
||||
struct hyper_container *c;
|
||||
|
||||
for (i = 0; i < pod->c_num; i++) {
|
||||
c = &pod->c[i];
|
||||
|
||||
if (hyper_start_container(c) < 0) {
|
||||
fprintf(stderr, "restart container %s failed\n", c->id);
|
||||
hyper_send_type(pod->ctl.fd, ERROR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (hyper_send_type(pod->ctl.fd, ACK) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct hyper_container *hyper_find_container(struct hyper_pod *pod, char *id)
|
||||
{
|
||||
int i;
|
||||
struct hyper_container *container;
|
||||
struct hyper_container *c;
|
||||
|
||||
for (i = 0; i < pod->c_num; i++) {
|
||||
container = &pod->c[i];
|
||||
|
||||
if (strlen(container->id) != strlen(id))
|
||||
list_for_each_entry(c, &pod->containers, list) {
|
||||
if (strlen(c->id) != strlen(id))
|
||||
continue;
|
||||
|
||||
if (strncmp(container->id, id, strlen(id)))
|
||||
if (strncmp(c->id, id, strlen(id)))
|
||||
continue;
|
||||
|
||||
return container;
|
||||
return c;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void hyper_cleanup_container(struct hyper_pod *pod)
|
||||
void hyper_cleanup_container(struct hyper_container *c)
|
||||
{
|
||||
int i, j;
|
||||
struct hyper_container *c;
|
||||
struct volume *vol;
|
||||
struct env *env;
|
||||
struct fsmap *map;
|
||||
char root[512];
|
||||
|
||||
for (i = 0; i < pod->c_num; i++) {
|
||||
c = &pod->c[i];
|
||||
sprintf(root, "/tmp/hyper/%s/devpts/", c->id);
|
||||
if (umount(root) < 0 && umount2(root, MNT_DETACH))
|
||||
perror("umount devpts failed");
|
||||
|
||||
sprintf(root, "/tmp/hyper/%s/devpts/", c->id);
|
||||
if (umount(root) < 0 && umount2(root, MNT_DETACH))
|
||||
perror("umount devpts failed");
|
||||
close(c->ns);
|
||||
hyper_free_container(c);
|
||||
}
|
||||
|
||||
free(c->id);
|
||||
free(c->rootfs);
|
||||
free(c->image);
|
||||
free(c->workdir);
|
||||
free(c->fstype);
|
||||
void hyper_cleanup_containers(struct hyper_pod *pod)
|
||||
{
|
||||
struct hyper_container *c, *n;
|
||||
|
||||
for (j = 0; j < c->vols_num; j++) {
|
||||
vol = &(c->vols[j]);
|
||||
free(vol->device);
|
||||
free(vol->mountpoint);
|
||||
free(vol->fstype);
|
||||
}
|
||||
free(c->vols);
|
||||
list_for_each_entry_safe(c, n, &pod->containers, list)
|
||||
hyper_cleanup_container(c);
|
||||
|
||||
for (j = 0; j < c->envs_num; j++) {
|
||||
env = &(c->envs[j]);
|
||||
free(env->env);
|
||||
free(env->value);
|
||||
}
|
||||
free(c->envs);
|
||||
|
||||
for (j = 0; j < c->maps_num; j++) {
|
||||
map = &(c->maps[j]);
|
||||
free(map->source);
|
||||
free(map->path);
|
||||
}
|
||||
free(c->maps);
|
||||
}
|
||||
|
||||
free(pod->c);
|
||||
pod->c = NULL;
|
||||
pod->c_num = 0;
|
||||
pod->remains = 0;
|
||||
}
|
||||
|
||||
+16
-3
@@ -10,6 +10,7 @@ struct env {
|
||||
|
||||
struct volume {
|
||||
char *device;
|
||||
char *scsiaddr;
|
||||
char *mountpoint;
|
||||
char *fstype;
|
||||
int readonly;
|
||||
@@ -21,27 +22,39 @@ struct fsmap {
|
||||
int readonly;
|
||||
};
|
||||
|
||||
struct sysctl {
|
||||
char *path;
|
||||
char *value;
|
||||
};
|
||||
|
||||
struct hyper_container {
|
||||
char *id;
|
||||
char *rootfs;
|
||||
char *image;
|
||||
char *scsiaddr;
|
||||
char *workdir;
|
||||
char *fstype;
|
||||
struct volume *vols;
|
||||
struct env *envs;
|
||||
struct fsmap *maps;
|
||||
struct sysctl *sys;
|
||||
int vols_num;
|
||||
int envs_num;
|
||||
int maps_num;
|
||||
int sys_num;
|
||||
int ns;
|
||||
uint32_t code;
|
||||
struct list_head list;
|
||||
struct hyper_exec exec;
|
||||
};
|
||||
|
||||
struct hyper_pod;
|
||||
|
||||
int hyper_start_containers(struct hyper_pod *pod);
|
||||
int hyper_start_container(struct hyper_container *container,
|
||||
int utsns, int ipcns, struct hyper_pod *pod);
|
||||
struct hyper_container *hyper_find_container(struct hyper_pod *pod, char *id);
|
||||
int hyper_restart_containers(struct hyper_pod *pod);
|
||||
void hyper_cleanup_container(struct hyper_pod *pod);
|
||||
void hyper_cleanup_container(struct hyper_container *container);
|
||||
void hyper_cleanup_containers(struct hyper_pod *pod);
|
||||
void hyper_free_container(struct hyper_container *c);
|
||||
|
||||
#endif
|
||||
|
||||
+190
-22
@@ -5,33 +5,45 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "net.h"
|
||||
#include "util.h"
|
||||
#include "hyper.h"
|
||||
#include "event.h"
|
||||
|
||||
void hyper_reset_event(struct hyper_event *de)
|
||||
{
|
||||
free(de->buf.data);
|
||||
de->buf.data = NULL;
|
||||
free(de->rbuf.data);
|
||||
free(de->wbuf.data);
|
||||
close(de->fd);
|
||||
memset(de, 0, sizeof(*de));
|
||||
de->fd = -1;
|
||||
}
|
||||
|
||||
int hyper_init_event(struct hyper_event *de,
|
||||
struct hyper_event_ops *ops,
|
||||
uint32_t size, int to, void *arg)
|
||||
int hyper_init_event(struct hyper_event *de, struct hyper_event_ops *ops, void *arg)
|
||||
{
|
||||
struct hyper_buf *buf = &de->buf;
|
||||
struct hyper_buf *rbuf = &de->rbuf;
|
||||
struct hyper_buf *wbuf = &de->wbuf;
|
||||
|
||||
memset(buf, 0, sizeof(*buf));
|
||||
memset(rbuf, 0, sizeof(*rbuf));
|
||||
memset(wbuf, 0, sizeof(*wbuf));
|
||||
|
||||
de->ops = ops;
|
||||
de->ptr = arg;
|
||||
de->to = to;
|
||||
buf->size = size;
|
||||
rbuf->size = ops->rbuf_size;
|
||||
wbuf->size = ops->wbuf_size;
|
||||
|
||||
if (size) {
|
||||
buf->data = malloc(size);
|
||||
if (buf->data == NULL) {
|
||||
fprintf(stderr, "allocate data for event failed\n");
|
||||
if (rbuf->size) {
|
||||
rbuf->data = malloc(rbuf->size);
|
||||
if (rbuf->data == NULL) {
|
||||
fprintf(stderr, "allocate read buffer for event failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (wbuf->size) {
|
||||
wbuf->data = malloc(wbuf->size);
|
||||
if (wbuf->data == NULL) {
|
||||
fprintf(stderr, "allocate write buffer for event failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -39,13 +51,14 @@ int hyper_init_event(struct hyper_event *de,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_add_event(int efd, struct hyper_event *de)
|
||||
int hyper_add_event(int efd, struct hyper_event *de, int flag)
|
||||
{
|
||||
struct epoll_event event = {
|
||||
.events = EPOLLIN,
|
||||
.events = flag,
|
||||
.data.ptr = de,
|
||||
};
|
||||
|
||||
de->flag = flag;
|
||||
if (hyper_setfd_nonblock(de->fd) < 0) {
|
||||
perror("set fd nonblock failed");
|
||||
return -1;
|
||||
@@ -61,31 +74,186 @@ int hyper_add_event(int efd, struct hyper_event *de)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_modify_event(int efd, struct hyper_event *de, int flag)
|
||||
{
|
||||
struct epoll_event event = {
|
||||
.events = flag,
|
||||
.data.ptr = de,
|
||||
};
|
||||
|
||||
if (de->flag == flag)
|
||||
return 0;
|
||||
|
||||
de->flag = flag;
|
||||
fprintf(stdout, "%s modify event fd %d, %p, event %d\n",
|
||||
__func__, de->fd, de, flag);
|
||||
|
||||
if (epoll_ctl(efd, EPOLL_CTL_MOD, de->fd, &event) < 0) {
|
||||
perror("epoll_ctl fd failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hyper_getmsg_len(struct hyper_event *de, uint32_t *len)
|
||||
{
|
||||
struct hyper_buf *buf = &de->rbuf;
|
||||
|
||||
if (buf->get < de->ops->len_offset + 4)
|
||||
return -1;
|
||||
|
||||
*len = hyper_get_be32(buf->data + de->ops->len_offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_event_read(struct hyper_event *de)
|
||||
{
|
||||
struct hyper_buf *buf = &de->rbuf;
|
||||
uint32_t len = 4;
|
||||
uint8_t data[4];
|
||||
int offset = de->ops->len_offset;
|
||||
int end = offset + 4;
|
||||
int size;
|
||||
|
||||
fprintf(stdout, "%s\n", __func__);
|
||||
|
||||
while (hyper_getmsg_len(de, &len) < 0) {
|
||||
size = read(de->fd, buf->data + buf->get, end - buf->get);
|
||||
if (size > 0) {
|
||||
buf->get += size;
|
||||
fprintf(stdout, "already read %" PRIu32 " bytes data\n",
|
||||
buf->get);
|
||||
|
||||
if (de->ops->ack) {
|
||||
/* control channel, need ack */
|
||||
hyper_set_be32(data, size);
|
||||
hyper_send_msg(de->fd, NEXT, 4, data);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
||||
if (errno != EAGAIN && size != 0) {
|
||||
perror("fail to read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stdout, "get length %" PRIu32"\n", len);
|
||||
if (len > buf->size) {
|
||||
fprintf(stderr, "get length %" PRIu32", too long\n", len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (buf->get < len) {
|
||||
size = read(de->fd, buf->data + buf->get, len - buf->get);
|
||||
if (size > 0) {
|
||||
buf->get += size;
|
||||
fprintf(stdout, "read %d bytes data, total data %" PRIu32 "\n",
|
||||
size, buf->get);
|
||||
if (de->ops->ack) {
|
||||
/* control channel, need ack */
|
||||
hyper_set_be32(data, size);
|
||||
hyper_send_msg(de->fd, NEXT, 4, data);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
||||
if (errno != EAGAIN && size != 0) {
|
||||
perror("fail to read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* size == 0 : No one connect to qemu socket */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* get the whole data */
|
||||
if (de->ops->handle(de, len) != 0)
|
||||
return -1;
|
||||
|
||||
/* len: length of the already get new data */
|
||||
buf->get -= len;
|
||||
memmove(buf->data, buf->data + len, buf->get);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_event_write(struct hyper_event *de)
|
||||
{
|
||||
struct hyper_buf *buf = &de->wbuf;
|
||||
uint32_t len = 0;
|
||||
int size = 0;
|
||||
|
||||
while (len < buf->get) {
|
||||
size = write(de->fd, buf->data + len, buf->get - len);
|
||||
if (size <= 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
if (errno == EAGAIN || size == 0)
|
||||
break;
|
||||
return -1;
|
||||
}
|
||||
len += size;
|
||||
}
|
||||
|
||||
buf->get -= len;
|
||||
memmove(buf->data, buf->data + len, buf->get);
|
||||
|
||||
if (buf->get == 0) {
|
||||
hyper_modify_event(ctl.efd, de, EPOLLIN);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hyper_event_hup(struct hyper_event *de, int efd)
|
||||
{
|
||||
if (epoll_ctl(efd, EPOLL_CTL_DEL, de->fd, NULL) < 0)
|
||||
perror("epoll_ctl del epoll event failed");
|
||||
close(de->fd);
|
||||
hyper_reset_event(de);
|
||||
}
|
||||
|
||||
int hyper_handle_event(int efd, struct epoll_event *event)
|
||||
{
|
||||
struct hyper_event *de = event->data.ptr;
|
||||
fprintf(stdout, "%s get event %d, de %p, fd %d. ops %p\n",
|
||||
__func__, event->events, de, de->fd, de->ops);
|
||||
|
||||
if (event->events & EPOLLHUP) {
|
||||
/* do not handle hup event if have in event */
|
||||
if (event->events & EPOLLIN) {
|
||||
fprintf(stdout, "%s event EPOLLIN, de %p, fd %d, %p\n",
|
||||
__func__, de, de->fd, de->ops);
|
||||
if (de->ops->read(de) < 0)
|
||||
return -1;
|
||||
} else if (event->events & EPOLLHUP) {
|
||||
fprintf(stdout, "%s event EPOLLHUP, de %p, fd %d, %p\n",
|
||||
__func__, de, de->fd, de->ops);
|
||||
if (de->ops->hup)
|
||||
de->ops->hup(de, efd);
|
||||
return 0;
|
||||
} else if (event->events & EPOLLIN) {
|
||||
return de->ops->read(de);
|
||||
} else if (event->events & EPOLLERR) {
|
||||
}
|
||||
|
||||
if (event->events & EPOLLOUT) {
|
||||
fprintf(stdout, "%s event EPOLLOUT, de %p, fd %d, %p\n",
|
||||
__func__, de, de->fd, de->ops);
|
||||
if (de->ops->write && de->ops->write(de) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (event->events & EPOLLERR) {
|
||||
fprintf(stderr, "get epoll err of not epool in event\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(stdout, "%s get unknown event %d\n", __func__, event->events);
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
+13
-5
@@ -8,9 +8,13 @@ struct hyper_event;
|
||||
|
||||
struct hyper_event_ops {
|
||||
int (*read)(struct hyper_event *e);
|
||||
int (*getlen)(struct hyper_event *e, uint32_t *len);
|
||||
int (*write)(struct hyper_event *e);
|
||||
int (*handle)(struct hyper_event *e, uint32_t len);
|
||||
void (*hup)(struct hyper_event *e, int efd);
|
||||
int rbuf_size;
|
||||
int wbuf_size;
|
||||
int len_offset;
|
||||
int ack;
|
||||
};
|
||||
|
||||
struct hyper_buf {
|
||||
@@ -21,16 +25,20 @@ struct hyper_buf {
|
||||
|
||||
struct hyper_event {
|
||||
int fd;
|
||||
int to;
|
||||
struct hyper_buf buf;
|
||||
int flag;
|
||||
struct hyper_buf rbuf;
|
||||
struct hyper_buf wbuf;
|
||||
struct hyper_event_ops *ops;
|
||||
void *ptr;
|
||||
};
|
||||
|
||||
int hyper_add_event(int efd, struct hyper_event *de);
|
||||
int hyper_add_event(int efd, struct hyper_event *de, int flag);
|
||||
int hyper_modify_event(int efd, struct hyper_event *de, int flag);
|
||||
int hyper_init_event(struct hyper_event *de, struct hyper_event_ops *ops,
|
||||
uint32_t size, int to, void *arg);
|
||||
void *arg);
|
||||
int hyper_handle_event(int efd, struct epoll_event *event);
|
||||
void hyper_reset_event(struct hyper_event *de);
|
||||
void hyper_event_hup(struct hyper_event *de, int efd);
|
||||
int hyper_event_read(struct hyper_event *de);
|
||||
int hyper_event_write(struct hyper_event *de);
|
||||
#endif
|
||||
|
||||
+443
-302
@@ -9,49 +9,159 @@
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include "syscall.h"
|
||||
|
||||
#include "hyper.h"
|
||||
#include "util.h"
|
||||
#include "parse.h"
|
||||
#include "syscall.h"
|
||||
|
||||
static int pts_loop(struct hyper_event *de)
|
||||
static int send_exec_finishing(uint64_t seq, int len, int code, int block)
|
||||
{
|
||||
int size = 0;
|
||||
uint8_t buf[512];
|
||||
uint8_t seq[12];
|
||||
struct hyper_exec *exec = container_of(de, struct hyper_exec, e);
|
||||
struct hyper_buf *buf = &ctl.tty.wbuf;
|
||||
|
||||
fprintf(stdout, "%s\n", __func__);
|
||||
while (1) {
|
||||
size = read(de->fd, buf, sizeof(buf));
|
||||
if (size <= 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
if (errno == EAGAIN || errno == EIO)
|
||||
break;
|
||||
if (buf->get + len > buf->size) {
|
||||
uint8_t *data;
|
||||
fprintf(stdout, "%s: tty buf full\n", __func__);
|
||||
|
||||
perror("fail to read tty fd");
|
||||
data = realloc(buf->data, buf->size + len);
|
||||
if (data == NULL) {
|
||||
perror("realloc failed");
|
||||
return -1;
|
||||
}
|
||||
buf->data = data;
|
||||
buf->size += len;
|
||||
}
|
||||
|
||||
hyper_set_be64(seq, exec->seq);
|
||||
hyper_set_be32(seq + 8, size + 12);
|
||||
/* no in event, no more data, send eof */
|
||||
hyper_set_be64(buf->data + buf->get, seq);
|
||||
hyper_set_be32(buf->data + buf->get + 8, len);
|
||||
if (len > 12)
|
||||
buf->data[buf->get + 12] = code;
|
||||
|
||||
if (hyper_send_data(de->to, seq, 12) < 0)
|
||||
continue;
|
||||
buf->get += len;
|
||||
if (!block) {
|
||||
hyper_modify_event(ctl.efd, &ctl.tty, EPOLLIN | EPOLLOUT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
hyper_send_data(de->to, buf, size);
|
||||
if (hyper_setfd_block(ctl.tty.fd) < 0 ||
|
||||
hyper_send_data(ctl.tty.fd, buf->data, buf->get) < 0 ||
|
||||
hyper_setfd_nonblock(ctl.tty.fd) < 0) {
|
||||
fprintf(stderr, "send eof failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hyper_send_exec_eof(struct hyper_exec *exec, int block) {
|
||||
return send_exec_finishing(exec->seq, 12, -1, block);
|
||||
}
|
||||
|
||||
static int hyper_send_exec_code(struct hyper_exec *exec, int block) {
|
||||
return send_exec_finishing(exec->seq, 13, exec->code, block);
|
||||
}
|
||||
|
||||
static void pts_hup(struct hyper_event *de, int efd, int out)
|
||||
{
|
||||
struct hyper_exec *exec;
|
||||
struct hyper_pod *pod = de->ptr;
|
||||
uint64_t seq;
|
||||
|
||||
if (out) {
|
||||
exec = container_of(de, struct hyper_exec, e);
|
||||
seq = exec->seq;
|
||||
} else {
|
||||
exec = container_of(de, struct hyper_exec, errev);
|
||||
seq = exec->errseq;
|
||||
}
|
||||
|
||||
fprintf(stdout, "%s, seq %" PRIu64"\n", __func__, seq);
|
||||
|
||||
hyper_event_hup(de, efd);
|
||||
|
||||
hyper_send_exec_eof(exec, 0);
|
||||
|
||||
hyper_release_exec(exec, pod);
|
||||
}
|
||||
|
||||
static void stdout_hup(struct hyper_event *de, int efd)
|
||||
{
|
||||
fprintf(stdout, "%s\n", __func__);
|
||||
return pts_hup(de, efd, 1);
|
||||
}
|
||||
|
||||
static void stderr_hup(struct hyper_event *de, int efd)
|
||||
{
|
||||
fprintf(stdout, "%s\n", __func__);
|
||||
return pts_hup(de, efd, 0);
|
||||
}
|
||||
|
||||
static int pts_loop(struct hyper_event *de, uint64_t seq)
|
||||
{
|
||||
int size = -1;
|
||||
struct hyper_buf *buf = &ctl.tty.wbuf;
|
||||
|
||||
while ((buf->get + 12 < buf->size) && size) {
|
||||
size = read(de->fd, buf->data + buf->get + 12, buf->size - buf->get - 12);
|
||||
fprintf(stdout, "%s: read %d data\n", __func__, size);
|
||||
if (size <= 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
||||
if (errno != EAGAIN && errno != EIO) {
|
||||
perror("fail to read tty fd");
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
hyper_set_be64(buf->data + buf->get, seq);
|
||||
hyper_set_be32(buf->data + buf->get + 8, size + 12);
|
||||
buf->get += size + 12;
|
||||
}
|
||||
|
||||
if (hyper_modify_event(ctl.efd, &ctl.tty, EPOLLIN | EPOLLOUT) < 0) {
|
||||
fprintf(stderr, "modify ctl tty event to in & out failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stdout_loop(struct hyper_event *de)
|
||||
{
|
||||
struct hyper_exec *exec = container_of(de, struct hyper_exec, e);
|
||||
fprintf(stdout, "%s, seq %" PRIu64"\n", __func__, exec->seq);
|
||||
|
||||
return pts_loop(de, exec->seq);
|
||||
}
|
||||
|
||||
struct hyper_event_ops pts_ops = {
|
||||
.read = pts_loop,
|
||||
.hup = hyper_event_hup,
|
||||
.read = stdout_loop,
|
||||
.hup = stdout_hup,
|
||||
.write = hyper_event_write,
|
||||
.wbuf_size = 512,
|
||||
/* don't need read buff, the pts data will store in tty buffer */
|
||||
};
|
||||
|
||||
static int stderr_loop(struct hyper_event *de)
|
||||
{
|
||||
struct hyper_exec *exec = container_of(de, struct hyper_exec, errev);
|
||||
fprintf(stdout, "%s, seq %" PRIu64"\n", __func__, exec->errseq);
|
||||
|
||||
return pts_loop(de, exec->errseq);
|
||||
}
|
||||
|
||||
struct hyper_event_ops err_ops = {
|
||||
.read = stderr_loop,
|
||||
.hup = stderr_hup,
|
||||
/* don't need read buff, the stderr data will store in tty buffer */
|
||||
/* don't need write buff, the stderr data is one way */
|
||||
};
|
||||
|
||||
int hyper_setup_exec_tty(struct hyper_exec *e)
|
||||
@@ -62,6 +172,16 @@ int hyper_setup_exec_tty(struct hyper_exec *e)
|
||||
if (e->seq == 0)
|
||||
return 0;
|
||||
|
||||
if (e->errseq > 0) {
|
||||
int errpipe[2];
|
||||
if (pipe2(errpipe, O_NONBLOCK|O_CLOEXEC) < 0) {
|
||||
fprintf(stderr, "creating stderr pipe failed\n");
|
||||
return -1;
|
||||
}
|
||||
e->errev.fd = errpipe[0];
|
||||
e->errfd = errpipe[1];
|
||||
}
|
||||
|
||||
if (e->id) {
|
||||
if (sprintf(path, "/tmp/hyper/%s/devpts/", e->id) < 0) {
|
||||
fprintf(stderr, "get ptmx path failed\n");
|
||||
@@ -100,377 +220,412 @@ int hyper_setup_exec_tty(struct hyper_exec *e)
|
||||
return -1;
|
||||
}
|
||||
|
||||
e->pty = strdup(ptmx);
|
||||
fprintf(stdout, "get pty device for exec %s\n", e->pty);
|
||||
e->ptyfd = open(ptmx, O_RDWR | O_NOCTTY | O_CLOEXEC);
|
||||
fprintf(stdout, "get pty device for exec %s\n", ptmx);
|
||||
|
||||
fprintf(stdout, "%s pts event %p, fd %d %d\n",
|
||||
__func__, &e->e, e->e.fd, e->ptyfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_dup_exec_tty(int to, struct hyper_exec *e)
|
||||
{
|
||||
int fd;
|
||||
int fd = -1, ret = -1;
|
||||
char pty[128];
|
||||
|
||||
fprintf(stdout, "%s\n", __func__);
|
||||
setsid();
|
||||
|
||||
if (e->seq) {
|
||||
if (sprintf(pty, "/dev/pts/%d", e->ptyno) < 0) {
|
||||
perror("get pts device name failed");
|
||||
return -1;
|
||||
}
|
||||
fd = e->ptyfd;
|
||||
} else {
|
||||
if (sprintf(pty, "/dev/null") < 0) {
|
||||
perror("get pts device name failed");
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
fd = open(pty, O_RDWR | O_NOCTTY);
|
||||
}
|
||||
|
||||
fprintf(stdout, "setup pty device %s for exec\n", pty);
|
||||
|
||||
fd = open(pty, O_RDWR | O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
perror("open pty device for execcmd failed");
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (e->seq && (ioctl(fd, TIOCSCTTY, NULL) < 0)) {
|
||||
perror("ioctl pty device for execcmd failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (hyper_send_type_block(to, READY, 0) < 0) {
|
||||
fprintf(stderr, "send ready message to hyper init failed\n");
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
hyper_send_type(to, READY);
|
||||
|
||||
if (dup2(fd, STDIN_FILENO) < 0) {
|
||||
perror("dup tty device to stdin failed");
|
||||
close(fd);
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dup2(fd, STDOUT_FILENO) < 0) {
|
||||
perror("dup tty device to stdout failed");
|
||||
close(fd);
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dup2(fd, STDERR_FILENO) < 0) {
|
||||
perror("dup tty device to stderr failed");
|
||||
close(fd);
|
||||
return -1;
|
||||
if (e->errseq > 0) {
|
||||
if (dup2(e->errfd, STDERR_FILENO) < 0) {
|
||||
perror("dup err pipe to stderr failed");
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
if (dup2(fd, STDERR_FILENO) < 0) {
|
||||
perror("dup tty device to stderr failed");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
out:
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hyper_exec_in_container(struct hyper_pod *pod,
|
||||
struct hyper_exec *exec)
|
||||
int hyper_watch_exec_pty(struct hyper_exec *exec, struct hyper_pod *pod)
|
||||
{
|
||||
global_exec = exec;
|
||||
fprintf(stdout, "hyper_init_event container pts event %p, ops %p, fd %d\n",
|
||||
&exec->e, &pts_ops, exec->e.fd);
|
||||
|
||||
if (hyper_send_type_block(ctl.ctl.fd, EXECCMD, 1) < 0) {
|
||||
global_exec = NULL;
|
||||
fprintf(stderr, "tell pod init EXECCMD failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
list_add_tail(&exec->list, &pod->ce_head);
|
||||
if (exec->seq == 0)
|
||||
return 0;
|
||||
|
||||
fprintf(stdout, "init container exec pts event %p, ops %p, fd %d\n",
|
||||
&exec->e, &pts_ops, exec->e.fd);
|
||||
|
||||
if (hyper_init_event(&exec->e, &pts_ops, 0, ctl.tty.fd, NULL) < 0 ||
|
||||
hyper_add_event(ctl.efd, &exec->e) < 0) {
|
||||
fprintf(stderr, "add pts master event failed\n");
|
||||
if (hyper_init_event(&exec->e, &pts_ops, pod) < 0 ||
|
||||
hyper_add_event(ctl.efd, &exec->e, EPOLLIN) < 0) {
|
||||
fprintf(stderr, "add container pts master event failed\n");
|
||||
return -1;
|
||||
}
|
||||
exec->ref++;
|
||||
|
||||
if (exec->errseq == 0)
|
||||
return 0;
|
||||
|
||||
if (hyper_init_event(&exec->errev, &err_ops, pod) < 0 ||
|
||||
hyper_add_event(ctl.efd, &exec->errev, EPOLLIN) < 0) {
|
||||
fprintf(stderr, "add container stderr event failed\n");
|
||||
return -1;
|
||||
}
|
||||
exec->ref++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_request_restart_containers(struct hyper_pod *pod)
|
||||
int hyper_enter_container(struct hyper_pod *pod,
|
||||
struct hyper_exec *exec)
|
||||
{
|
||||
int i;
|
||||
struct hyper_exec *exec;
|
||||
int ipcns, utsns, mntns, ret;
|
||||
struct hyper_container *c;
|
||||
char path[512];
|
||||
|
||||
pod->code = 0;
|
||||
pod->remains = pod->c_num;
|
||||
ret = ipcns = utsns = mntns = -1;
|
||||
|
||||
for (i = 0; i < pod->c_num; i++) {
|
||||
exec = &pod->c[i].exec;
|
||||
|
||||
if (hyper_setup_exec_tty(exec) < 0) {
|
||||
fprintf(stdout, "restart setup container tty failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (hyper_send_type_block(ctl.ctl.fd, RESTARTCONTAINER, 1) < 0) {
|
||||
fprintf(stderr, "tell container init RESTARTCONTAINER failed\n");
|
||||
c = hyper_find_container(pod, exec->id);
|
||||
if (c == NULL) {
|
||||
fprintf(stderr, "can not find container %s\n", exec->id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < pod->c_num; i++) {
|
||||
exec = &pod->c[i].exec;
|
||||
|
||||
list_add_tail(&exec->list, &pod->ce_head);
|
||||
if (exec->seq == 0)
|
||||
continue;
|
||||
|
||||
if (hyper_init_event(&exec->e, &pts_ops, 0, ctl.tty.fd, NULL) < 0 ||
|
||||
hyper_add_event(ctl.efd, &exec->e) < 0) {
|
||||
fprintf(stderr, "add pts master event failed\n");
|
||||
return -1;
|
||||
}
|
||||
sprintf(path, "/proc/%d/ns/uts", pod->init_pid);
|
||||
utsns = open(path, O_RDONLY| O_CLOEXEC);
|
||||
if (utsns < 0) {
|
||||
perror("fail to open utsns of pod init");
|
||||
goto out;
|
||||
}
|
||||
|
||||
return 0;
|
||||
sprintf(path, "/proc/%d/ns/ipc", pod->init_pid);
|
||||
ipcns = open(path, O_RDONLY| O_CLOEXEC);
|
||||
if (ipcns < 0) {
|
||||
perror("fail to open ipcns of pod init");
|
||||
goto out;
|
||||
}
|
||||
|
||||
mntns = c->ns;
|
||||
if (mntns < 0) {
|
||||
perror("fail to open mntns of pod init");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (setns(utsns, CLONE_NEWUTS) < 0 ||
|
||||
setns(ipcns, CLONE_NEWIPC) <0 ||
|
||||
setns(mntns, CLONE_NEWNS) < 0) {
|
||||
perror("fail to enter container ns");
|
||||
goto out;
|
||||
}
|
||||
|
||||
sprintf(path, "/tmp/hyper/%s/root/%s/", c->id, c->rootfs);
|
||||
fprintf(stdout, "root directory for container is %s, exec %s\n",
|
||||
path, exec->argv[0]);
|
||||
|
||||
/* TODO: wait for container finishing setup root */
|
||||
if (chroot(path) < 0) {
|
||||
perror("chroot for exec command failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
chdir("/");
|
||||
|
||||
ret = hyper_setup_env(c->envs, c->envs_num);
|
||||
out:
|
||||
close(ipcns);
|
||||
close(utsns);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct hyper_exec_arg {
|
||||
struct hyper_pod *pod;
|
||||
struct hyper_exec *exec;
|
||||
int pipe[2];
|
||||
};
|
||||
|
||||
static int hyper_do_exec_cmd(void *data)
|
||||
{
|
||||
struct hyper_exec_arg *arg = data;
|
||||
struct hyper_exec *exec = arg->exec;
|
||||
struct hyper_pod *pod = arg->pod;
|
||||
int pipe[2] = {-1, -1}, pid;
|
||||
int ret = -1;
|
||||
|
||||
if (exec->id) {
|
||||
char path[512];
|
||||
int pidns;
|
||||
|
||||
sprintf(path, "/proc/%d/ns/pid", pod->init_pid);
|
||||
pidns = open(path, O_RDONLY| O_CLOEXEC);
|
||||
if (pidns < 0) {
|
||||
perror("fail to open pidns of pod init");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* enter pidns of pod init, so the children of this process will run in
|
||||
* pidns of pod init, see man 2 setns */
|
||||
if (setns(pidns, CLONE_NEWPID) < 0) {
|
||||
perror("enter pidns of pod init failed");
|
||||
goto out;
|
||||
}
|
||||
close(pidns);
|
||||
}
|
||||
|
||||
if (pipe2(pipe, O_CLOEXEC) < 0) {
|
||||
perror("create pipe in exec command failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (hyper_watch_exec_pty(exec, pod) < 0) {
|
||||
fprintf(stderr, "add pts master event failed\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
perror("fail to fork");
|
||||
goto out;
|
||||
} else if (pid > 0) {
|
||||
uint32_t type;
|
||||
|
||||
if (hyper_get_type(pipe[0], &type) < 0 || type != READY) {
|
||||
fprintf(stderr, "hyper init doesn't get execcmd ready message\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
fprintf(stdout, "hyper init get ready message\n");
|
||||
exec->pid = pid;
|
||||
//TODO combin ref++ and add to list.
|
||||
list_add_tail(&exec->list, &pod->exec_head);
|
||||
exec->ref++;
|
||||
fprintf(stdout, "create exec cmd %s pid %d,ref %d\n", exec->argv[0], pid, exec->ref);
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (exec->id && hyper_enter_container(pod, exec) < 0) {
|
||||
fprintf(stderr, "enter container ns failed\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (hyper_dup_exec_tty(pipe[1], exec) < 0) {
|
||||
fprintf(stderr, "dup pts to exec stdio failed\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (execvp(exec->argv[0], exec->argv) < 0) {
|
||||
perror("exec failed");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
exit:
|
||||
close(pipe[0]);
|
||||
close(pipe[1]);
|
||||
hyper_send_type(pipe[1], ERROR);
|
||||
_exit(ret);
|
||||
out:
|
||||
close(pipe[0]);
|
||||
close(pipe[1]);
|
||||
hyper_send_type(arg->pipe[1], ret ? ERROR : READY);
|
||||
_exit(ret);
|
||||
}
|
||||
|
||||
static void hyper_free_exec(struct hyper_exec *exec)
|
||||
{
|
||||
int i;
|
||||
|
||||
free(exec->id);
|
||||
|
||||
for (i = 0; i < exec->argc; i++) {
|
||||
//fprintf(stdout, "argv %d %s\n", i, exec->argv[i]);
|
||||
free(exec->argv[i]);
|
||||
}
|
||||
|
||||
free(exec->argv);
|
||||
free(exec);
|
||||
}
|
||||
|
||||
int hyper_exec_cmd(char *json, int length)
|
||||
{
|
||||
struct hyper_exec *exec;
|
||||
struct hyper_pod *pod = &global_pod;
|
||||
int pid, pipe[2];
|
||||
int stacksize = getpagesize() * 4;
|
||||
void *stack = NULL;
|
||||
struct hyper_exec_arg arg = {
|
||||
.pod = pod,
|
||||
.exec = NULL,
|
||||
.pipe = {-1, -1},
|
||||
};
|
||||
int pid, ret = -1;
|
||||
uint32_t type;
|
||||
|
||||
fprintf(stdout, "call hyper_exec_cmd, json %s, len %d\n", json, length);
|
||||
|
||||
exec = hyper_parse_execcmd(json, length);
|
||||
if (exec == NULL) {
|
||||
fprintf(stderr, "parse exec cmd failed\n");
|
||||
return -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (exec->argv == NULL) {
|
||||
fprintf(stderr, "cmd is %p, seq %" PRIu64 ", container %s\n",
|
||||
exec->argv, exec->seq, exec->id);
|
||||
return -1;
|
||||
goto free_exec;
|
||||
}
|
||||
|
||||
if (hyper_setup_exec_tty(exec) < 0) {
|
||||
fprintf(stderr, "setup exec tty failed\n");
|
||||
return -1;
|
||||
goto free_exec;
|
||||
}
|
||||
|
||||
if (exec->id) {
|
||||
if (hyper_exec_in_container(pod, exec) < 0) {
|
||||
fprintf(stderr, "notify container exec failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (socketpair(PF_UNIX, SOCK_STREAM, 0, pipe) < 0) {
|
||||
if (pipe2(arg.pipe, O_CLOEXEC) < 0) {
|
||||
perror("create pipe between pod init execcmd failed");
|
||||
return -1;
|
||||
goto close_tty;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
arg.exec = exec;
|
||||
|
||||
stack = malloc(stacksize);
|
||||
if (stack == NULL) {
|
||||
perror("fail to allocate stack for container init");
|
||||
goto close_tty;
|
||||
}
|
||||
|
||||
pid = clone(hyper_do_exec_cmd, stack + stacksize, CLONE_VM| CLONE_FILES| SIGCHLD, &arg);
|
||||
fprintf(stdout, "do_exec_cmd pid %d\n", pid);
|
||||
if (pid < 0) {
|
||||
fprintf(stderr, "fork failed\n");
|
||||
return -1;
|
||||
} else if (pid > 0) {
|
||||
uint32_t type;
|
||||
|
||||
if (hyper_get_type_block(pipe[0], &type) < 0 || type != READY) {
|
||||
fprintf(stderr, "hyper init doesn't get execcmd ready message\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(pipe[0]);
|
||||
close(pipe[1]);
|
||||
fprintf(stdout, "hyper init get ready message\n");
|
||||
exec->pid = pid;
|
||||
fprintf(stdout, "create exec cmd %s pid %d\n", exec->argv[0], pid);
|
||||
|
||||
list_add_tail(&exec->list, &pod->pe_head);
|
||||
if (exec->seq == 0)
|
||||
return 0;
|
||||
|
||||
fprintf(stdout, "init pod exec pts event %p, ops %p, fd %d\n",
|
||||
&exec->e, &pts_ops, exec->e.fd);
|
||||
if (hyper_init_event(&exec->e, &pts_ops, 0, ctl.tty.fd, NULL) < 0 ||
|
||||
hyper_add_event(ctl.efd, &exec->e) < 0) {
|
||||
fprintf(stderr, "add pts master event failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
perror("clone hyper_do_exec_cmd failed");
|
||||
goto close_tty;
|
||||
}
|
||||
|
||||
if (hyper_dup_exec_tty(pipe[1], exec) < 0) {
|
||||
fprintf(stderr, "dup pts to exec stdio failed\n");
|
||||
_exit(-1);
|
||||
if (hyper_get_type(arg.pipe[0], &type) < 0 || type != READY) {
|
||||
fprintf(stderr, "hyper init doesn't get execcmd ready message\n");
|
||||
goto close_tty;
|
||||
}
|
||||
|
||||
close(pipe[0]);
|
||||
close(pipe[1]);
|
||||
|
||||
if (execvp(exec->argv[0], exec->argv) < 0) {
|
||||
perror("exec failed");
|
||||
_exit(-1);
|
||||
}
|
||||
|
||||
_exit(0);
|
||||
fprintf(stdout, "%s get ready message %"PRIu32 "\n", __func__, type);
|
||||
ret = 0;
|
||||
out:
|
||||
close(arg.pipe[0]);
|
||||
close(arg.pipe[1]);
|
||||
free(stack);
|
||||
return ret;
|
||||
close_tty:
|
||||
close(exec->ptyfd);
|
||||
close(exec->errfd);
|
||||
close(exec->e.fd);
|
||||
free_exec:
|
||||
hyper_free_exec(exec);
|
||||
goto out;
|
||||
}
|
||||
|
||||
int hyper_container_execcmd(struct hyper_pod *pod)
|
||||
static int hyper_send_pod_finished(struct hyper_pod *pod)
|
||||
{
|
||||
struct hyper_exec *exec = global_exec;
|
||||
struct hyper_container *container = NULL;
|
||||
int fd, pid, sock = pod->ctl.fd;
|
||||
char root[512]; int pipe[2];
|
||||
int ret = -1;
|
||||
struct hyper_container *c;
|
||||
uint8_t *data = NULL, *new;
|
||||
int c_num = 0;
|
||||
|
||||
global_exec = NULL;
|
||||
list_for_each_entry(c, &pod->containers, list) {
|
||||
c_num++;
|
||||
new = realloc(data, c_num * 4);
|
||||
if (new == NULL)
|
||||
goto out;
|
||||
|
||||
container = hyper_find_container(pod, exec->id);
|
||||
if (container == NULL) {
|
||||
fprintf(stderr, "can not find container %s\n", exec->id);
|
||||
return -1;
|
||||
hyper_set_be32(new + ((c_num - 1) * 4), c->exec.code);
|
||||
data = new;
|
||||
}
|
||||
|
||||
if (sprintf(root, "/tmp/hyper/%s/devpts/", exec->id) < 0) {
|
||||
fprintf(stderr, "get container %s pts path failed\n", exec->id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (socketpair(PF_UNIX, SOCK_STREAM, 0, pipe) < 0) {
|
||||
perror("create pipe between pod init execcmd failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
fprintf(stderr, "container init fork failed\n");
|
||||
return -1;
|
||||
} else if (pid > 0) {
|
||||
uint32_t type;
|
||||
|
||||
if (hyper_get_type_block(pipe[0], &type) < 0 || type != READY) {
|
||||
fprintf(stderr, "pod init get execcmd ready message failed\n");
|
||||
hyper_send_type_block(sock, ERROR, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
close(pipe[0]);
|
||||
close(pipe[1]);
|
||||
fprintf(stdout, "pod init get ready message\n");
|
||||
|
||||
exec->pid = pid;
|
||||
fprintf(stdout, "create exec cmd %s pid %d\n", exec->argv[0], pid);
|
||||
|
||||
if (hyper_send_type_block(sock, ACK, 0) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
close(pipe[0]);
|
||||
sprintf(root, "/proc/%d/ns/mnt", container->exec.pid);
|
||||
|
||||
fprintf(stdout, "container %s, init pid %d\n",
|
||||
exec->id, container->exec.pid);
|
||||
|
||||
fd = open(root, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
perror("fail to open container mnt ns\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (syscall(SYS_setns, fd, CLONE_NEWNS) < 0) {
|
||||
perror("enter mnt ns failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
sprintf(root, "/tmp/hyper/%s/root/%s/",
|
||||
container->id, container->rootfs);
|
||||
|
||||
fprintf(stdout, "root directory for container is %s, exec %s\n",
|
||||
root, exec->argv[0]);
|
||||
|
||||
/* TODO: wait for container finishing setup root */
|
||||
if (chroot(root) < 0) {
|
||||
perror("chroot for exec command failed");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
chdir("/");
|
||||
|
||||
if (hyper_dup_exec_tty(pipe[1], exec)) {
|
||||
fprintf(stderr, "dup pts to stdio failed\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
close(pipe[1]);
|
||||
if (execvp(exec->argv[0], exec->argv) < 0)
|
||||
perror("exec failed");
|
||||
|
||||
_exit(-1);
|
||||
fail:
|
||||
hyper_send_type_block(pipe[1], ERROR, 0);
|
||||
_exit(-1);
|
||||
ret = hyper_send_msg_block(ctl.chan.fd, PODFINISHED, c_num * 4, data);
|
||||
out:
|
||||
free(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hyper_release_exec(struct hyper_exec *exec,
|
||||
struct hyper_pod *pod)
|
||||
{
|
||||
int i;
|
||||
if (--exec->ref != 0) {
|
||||
fprintf(stdout, "still have %d user of exec\n", exec->ref);
|
||||
return 0;
|
||||
}
|
||||
|
||||
close(exec->e.fd);
|
||||
free(exec->pty);
|
||||
/* exec has no pty or the pty user already exited */
|
||||
fprintf(stdout, "last user of exec exit, release\n");
|
||||
|
||||
hyper_reset_event(&exec->e);
|
||||
hyper_reset_event(&exec->errev);
|
||||
|
||||
list_del_init(&exec->list);
|
||||
|
||||
hyper_send_exec_code(exec, 0);
|
||||
|
||||
fprintf(stdout, "%s exit code %" PRIu8"\n", __func__, exec->code);
|
||||
if (exec->init) {
|
||||
fprintf(stdout, "%s container init exited, type %d, remains %d, policy %d\n",
|
||||
__func__, pod->type, pod->remains, pod->policy);
|
||||
|
||||
/* stop pod, should not restart container */
|
||||
if (pod->type == STOPPOD)
|
||||
return 0;
|
||||
|
||||
if (exec->code)
|
||||
pod->code = exec->code;
|
||||
|
||||
// TODO send finish of this container and full cleanup
|
||||
if (--pod->remains > 0)
|
||||
return 0;
|
||||
|
||||
/* should shutdown? */
|
||||
if (pod->policy == POLICY_NEVER ||
|
||||
((pod->policy == POLICY_ONFAILURE) && pod->code == 0)) {
|
||||
hyper_shutdown(pod);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hyper_request_restart_containers(pod) < 0) {
|
||||
fprintf(stderr, "restart container failed\n");
|
||||
return -1;
|
||||
if (pod->type == STOPPOD) {
|
||||
/* stop pod manually, hyper doesn't care the pod finished codes */
|
||||
hyper_send_msg_block(ctl.chan.fd, ACK, 0, NULL);
|
||||
} else if (pod->type == DESTROYPOD) {
|
||||
/* shutdown vm manually, hyper doesn't care the pod finished codes */
|
||||
hyper_shutdown();
|
||||
} else {
|
||||
/* send out pod finish message, hyper will decide if restart pod or not */
|
||||
hyper_send_pod_finished(pod);
|
||||
}
|
||||
|
||||
hyper_cleanup_pod(pod);
|
||||
return 0;
|
||||
}
|
||||
|
||||
free(exec->id);
|
||||
|
||||
for (i = 0; i < exec->argc; i++) {
|
||||
fprintf(stdout, "argv %d %s\n", i, exec->argv[i]);
|
||||
free(exec->argv[i]);
|
||||
}
|
||||
|
||||
free(exec->argv);
|
||||
free(exec);
|
||||
|
||||
hyper_free_exec(exec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -493,17 +648,8 @@ struct hyper_exec *hyper_find_exec_by_seq(struct hyper_pod *pod, uint64_t seq)
|
||||
{
|
||||
struct hyper_exec *exec;
|
||||
|
||||
list_for_each_entry(exec, &pod->ce_head, list) {
|
||||
fprintf(stdout, "container exec seq %" PRIu64 ", seq %" PRIu64 "\n",
|
||||
exec->seq, seq);
|
||||
if (exec->seq != seq)
|
||||
continue;
|
||||
|
||||
return exec;
|
||||
}
|
||||
|
||||
list_for_each_entry(exec, &pod->pe_head, list) {
|
||||
fprintf(stdout, "pod exec seq %" PRIu64 ", seq %" PRIu64 "\n",
|
||||
list_for_each_entry(exec, &pod->exec_head, list) {
|
||||
fprintf(stdout, "exec seq %" PRIu64 ", seq %" PRIu64 "\n",
|
||||
exec->seq, seq);
|
||||
if (exec->seq != seq)
|
||||
continue;
|
||||
@@ -514,35 +660,28 @@ struct hyper_exec *hyper_find_exec_by_seq(struct hyper_pod *pod, uint64_t seq)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int hyper_send_exec_eof(int to, struct hyper_pod *pod,
|
||||
struct list_head *head, int pid,
|
||||
uint8_t code)
|
||||
int hyper_handle_exec_exit(struct hyper_pod *pod, int pid, uint8_t code)
|
||||
{
|
||||
struct hyper_exec *exec;
|
||||
uint8_t seq[12];
|
||||
|
||||
exec = hyper_find_exec_by_pid(head, pid);
|
||||
exec = hyper_find_exec_by_pid(&pod->exec_head, pid);
|
||||
if (exec == NULL) {
|
||||
fprintf(stdout, "can not find exec whose pid is %d\n",
|
||||
pid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stdout, "%s exec pid %d, seq %" PRIu64 ", container %s\n",
|
||||
fprintf(stdout, "%s exec exit pid %d, seq %" PRIu64 ", container %s\n",
|
||||
__func__, exec->pid, exec->seq, exec->id ? exec->id : "pod");
|
||||
|
||||
exec->code = code;
|
||||
exec->exit = 1;
|
||||
|
||||
if (exec->seq == 0)
|
||||
goto out;
|
||||
close(exec->ptyfd);
|
||||
exec->ptyfd = -1;
|
||||
close(exec->errfd);
|
||||
exec->errfd = -1;
|
||||
|
||||
hyper_set_be64(seq, exec->seq);
|
||||
hyper_set_be32(seq + 8, 12);
|
||||
if (hyper_send_data(to, seq, 12) < 0) {
|
||||
fprintf(stderr, "pod signal_loop send finishcmd failed\n");
|
||||
return -1;
|
||||
}
|
||||
out:
|
||||
hyper_release_exec(exec, pod);
|
||||
|
||||
return 0;
|
||||
@@ -552,8 +691,10 @@ void hyper_cleanup_exec(struct hyper_pod *pod)
|
||||
{
|
||||
struct hyper_exec *exec, *next;
|
||||
|
||||
list_for_each_entry_safe(exec, next, &pod->ce_head, list) {
|
||||
fprintf(stdout, "cleanup container exec seq %" PRIu64 "\n", exec->seq);
|
||||
hyper_release_exec(exec, pod);
|
||||
list_for_each_entry_safe(exec, next, &pod->exec_head, list) {
|
||||
fprintf(stdout, "send eof for exec seq %" PRIu64 "\n", exec->seq);
|
||||
if (hyper_send_exec_eof(exec, 1) < 0 ||
|
||||
hyper_send_exec_code(exec, 1) < 0)
|
||||
fprintf(stderr, "send eof failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
+8
-4
@@ -7,15 +7,20 @@
|
||||
struct hyper_exec {
|
||||
struct list_head list;
|
||||
struct hyper_event e;
|
||||
struct hyper_event errev;
|
||||
char *id;
|
||||
char *pty;
|
||||
char **argv;
|
||||
int argc;
|
||||
uint64_t seq;
|
||||
uint64_t errseq;
|
||||
int pid;
|
||||
int ptyno;
|
||||
int init;
|
||||
int ptyfd;
|
||||
int errfd;
|
||||
uint8_t code;
|
||||
uint8_t exit;
|
||||
uint8_t ref;
|
||||
};
|
||||
|
||||
struct hyper_pod;
|
||||
@@ -27,9 +32,8 @@ int hyper_setup_exec_tty(struct hyper_exec *e);
|
||||
int hyper_dup_exec_tty(int fd, struct hyper_exec *e);
|
||||
struct hyper_exec *hyper_find_exec_by_pid(struct list_head *head, int pid);
|
||||
struct hyper_exec *hyper_find_exec_by_seq(struct hyper_pod *pod, uint64_t seq);
|
||||
int hyper_send_exec_eof(int to, struct hyper_pod *pod,
|
||||
struct list_head *head, int pid,
|
||||
uint8_t code);
|
||||
int hyper_handle_exec_exit(struct hyper_pod *pod, int pid, uint8_t code);
|
||||
int hyper_watch_exec_pty(struct hyper_exec *exec, struct hyper_pod *pod);
|
||||
void hyper_cleanup_exec(struct hyper_pod *pod);
|
||||
|
||||
extern struct hyper_event_ops pts_ops;
|
||||
|
||||
+35
-13
@@ -1,5 +1,5 @@
|
||||
#ifndef _DVM_H_
|
||||
#define _DVM_H_
|
||||
#ifndef _HYPER_H_
|
||||
#define _HYPER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -10,20 +10,25 @@
|
||||
#include "container.h"
|
||||
|
||||
enum {
|
||||
SETDVM,
|
||||
RESERVED,
|
||||
STARTPOD,
|
||||
GETPOD,
|
||||
STOPPOD,
|
||||
DESTROYPOD,
|
||||
RESTARTCONTAINER,
|
||||
EXECCMD,
|
||||
FINISHCMD,
|
||||
CMDFINISHED,
|
||||
READY,
|
||||
ACK,
|
||||
ERROR,
|
||||
WINSIZE,
|
||||
PING,
|
||||
FINISH,
|
||||
PODFINISHED,
|
||||
NEXT,
|
||||
WRITEFILE,
|
||||
READFILE,
|
||||
NEWCONTAINER,
|
||||
KILLCONTAINER,
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -36,23 +41,22 @@ struct hyper_pod {
|
||||
struct hyper_container *c;
|
||||
struct hyper_interface *iface;
|
||||
struct hyper_route *rt;
|
||||
struct list_head pe_head;
|
||||
struct list_head ce_head;
|
||||
char **dns;
|
||||
struct list_head containers;
|
||||
struct list_head exec_head;
|
||||
char *hostname;
|
||||
char *tag;
|
||||
char *channel;
|
||||
char *share_tag;
|
||||
int init_pid;
|
||||
uint32_t c_num;
|
||||
uint32_t i_num;
|
||||
uint32_t r_num;
|
||||
uint32_t e_num;
|
||||
uint32_t d_num;
|
||||
uint32_t type;
|
||||
uint32_t code;
|
||||
/* how many containers are running */
|
||||
uint32_t remains;
|
||||
uint8_t policy;
|
||||
int efd;
|
||||
struct hyper_event sig;
|
||||
struct hyper_event ctl;
|
||||
};
|
||||
|
||||
struct hyper_win_size {
|
||||
@@ -62,17 +66,35 @@ struct hyper_win_size {
|
||||
uint64_t seq;
|
||||
};
|
||||
|
||||
struct hyper_killer {
|
||||
char *id;
|
||||
int signal;
|
||||
};
|
||||
|
||||
struct hyper_reader {
|
||||
char *id;
|
||||
char *file;
|
||||
};
|
||||
|
||||
struct hyper_writter {
|
||||
char *id;
|
||||
char *file;
|
||||
uint8_t *data;
|
||||
int len;
|
||||
};
|
||||
|
||||
struct hyper_ctl {
|
||||
int efd;
|
||||
struct hyper_event sig;
|
||||
struct hyper_event tty;
|
||||
struct hyper_event chan;
|
||||
struct hyper_event ctl;
|
||||
};
|
||||
|
||||
int hyper_mkdir(char *hyper_path);
|
||||
int hyper_open_serial(char *tty);
|
||||
struct hyper_container *hyper_find_container(struct hyper_pod *pod, char *id);
|
||||
int hyper_start_containers(struct hyper_pod *pod);
|
||||
void hyper_cleanup_pod(struct hyper_pod *pod);
|
||||
|
||||
extern struct hyper_pod global_pod;
|
||||
extern struct hyper_ctl ctl;
|
||||
|
||||
+777
-415
File diff suppressed because it is too large
Load Diff
+11
-4
@@ -164,14 +164,18 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
|
||||
int i;
|
||||
jsmntok_t *token;
|
||||
int count = 0;
|
||||
int num = 0;
|
||||
int out = 0;
|
||||
|
||||
for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
|
||||
for (; parser->pos < len && js[parser->pos] != '\0' && !out; parser->pos++) {
|
||||
char c;
|
||||
jsmntype_t type;
|
||||
|
||||
c = js[parser->pos];
|
||||
switch (c) {
|
||||
case '{': case '[':
|
||||
case '{':
|
||||
num++;
|
||||
case '[':
|
||||
count++;
|
||||
if (tokens == NULL)
|
||||
break;
|
||||
@@ -189,7 +193,10 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
|
||||
token->start = parser->pos;
|
||||
parser->toksuper = parser->toknext - 1;
|
||||
break;
|
||||
case '}': case ']':
|
||||
case '}':
|
||||
if (--num <= 0)
|
||||
out = 1;
|
||||
case ']':
|
||||
if (tokens == NULL)
|
||||
break;
|
||||
type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
|
||||
@@ -221,7 +228,7 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
|
||||
|
||||
parser->toksuper = -1;
|
||||
token->end = parser->pos + 1;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Error if unmatched closing bracket */
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include "hyper.h"
|
||||
#include "util.h"
|
||||
#include "../config.h"
|
||||
|
||||
void hyper_set_be32(uint8_t *buf, uint32_t val)
|
||||
{
|
||||
@@ -55,7 +58,9 @@ int hyper_send_data(int fd, uint8_t *data, uint32_t len)
|
||||
perror("send hyper data failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if WITH_VBOX
|
||||
tcdrain(fd);
|
||||
#endif
|
||||
length += size;
|
||||
}
|
||||
|
||||
@@ -86,7 +91,7 @@ int hyper_send_type(int fd, uint32_t type)
|
||||
return hyper_send_msg(fd, type, 0, NULL);
|
||||
}
|
||||
|
||||
int hyper_get_type_block(int fd, uint32_t *type)
|
||||
int hyper_get_type(int fd, uint32_t *type)
|
||||
{
|
||||
int len = 0, size;
|
||||
uint8_t buf[8];
|
||||
@@ -107,42 +112,20 @@ int hyper_get_type_block(int fd, uint32_t *type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_send_type_block(int fd, uint32_t type, int need_ack)
|
||||
int hyper_send_msg_block(int fd, uint32_t type, uint32_t len, uint8_t *data)
|
||||
{
|
||||
int ret = 0, flags;
|
||||
uint32_t t;
|
||||
int ret, flags;
|
||||
|
||||
flags = fcntl(fd, F_GETFL, 0);
|
||||
flags = hyper_setfd_block(fd);
|
||||
if (flags < 0) {
|
||||
fprintf(stderr, "get fd flag failed\n");
|
||||
fprintf(stderr, "%s fail to set fd block\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) < 0) {
|
||||
perror("set fd BLOCK failed");
|
||||
return -1;
|
||||
}
|
||||
ret = hyper_send_msg(fd, type, len, data);
|
||||
|
||||
ret = hyper_send_msg(fd, type, 0, NULL);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
if (need_ack == 0)
|
||||
goto out;
|
||||
|
||||
ret = hyper_get_type_block(fd, &t);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "can not get type\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
fprintf(stdout, "get type %" PRIu32"\n", type);
|
||||
|
||||
if (t != ACK)
|
||||
ret = -1;
|
||||
out:
|
||||
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
|
||||
perror("set fd BLOCK failed");
|
||||
if (fcntl(fd, F_SETFL, flags) < 0) {
|
||||
perror("restore fd flag failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -303,14 +286,17 @@ static int hyper_remove_nic(char *device)
|
||||
{
|
||||
char path[256], real[128];
|
||||
int fd;
|
||||
ssize_t size;
|
||||
|
||||
sprintf(path, "/sys/class/net/%s", device);
|
||||
|
||||
if (readlink(path, real, 128) < 0) {
|
||||
size = readlink(path, real, 128);
|
||||
if (size < 0 || size > 127) {
|
||||
perror("fail to read link directory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
real[size] = '\0';
|
||||
sprintf(path, "/sys/%s/../../../remove", real + 5);
|
||||
|
||||
fprintf(stdout, "get net sys path %s\n", path);
|
||||
@@ -672,6 +658,11 @@ static int hyper_cleanup_interface(struct rtnl_handle *rth,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Don't down&remove lo device */
|
||||
if (strcmp(iface->device, "lo") == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hyper_down_nic(rth, iface->ifindex) < 0) {
|
||||
fprintf(stderr, "up device %d failed\n", iface->ifindex);
|
||||
return -1;
|
||||
@@ -791,3 +782,64 @@ void hyper_cleanup_network(struct hyper_pod *pod)
|
||||
pod->i_num = 0;
|
||||
netlink_close(&rth);
|
||||
}
|
||||
|
||||
int hyper_setup_dns(struct hyper_pod *pod)
|
||||
{
|
||||
int i, fd, ret = -1;
|
||||
char buf[28];
|
||||
|
||||
if (pod->dns == NULL)
|
||||
return 0;
|
||||
|
||||
fd = open("/tmp/hyper/resolv.conf", O_CREAT| O_TRUNC| O_WRONLY, 0644);
|
||||
|
||||
if (fd < 0) {
|
||||
perror("create /tmp/resolv.conf failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < pod->d_num; i++) {
|
||||
int size = snprintf(buf, sizeof(buf), "nameserver %s\n", pod->dns[i]);
|
||||
int len = 0, l;
|
||||
|
||||
if (size < 0) {
|
||||
fprintf(stderr, "sprintf resolv.conf entry failed\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (len < size) {
|
||||
l = write(fd, buf + len, size - len);
|
||||
if (l < 0) {
|
||||
perror("fail to write resolv.conf");
|
||||
goto out;
|
||||
}
|
||||
len += l;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
out:
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void hyper_cleanup_dns(struct hyper_pod *pod)
|
||||
{
|
||||
int fd, i;
|
||||
|
||||
for (i = 0; i < pod->d_num; i++) {
|
||||
free(pod->dns[i]);
|
||||
}
|
||||
|
||||
free(pod->dns);
|
||||
pod->dns = NULL;
|
||||
pod->d_num = 0;
|
||||
|
||||
fd = open("/tmp/hyper/resolv.conf", O_WRONLY| O_TRUNC);
|
||||
if (fd < 0) {
|
||||
perror("open /tmp/hyper/resolv.conf failed");
|
||||
return;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
@@ -48,10 +48,12 @@ void hyper_set_be64(uint8_t *buf, uint64_t val);
|
||||
uint64_t hyper_get_be64(uint8_t *buf);
|
||||
int hyper_setup_network(struct hyper_pod *pod);
|
||||
void hyper_cleanup_network(struct hyper_pod *pod);
|
||||
int hyper_get_type_block(int fd, uint32_t *type);
|
||||
int hyper_setup_dns(struct hyper_pod *pod);
|
||||
void hyper_cleanup_dns(struct hyper_pod *pod);
|
||||
int hyper_get_type(int fd, uint32_t *type);
|
||||
int hyper_send_type(int fd, uint32_t type);
|
||||
int hyper_send_type_block(int fd, uint32_t type, int need_ack);
|
||||
int hyper_send_msg(int fd, uint32_t type, uint32_t len,
|
||||
uint8_t *message);
|
||||
int hyper_send_msg(int fd, uint32_t type, uint32_t len, uint8_t *data);
|
||||
int hyper_send_msg_block(int fd, uint32_t type, uint32_t len, uint8_t *data);
|
||||
int hyper_send_data(int fd, uint8_t *data, uint32_t len);
|
||||
#endif
|
||||
|
||||
+746
-133
File diff suppressed because it is too large
Load Diff
+7
-2
@@ -1,5 +1,5 @@
|
||||
#ifndef _DVM_JSON_H_
|
||||
#define _DVM_JSON_H_
|
||||
#ifndef _PARSE_H_
|
||||
#define _PARSE_H_
|
||||
|
||||
#include "hyper.h"
|
||||
#include "jsmn.h"
|
||||
@@ -9,5 +9,10 @@ struct hyper_exec *hyper_parse_execcmd(char *json, int length);
|
||||
char *json_token_str(char *js, jsmntok_t *t);
|
||||
int json_token_streq(char *js, jsmntok_t *t, char *s);
|
||||
int hyper_parse_winsize(struct hyper_win_size *ws, char *json, int length);
|
||||
int hyper_parse_kill_container(struct hyper_killer *killer, char *json, int length);
|
||||
int hyper_parse_write_file(struct hyper_writter *writter, char *json, int length);
|
||||
int hyper_parse_read_file(struct hyper_reader *reader, char *json, int length);
|
||||
struct hyper_container *hyper_parse_new_container(struct hyper_pod *pod, char *json, int length);
|
||||
void hyper_free_container(struct hyper_container *c);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
/*
|
||||
* Use raw syscall for versions of glibc that don't include it. But this
|
||||
* requires kernel-headers for syscall number hint.
|
||||
*/
|
||||
|
||||
#if !defined(HAVE_SETNS) && defined(__NR_setns)
|
||||
static inline int setns(int fd, int nstype)
|
||||
{
|
||||
errno = syscall(__NR_setns, fd, nstype);
|
||||
return errno == 0 ? 0 : -1;
|
||||
}
|
||||
#endif
|
||||
+249
-75
@@ -11,17 +11,36 @@
|
||||
#include <ctype.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <linux/reboot.h>
|
||||
|
||||
#include "net.h"
|
||||
#include "util.h"
|
||||
#include "hyper.h"
|
||||
#include "container.h"
|
||||
#include "../config.h"
|
||||
|
||||
char *read_cmdline(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int hyper_setup_env(struct env *envs, int num)
|
||||
{
|
||||
int i, ret = 0;
|
||||
struct env *env;
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
env = &envs[i];
|
||||
if (setenv(env->env, env->value, 1) < 0) {
|
||||
perror("fail to setup env");
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hyper_list_dir(char *path)
|
||||
{
|
||||
struct dirent **list;
|
||||
@@ -38,12 +57,47 @@ int hyper_list_dir(char *path)
|
||||
for (i = 0; i < num; i++) {
|
||||
dir = list[i];
|
||||
fprintf(stdout, "%s get %s\n", path, dir->d_name);
|
||||
free(dir);
|
||||
}
|
||||
|
||||
free(list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_find_sd(char *prefix, char *addr, char **dev) {
|
||||
struct dirent **list;
|
||||
struct dirent *dir;
|
||||
char path[512];
|
||||
int i, num;
|
||||
|
||||
sprintf(path, "%s/sys/class/scsi_disk/0:0:%s/device/block/", prefix, addr);
|
||||
fprintf(stdout, "orig dev %s, scan path %s\n", *dev, path);
|
||||
|
||||
num = scandir(path, &list, NULL, NULL);
|
||||
if (num < 0) {
|
||||
perror("scan path failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
dir = list[i];
|
||||
if (dir->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(stdout, "%s get %s\n", path, dir->d_name);
|
||||
free(*dev);
|
||||
*dev = strdup(dir->d_name);
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
free(list[i]);
|
||||
|
||||
free(list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hyper_mkdir(char *hyper_path)
|
||||
{
|
||||
struct stat st;
|
||||
@@ -86,6 +140,173 @@ int hyper_mkdir(char *hyper_path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void online_cpu(void)
|
||||
{
|
||||
DIR *dir = opendir("/sys/devices/system/cpu");
|
||||
if (dir == NULL) {
|
||||
fprintf(stderr, "open dir /sys/devices/system/cpu failed\n");
|
||||
return;
|
||||
}
|
||||
printf("online_cpu()\n");
|
||||
for (;;) {
|
||||
int num;
|
||||
int ret;
|
||||
char path[256];
|
||||
int fd;
|
||||
|
||||
struct dirent *entry = readdir(dir);
|
||||
if (entry == NULL)
|
||||
break;
|
||||
if (entry->d_type != DT_DIR)
|
||||
continue;
|
||||
ret = sscanf(entry->d_name, "cpu%d", &num);
|
||||
if (ret < 1 || num == 0) /* skip none cpu%d and cpu0 */
|
||||
continue;
|
||||
sprintf(path, "/sys/devices/system/cpu/%s/online", entry->d_name);
|
||||
fd = open(path, O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "open %s failed\n", path);
|
||||
continue;
|
||||
}
|
||||
printf("try to online %s\n", entry->d_name);
|
||||
ret = write(fd, "1", sizeof("1"));
|
||||
printf("online %s result: %s\n", entry->d_name, ret == 2 ? "success" : "failed");
|
||||
close(fd);
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
void online_memory(void)
|
||||
{
|
||||
DIR *dir = opendir("/sys/devices/system/memory");
|
||||
if (dir == NULL) {
|
||||
fprintf(stderr, "open dir /sys/devices/system/memory failed\n");
|
||||
return;
|
||||
}
|
||||
printf("online_memory()\n");
|
||||
for (;;) {
|
||||
int num;
|
||||
int ret;
|
||||
char path[256];
|
||||
int fd;
|
||||
|
||||
struct dirent *entry = readdir(dir);
|
||||
if (entry == NULL)
|
||||
break;
|
||||
if (entry->d_type != DT_DIR)
|
||||
continue;
|
||||
ret = sscanf(entry->d_name, "memory%d", &num);
|
||||
if (ret < 1 || num == 0) /* skip none memory%d and memory0 */
|
||||
continue;
|
||||
sprintf(path, "/sys/devices/system/memory/%s/online", entry->d_name);
|
||||
fd = open(path, O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "open %s failed\n", path);
|
||||
continue;
|
||||
}
|
||||
printf("try to online %s\n", entry->d_name);
|
||||
ret = write(fd, "1", sizeof("1"));
|
||||
printf("online %s result: %s\n", entry->d_name, ret == 2 ? "success" : "failed");
|
||||
close(fd);
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
#if WITH_VBOX
|
||||
|
||||
#include <termios.h>
|
||||
int hyper_open_channel(char *channel, int mode)
|
||||
{
|
||||
struct termios term;
|
||||
int fd = open(channel, O_RDWR | O_CLOEXEC | mode);
|
||||
fprintf(stdout, "open %s get %d\n", channel, fd);
|
||||
|
||||
if (fd < 0) {
|
||||
perror("fail to open channel device");
|
||||
return -1;
|
||||
}
|
||||
|
||||
bzero(&term, sizeof(term));
|
||||
|
||||
cfmakeraw(&term);
|
||||
term.c_cflag |= CLOCAL | CREAD| CRTSCTS;
|
||||
term.c_cc[VTIME] = 0;
|
||||
term.c_cc[VMIN] = 0;
|
||||
|
||||
cfsetispeed(&term, B115200);
|
||||
cfsetospeed(&term, B115200);
|
||||
|
||||
tcsetattr(fd, TCSANOW, &term);
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
static const char *moderror(int err)
|
||||
{
|
||||
switch (err) {
|
||||
case ENOEXEC:
|
||||
return "Invalid module format";
|
||||
case ENOENT:
|
||||
return "Unknown symbol in module";
|
||||
case ESRCH:
|
||||
return "Module has wrong symbol version";
|
||||
case EINVAL:
|
||||
return "Invalid parameters";
|
||||
default:
|
||||
return strerror(err);
|
||||
}
|
||||
}
|
||||
|
||||
extern long init_module (void *, unsigned long, const char *);
|
||||
|
||||
int hyper_insmod(char *module)
|
||||
{
|
||||
size_t size, offset = 0, rc;
|
||||
struct stat st;
|
||||
char *buf = NULL;
|
||||
int ret;
|
||||
|
||||
int fd = open(module, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
fprintf (stderr, "insmod: open: %s: %m\n", module);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fstat(fd, &st) == -1) {
|
||||
perror ("insmod: fstat");
|
||||
goto err;
|
||||
}
|
||||
|
||||
size = st.st_size;
|
||||
buf = malloc(size);
|
||||
if (buf == NULL)
|
||||
goto err;
|
||||
|
||||
do {
|
||||
rc = read(fd, buf + offset, size - offset);
|
||||
if (rc == -1) {
|
||||
perror ("insmod: read");
|
||||
goto err;
|
||||
}
|
||||
offset += rc;
|
||||
} while (offset < size);
|
||||
|
||||
if (init_module(buf, size, "") != 0) {
|
||||
fprintf (stderr, "insmod: init_module: %s: %s\n", module, moderror(errno));
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
out:
|
||||
close(fd);
|
||||
free(buf);
|
||||
|
||||
return ret;
|
||||
err:
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
#else
|
||||
int hyper_open_channel(char *channel, int mode)
|
||||
{
|
||||
struct dirent **list;
|
||||
@@ -133,7 +354,7 @@ int hyper_open_channel(char *channel, int mode)
|
||||
fprintf(stdout, "open hyper channel %s\n", path);
|
||||
fd = open(path, O_RDWR | O_CLOEXEC | mode);
|
||||
if (fd < 0)
|
||||
perror("fail to open channel deice");
|
||||
perror("fail to open channel device");
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -142,34 +363,22 @@ int hyper_open_channel(char *channel, int mode)
|
||||
return fd;
|
||||
}
|
||||
|
||||
int hyper_insmod(char *module)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int hyper_open_serial_dev(char *tty)
|
||||
{
|
||||
int fd = open(tty, O_RDWR | O_CLOEXEC | O_NOCTTY);
|
||||
|
||||
if (fd < 0) {
|
||||
if (fd < 0)
|
||||
perror("fail to open tty device");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int hyper_open_serial(char *tty)
|
||||
{
|
||||
char path[256];
|
||||
|
||||
memset(path, 0, sizeof(path));
|
||||
|
||||
if (snprintf(path, sizeof(path), "/dev/%s", tty) < 0) {
|
||||
fprintf(stderr, "get channel device %s path failed\n", tty);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(stdout, "open hyper tty %s\n", path);
|
||||
|
||||
return hyper_open_serial_dev(path);
|
||||
}
|
||||
|
||||
int hyper_setfd_cloexec(int fd)
|
||||
{
|
||||
int flags = fcntl(fd, F_GETFD);
|
||||
@@ -201,7 +410,7 @@ int hyper_setfd_block(int fd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return flags;
|
||||
}
|
||||
|
||||
int hyper_setfd_nonblock(int fd)
|
||||
@@ -218,10 +427,25 @@ int hyper_setfd_nonblock(int fd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
int hyper_socketpair(int domain, int type, int protocol, int sv[2])
|
||||
{
|
||||
if (socketpair(domain, type, protocol, sv) < 0) {
|
||||
perror("socketpair failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (hyper_setfd_cloexec(sv[0]) < 0 ||
|
||||
hyper_setfd_cloexec(sv[1]) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hyper_unmount_all(void)
|
||||
static void hyper_unmount_all(void)
|
||||
{
|
||||
FILE *mtab;
|
||||
struct mntent *mnt;
|
||||
@@ -266,59 +490,9 @@ void hyper_unmount_all(void)
|
||||
sync();
|
||||
}
|
||||
|
||||
void hyper_kill_all(void)
|
||||
void hyper_shutdown()
|
||||
{
|
||||
int npids = 0;
|
||||
int index = 0;
|
||||
int pid;
|
||||
DIR *dp;
|
||||
struct dirent *de;
|
||||
pid_t *pids = NULL;
|
||||
|
||||
dp = opendir("/proc");
|
||||
if (dp == NULL)
|
||||
return;
|
||||
|
||||
while ((de = readdir(dp)) && de != NULL) {
|
||||
if (!isdigit(de->d_name[0]))
|
||||
continue;
|
||||
pid = atoi(de->d_name);
|
||||
if (pid == 1)
|
||||
continue;
|
||||
if (index <= npids) {
|
||||
pids = realloc(pids, npids + 16384);
|
||||
if (pids == NULL)
|
||||
return;
|
||||
npids += 16384;
|
||||
}
|
||||
|
||||
pids[index++] = pid;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Sending SIGTERM\n");
|
||||
|
||||
for (--index; index >= 0; --index) {
|
||||
fprintf(stdout, "kill process %d\n", pids[index]);
|
||||
kill(pids[index], SIGTERM);
|
||||
}
|
||||
|
||||
free(pids);
|
||||
closedir(dp);
|
||||
}
|
||||
|
||||
void hyper_shutdown(struct hyper_pod *pod)
|
||||
{
|
||||
int i;
|
||||
uint8_t *data = calloc(pod->c_num, 4);
|
||||
|
||||
for (i = 0; i < pod->c_num; i++)
|
||||
hyper_set_be32(data + (i * 4), pod->c[i].exec.code);
|
||||
|
||||
hyper_send_msg(ctl.chan.fd, FINISH, pod->c_num * 4, data);
|
||||
|
||||
hyper_kill_all();
|
||||
|
||||
hyper_send_msg_block(ctl.chan.fd, ACK, 0, NULL);
|
||||
hyper_unmount_all();
|
||||
|
||||
reboot(LINUX_REBOOT_CMD_POWER_OFF);
|
||||
}
|
||||
|
||||
+19
-5
@@ -1,18 +1,32 @@
|
||||
#ifndef _UTIL_H_
|
||||
#define _UTIL_H_
|
||||
|
||||
#include "hyper.h"
|
||||
#include <stdio.h>
|
||||
#include "../config.h"
|
||||
|
||||
struct hyper_pod;
|
||||
struct env;
|
||||
|
||||
#ifdef WITH_DEBUG
|
||||
#define dprintf(fmt, ...) \
|
||||
fprintf(stdout, fmt, ##_VA_ARGS__)
|
||||
#else
|
||||
#define dprintf(fmr, ...)
|
||||
#endif
|
||||
|
||||
char *read_cmdline(void);
|
||||
int hyper_setup_env(struct env *envs, int num);
|
||||
int hyper_find_sd(char *prefix, char *addr, char **dev);
|
||||
int hyper_list_dir(char *path);
|
||||
void online_cpu(void);
|
||||
void online_memory(void);
|
||||
int hyper_mkdir(char *path);
|
||||
int hyper_open_channel(char *channel, int mode);
|
||||
int hyper_open_serial_dev(char *tty);
|
||||
int hyper_open_serial(char *tty);
|
||||
int hyper_setfd_cloexec(int fd);
|
||||
int hyper_setfd_block(int fd);
|
||||
int hyper_setfd_nonblock(int fd);
|
||||
void hyper_shutdown(struct hyper_pod *pod);
|
||||
void hyper_kill_all(void);
|
||||
void hyper_unmount_all(void);
|
||||
int hyper_socketpair(int domain, int type, int protocol, int sv[2]);
|
||||
void hyper_shutdown(void);
|
||||
int hyper_insmod(char *module);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user