[lxc-devel] [lxcfs/master] api_extensions: add and log api extensions

brauner on Github lxc-bot at linuxcontainers.org
Thu Feb 27 14:33:19 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 2348 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200227/ffd352a9/attachment.bin>
-------------- next part --------------
From ce8fc84c7ffb790e858233455793ca06f9722966 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 27 Feb 2020 15:23:02 +0100
Subject: [PATCH] api_extensions: add and log api extensions

New features should get an entry in here:

Feb 27 15:21:54 wittgenstein lxcfs[2129877]: mount namespace: 4
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: hierarchies:
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:   0: fd:   5:
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:   1: fd:   6: name=systemd
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:   2: fd:   7: cpu,cpuacct
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:   3: fd:   8: rdma
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:   4: fd:   9: devices
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:   5: fd:  10: pids
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:   6: fd:  11: net_cls,net_prio
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:   7: fd:  12: memory
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:   8: fd:  13: perf_event
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:   9: fd:  14: blkio
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:  10: fd:  15: freezer
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:  11: fd:  16: cpuset
Feb 27 15:21:54 wittgenstein lxcfs[2129877]:  12: fd:  17: hugetlb
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: Kernel supports pidfds
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: api_extensions:
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - cgroups
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - sys_cpu_online
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - proc_cpuinfo
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - proc_diskstats
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - proc_loadavg
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - proc_meminfo
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - proc_stat
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - proc_swaps
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - proc_uptime
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - shared_pidns
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - cpuview_daemon
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - loadavg_daemon
Feb 27 15:21:54 wittgenstein lxcfs[2129877]: - pidfds

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 Makefile.am      |  6 ++++--
 api_extensions.h | 33 +++++++++++++++++++++++++++++++++
 bindings.c       |  7 ++++++-
 3 files changed, 43 insertions(+), 3 deletions(-)
 create mode 100644 api_extensions.h

diff --git a/Makefile.am b/Makefile.am
index 41f3249..5029ef3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,7 +12,8 @@ AM_LDFLAGS = $(FUSE_LIBS) -pthread
 
 AM_CFLAGS += -DRUNTIME_PATH=\"$(RUNTIME_PATH)\"
 
-liblxcfs_la_SOURCES = bindings.c bindings.h \
+liblxcfs_la_SOURCES = api_extension.h \
+		      bindings.c bindings.h \
 		      cgroup_fuse.c cgroup_fuse.h \
 		      cgroups/cgfsng.c \
 		      cgroups/cgroup.c cgroups/cgroup.h \
@@ -29,7 +30,8 @@ liblxcfs_la_SOURCES = bindings.c bindings.h \
 liblxcfs_la_CFLAGS = $(AM_CFLAGS)
 liblxcfs_la_LDFLAGS = $(AM_CFLAGS) -module -avoid-version -shared
 
-liblxcfstest_la_SOURCES = bindings.c bindings.h \
+liblxcfstest_la_SOURCES = api_extension.h \
+			  bindings.c bindings.h \
 			  cgroup_fuse.c cgroup_fuse.h \
 			  cgroups/cgfsng.c \
 			  cgroups/cgroup.c cgroups/cgroup.h \
diff --git a/api_extensions.h b/api_extensions.h
new file mode 100644
index 0000000..a4ee0c1
--- /dev/null
+++ b/api_extensions.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#ifndef __LXCFS_API_EXTENSIONS_H
+#define __LXCFS_API_EXTENSIONS_H
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "config.h"
+
+/*
+ * api_extensions is the list of all API extensions in the order they were
+ * added.
+ */
+static char *api_extensions[] = {
+	"cgroups",
+	"sys_cpu_online",
+	"proc_cpuinfo",
+	"proc_diskstats",
+	"proc_loadavg",
+	"proc_meminfo",
+	"proc_stat",
+	"proc_swaps",
+	"proc_uptime",
+	"shared_pidns",
+	"cpuview_daemon",
+	"loadavg_daemon",
+	"pidfds",
+};
+
+static size_t nr_api_extensions = sizeof(api_extensions) / sizeof(*api_extensions);
+
+#endif /* __LXCFS_API_EXTENSIONS_H */
diff --git a/bindings.c b/bindings.c
index e4a8d15..128a504 100644
--- a/bindings.c
+++ b/bindings.c
@@ -45,6 +45,7 @@
 #include <sys/sysinfo.h>
 #include <sys/vfs.h>
 
+#include "api_extensions.h"
 #include "bindings.h"
 #include "config.h"
 #include "cgroup_fuse.h"
@@ -748,8 +749,12 @@ static void __attribute__((constructor)) lxcfs_init(void)
 	pidfd = pidfd_open(pid, 0);
 	if (pidfd >= 0 && pidfd_send_signal(pidfd, 0, NULL, 0) == 0) {
 		can_use_pidfd = true;
-		lxcfs_error("Kernel supports pidfds");
+		fprintf(stderr, "Kernel supports pidfds\n");
 	}
+
+	fprintf(stderr, "api_extensions:\n");
+	for (i = 0; i < nr_api_extensions; i++)
+		fprintf(stderr, "- %s\n", api_extensions[i]);
 }
 
 static void __attribute__((destructor)) lxcfs_exit(void)


More information about the lxc-devel mailing list