Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker-containerd is a daemon and API for controlling and managing runC containers. https://containerd.tools/ Signed-off-by: Christian Stewart <christian@paral.in> --- Changes since v3: - Don't depend on runc at compile-time - Add threading dependency - Use HOST_GO_TARGET_ENV, partially - Cleanup compile commands - Include patch to fix arm64 compilation Changes since v4: - Bump to v0.2.2 - update hash for 0.2.2 - fix docker-runc simlink - use CONTAINERD_VERSION for GitCommit const - add go arch supports to config.in comment - did runtime tests - added signed-off-by to the patch series Changes since v6: - containerd-shim aliased to docker-containerd-shim ---
- Loading branch information
Showing
5 changed files
with
250 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
From f6f54370d154b0ce5f35319d878048d7db8db89c Mon Sep 17 00:00:00 2001 | ||
From: Lei Jitang <leijitang@huawei.com> | ||
Date: Tue, 5 Apr 2016 23:17:30 -0400 | ||
Subject: [PATCH] arm64 fixes | ||
|
||
This commit is a combination of a few cherry-picked commits from the | ||
current master (0.3.0 candidate) of docker-containerd, which | ||
specifically address issues under arm64. | ||
|
||
move epoll syscall to arch specific to enable containerd run on arm64 | ||
Rename epoll_amd64.go to epoll.go | ||
Signed-off-by: Lei Jitang <leijitang@huawei.com> | ||
|
||
archutils: epoll_aarch64: fix C formatting | ||
Signed-off-by: Aleksa Sarai <asarai@suse.de> | ||
|
||
archutils: fix build on aarch64 | ||
Signed-off-by: Aleksa Sarai <asarai@suse.de> | ||
|
||
Use flag for aarch64 EpollCreate1 | ||
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com> | ||
|
||
Correct build flag for arm64 | ||
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com> | ||
|
||
Series signature: | ||
|
||
Signed-off-by: Christian Stewart <christian@paral.in> | ||
|
||
--- | ||
archutils/epoll.go | 19 ++++++++++++ | ||
archutils/epoll_arm64.go | 70 +++++++++++++++++++++++++++++++++++++++++++++ | ||
supervisor/monitor_linux.go | 9 +++--- | ||
3 files changed, 94 insertions(+), 4 deletions(-) | ||
create mode 100644 archutils/epoll.go | ||
create mode 100644 archutils/epoll_arm64.go | ||
|
||
diff --git a/archutils/epoll.go b/archutils/epoll.go | ||
new file mode 100644 | ||
index 0000000..c8ade64 | ||
--- /dev/null | ||
+++ b/archutils/epoll.go | ||
@@ -0,0 +1,19 @@ | ||
+// +build linux,!arm64 | ||
+ | ||
+package archutils | ||
+ | ||
+import ( | ||
+ "syscall" | ||
+) | ||
+ | ||
+func EpollCreate1(flag int) (int, error) { | ||
+ return syscall.EpollCreate1(flag) | ||
+} | ||
+ | ||
+func EpollCtl(epfd int, op int, fd int, event *syscall.EpollEvent) error { | ||
+ return syscall.EpollCtl(epfd, op, fd, event) | ||
+} | ||
+ | ||
+func EpollWait(epfd int, events []syscall.EpollEvent, msec int) (int, error) { | ||
+ return syscall.EpollWait(epfd, events, msec) | ||
+} | ||
diff --git a/archutils/epoll_arm64.go b/archutils/epoll_arm64.go | ||
new file mode 100644 | ||
index 0000000..00abc68 | ||
--- /dev/null | ||
+++ b/archutils/epoll_arm64.go | ||
@@ -0,0 +1,70 @@ | ||
+// +build linux,arm64 | ||
+ | ||
+package archutils | ||
+ | ||
+// #include <sys/epoll.h> | ||
+/* | ||
+int EpollCreate1(int flag) { | ||
+ return epoll_create1(flag); | ||
+} | ||
+ | ||
+int EpollCtl(int efd, int op,int sfd, int events, int fd) { | ||
+ struct epoll_event event; | ||
+ event.events = events; | ||
+ event.data.fd = fd; | ||
+ | ||
+ return epoll_ctl(efd, op, sfd, &event); | ||
+} | ||
+ | ||
+struct event_t { | ||
+ uint32_t events; | ||
+ int fd; | ||
+}; | ||
+ | ||
+struct epoll_event events[128]; | ||
+int run_epoll_wait(int fd, struct event_t *event) { | ||
+ int n, i; | ||
+ n = epoll_wait(fd, events, 128, -1); | ||
+ for (i = 0; i < n; i++) { | ||
+ event[i].events = events[i].events; | ||
+ event[i].fd = events[i].data.fd; | ||
+ } | ||
+ return n; | ||
+} | ||
+*/ | ||
+import "C" | ||
+ | ||
+import ( | ||
+ "fmt" | ||
+ "syscall" | ||
+ "unsafe" | ||
+) | ||
+ | ||
+func EpollCreate1(flag int) (int, error) { | ||
+ fd := int(C.EpollCreate1(C.int(flag))) | ||
+ if fd < 0 { | ||
+ return fd, fmt.Errorf("failed to create epoll, errno is %d", fd) | ||
+ } | ||
+ return fd, nil | ||
+} | ||
+ | ||
+func EpollCtl(epfd int, op int, fd int, event *syscall.EpollEvent) error { | ||
+ errno := C.EpollCtl(C.int(epfd), C.int(syscall.EPOLL_CTL_ADD), C.int(fd), C.int(event.Events), C.int(event.Fd)) | ||
+ if errno < 0 { | ||
+ return fmt.Errorf("Failed to ctl epoll") | ||
+ } | ||
+ return nil | ||
+} | ||
+ | ||
+func EpollWait(epfd int, events []syscall.EpollEvent, msec int) (int, error) { | ||
+ var c_events [128]C.struct_event_t | ||
+ n := int(C.run_epoll_wait(C.int(epfd), (*C.struct_event_t)(unsafe.Pointer(&c_events)))) | ||
+ if n < 0 { | ||
+ return int(n), fmt.Errorf("Failed to wait epoll") | ||
+ } | ||
+ for i := 0; i < n; i++ { | ||
+ events[i].Fd = int32(c_events[i].fd) | ||
+ events[i].Events = uint32(c_events[i].events) | ||
+ } | ||
+ return int(n), nil | ||
+} | ||
diff --git a/supervisor/monitor_linux.go b/supervisor/monitor_linux.go | ||
index adf4ffd..b176585 100644 | ||
--- a/supervisor/monitor_linux.go | ||
+++ b/supervisor/monitor_linux.go | ||
@@ -5,6 +5,7 @@ import ( | ||
"syscall" | ||
|
||
"github.com/Sirupsen/logrus" | ||
+ "github.com/docker/containerd/archutils" | ||
"github.com/docker/containerd/runtime" | ||
) | ||
|
||
@@ -14,7 +15,7 @@ func NewMonitor() (*Monitor, error) { | ||
exits: make(chan runtime.Process, 1024), | ||
ooms: make(chan string, 1024), | ||
} | ||
- fd, err := syscall.EpollCreate1(0) | ||
+ fd, err := archutils.EpollCreate1(0) | ||
if err != nil { | ||
return nil, err | ||
} | ||
@@ -47,7 +48,7 @@ func (m *Monitor) Monitor(p runtime.Process) error { | ||
Fd: int32(fd), | ||
Events: syscall.EPOLLHUP, | ||
} | ||
- if err := syscall.EpollCtl(m.epollFd, syscall.EPOLL_CTL_ADD, fd, &event); err != nil { | ||
+ if err := archutils.EpollCtl(m.epollFd, syscall.EPOLL_CTL_ADD, fd, &event); err != nil { | ||
return err | ||
} | ||
EpollFdCounter.Inc(1) | ||
@@ -67,7 +68,7 @@ func (m *Monitor) MonitorOOM(c runtime.Container) error { | ||
Fd: int32(fd), | ||
Events: syscall.EPOLLHUP | syscall.EPOLLIN, | ||
} | ||
- if err := syscall.EpollCtl(m.epollFd, syscall.EPOLL_CTL_ADD, fd, &event); err != nil { | ||
+ if err := archutils.EpollCtl(m.epollFd, syscall.EPOLL_CTL_ADD, fd, &event); err != nil { | ||
return err | ||
} | ||
EpollFdCounter.Inc(1) | ||
@@ -82,7 +83,7 @@ func (m *Monitor) Close() error { | ||
func (m *Monitor) start() { | ||
var events [128]syscall.EpollEvent | ||
for { | ||
- n, err := syscall.EpollWait(m.epollFd, events[:], -1) | ||
+ n, err := archutils.EpollWait(m.epollFd, events[:], -1) | ||
if err != nil { | ||
if err == syscall.EINTR { | ||
continue | ||
-- | ||
2.7.3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
config BR2_PACKAGE_DOCKER_CONTAINERD | ||
bool "docker-containerd" | ||
depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS | ||
depends on BR2_TOOLCHAIN_HAS_THREADS | ||
select BR2_PACKAGE_RUNC | ||
help | ||
containerd is a daemon to control runC. | ||
|
||
https://github.com/docker/containerd | ||
|
||
comment "docker-containerd needs a toolchain w/ threads" | ||
depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS | ||
depends on !BR2_TOOLCHAIN_HAS_THREADS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Computed locally | ||
sha256 a21efc7ea4bb97306ae9807caadca6782358679f38d3afd606cb599b6853bc52 docker-containerd-v0.2.2.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
################################################################################ | ||
# | ||
# docker-containerd | ||
# | ||
################################################################################ | ||
|
||
DOCKER_CONTAINERD_VERSION = v0.2.2 | ||
DOCKER_CONTAINERD_SITE = $(call github,docker,containerd,$(DOCKER_CONTAINERD_VERSION)) | ||
|
||
DOCKER_CONTAINERD_LICENSE = Apache-2.0 | ||
DOCKER_CONTAINERD_LICENSE_FILES = LICENSE.code | ||
|
||
DOCKER_CONTAINERD_DEPENDENCIES = host-go | ||
|
||
DOCKER_CONTAINERD_GOPATH = "$(@D)/vendor" | ||
DOCKER_CONTAINERD_MAKE_ENV = $(HOST_GO_TARGET_ENV) \ | ||
CGO_ENABLED=1 \ | ||
GOBIN="$(@D)/bin" \ | ||
GOPATH="$(DOCKER_CONTAINERD_GOPATH)" | ||
|
||
DOCKER_CONTAINERD_GLDFLAGS = \ | ||
-X github.com/docker/containerd.GitCommit=$(DOCKER_CONTAINERD_VERSION) \ | ||
-extldflags '-static' | ||
|
||
define DOCKER_CONTAINERD_CONFIGURE_CMDS | ||
mkdir -p $(DOCKER_CONTAINERD_GOPATH)/src/github.com/docker | ||
ln -s $(@D) $(DOCKER_CONTAINERD_GOPATH)/src/github.com/docker/containerd | ||
mkdir -p $(DOCKER_CONTAINERD_GOPATH)/src/github.com/opencontainers | ||
ln -s $(RUNC_SRCDIR) $(DOCKER_CONTAINERD_GOPATH)/src/github.com/opencontainers/runc | ||
endef | ||
|
||
define DOCKER_CONTAINERD_BUILD_CMDS | ||
cd $(@D); $(DOCKER_CONTAINERD_MAKE_ENV) $(HOST_DIR)/usr/bin/go build -v -o $(@D)/bin/ctr -ldflags "$(DOCKER_CONTAINERD_GLDFLAGS)" ./ctr | ||
cd $(@D); $(DOCKER_CONTAINERD_MAKE_ENV) $(HOST_DIR)/usr/bin/go build -v -o $(@D)/bin/containerd -ldflags "$(DOCKER_CONTAINERD_GLDFLAGS)" ./containerd | ||
cd $(@D); $(DOCKER_CONTAINERD_MAKE_ENV) $(HOST_DIR)/usr/bin/go build -v -o $(@D)/bin/containerd-shim -ldflags "$(DOCKER_CONTAINERD_GLDFLAGS)" ./containerd-shim | ||
endef | ||
|
||
define DOCKER_CONTAINERD_INSTALL_TARGET_CMDS | ||
ln -fs runc $(TARGET_DIR)/usr/bin/docker-runc | ||
$(INSTALL) -D -m 0755 $(@D)/bin/containerd $(TARGET_DIR)/usr/bin/docker-containerd | ||
$(INSTALL) -D -m 0755 $(@D)/bin/containerd-shim $(TARGET_DIR)/usr/bin/containerd-shim | ||
ln -fs containerd-shim $(TARGET_DIR)/usr/bin/docker-containerd-shim | ||
endef | ||
|
||
$(eval $(generic-package)) |