]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
abstraction: Add mapping tables
authorTom Hromatka <tom.hromatka@oracle.com>
Fri, 28 Jan 2022 17:21:10 +0000 (10:21 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 3 Feb 2022 21:41:57 +0000 (14:41 -0700)
Add a table for cgroup v1 to v2 conversions -
cgroup_v1_to_v2_map[]

Add a table for cgroup v2 to v1 conversions -
cgroup_v2_to_v1_map[]

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
src/Makefile.am
src/abstraction-map.c [new file with mode: 0644]
src/abstraction-map.h [new file with mode: 0644]

index 8a7136aebc13e962e5e74458771b7f9133da08c7..2008ebd7e04771503dc5671588824a4381323400 100644 (file)
@@ -21,7 +21,8 @@ TESTING_MAP_FILE = $(top_srcdir)/tests/gunit/libcgroup_unittest.map
 lib_LTLIBRARIES = libcgroup.la
 libcgroup_la_SOURCES = parse.h parse.y lex.l api.c config.c \
                       libcgroup-internal.h libcgroup.map wrapper.c log.c \
-                      abstraction-common.c abstraction-common.h
+                      abstraction-common.c abstraction-common.h \
+                      abstraction-map.c abstraction-map.h
 libcgroup_la_LIBADD = -lpthread $(CODE_COVERAGE_LIBS)
 libcgroup_la_CFLAGS = $(CODE_COVERAGE_CFLAGS) -DSTATIC=static
 libcgroup_la_LDFLAGS = -Wl,--version-script,$(srcdir)/libcgroup.map \
diff --git a/src/abstraction-map.c b/src/abstraction-map.c
new file mode 100644 (file)
index 0000000..56ac6a2
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * Libcgroup abstraction layer mappings
+ *
+ * Copyright (c) 2021-2022 Oracle and/or its affiliates.
+ * Author: Tom Hromatka <tom.hromatka@oracle.com>
+ */
+
+/*
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include <libcgroup.h>
+#include <libcgroup-internal.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "abstraction-common.h"
+#include "abstraction-map.h"
+
+const struct cgroup_abstraction_map cgroup_v1_to_v2_map[] = {
+};
+const int cgroup_v1_to_v2_map_sz = sizeof(cgroup_v1_to_v2_map) /
+                                  sizeof(cgroup_v1_to_v2_map[0]);
+
+const struct cgroup_abstraction_map cgroup_v2_to_v1_map[] = {
+};
+const int cgroup_v2_to_v1_map_sz = sizeof(cgroup_v2_to_v1_map) /
+                                  sizeof(cgroup_v2_to_v1_map[0]);
diff --git a/src/abstraction-map.h b/src/abstraction-map.h
new file mode 100644 (file)
index 0000000..38c611a
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * Libcgroup abstraction layer mappings
+ *
+ * Copyright (c) 2021-2022 Oracle and/or its affiliates.
+ * Author: Tom Hromatka <tom.hromatka@oracle.com>
+ */
+
+/*
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses>.
+ */
+#ifndef __ABSTRACTION_MAP
+#define __ABSTRACTION_MAP
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct cgroup_abstraction_map {
+       /* if the conversion isn't a one-to-one mapping or the mathematical
+        * conversion is unique, create a custom conversion function.
+        */
+       int (*cgroup_convert)(struct cgroup_controller * const dst_cgc,
+                             const char * const in_value,
+                             const char * const out_setting,
+                             void *in_dflt, void *out_dflt);
+       char *in_setting;
+       void *in_dflt;
+       char *out_setting;
+       void *out_dflt;
+};
+
+extern const struct cgroup_abstraction_map cgroup_v1_to_v2_map[];
+extern const int cgroup_v1_to_v2_map_sz;
+
+extern const struct cgroup_abstraction_map cgroup_v2_to_v1_map[];
+extern const int cgroup_v2_to_v1_map_sz;
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* __ABSTRACTION_MAP */