Compare commits
No commits in common. "4a2176c1ecdff7b26e44cdf6240b9aa779496170" and "9d7f95449216b4ba1ea94b25be6fc3989464e0e7" have entirely different histories.
4a2176c1ec
...
9d7f954492
@ -1,73 +0,0 @@
|
|||||||
From d9c7eee7cbae3de3b092fc317ff3e002e1a02bf9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: lipengyu <lipengyu@kylinos.cn>
|
|
||||||
Date: Fri, 6 Dec 2024 14:38:39 +0800
|
|
||||||
Subject: [PATCH] support-for-multiple-controller-nount-to-same-point
|
|
||||||
|
|
||||||
---
|
|
||||||
src/config.c | 29 ++++++++++++++++++++++++++++-
|
|
||||||
1 file changed, 28 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/config.c b/src/config.c
|
|
||||||
index 7678578..4d33b0d 100644
|
|
||||||
--- a/src/config.c
|
|
||||||
+++ b/src/config.c
|
|
||||||
@@ -629,6 +629,22 @@ void cgroup_config_cleanup_namespace_table(void)
|
|
||||||
memset(&config_namespace_table, 0, sizeof(struct cg_mount_table_s) * CG_CONTROLLER_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int is_valid_controller(char *ctrl)
|
|
||||||
+{
|
|
||||||
+ int i;
|
|
||||||
+
|
|
||||||
+ static const char *ctrl_list[] = { "blkio", "cpu", "cpuacct", "cpuset", "devices",
|
|
||||||
+ "freezer", "hugetlb", "memory", "misc", "net_cls",
|
|
||||||
+ "net_prio", "perf_event", "pids", "rdma", NULL };
|
|
||||||
+
|
|
||||||
+ for (i = 0; ctrl_list[i]; i++) {
|
|
||||||
+ if (strncmp(ctrl, ctrl_list[i], strlen(ctrl_list[i])) == 0)
|
|
||||||
+ return 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Add necessary options for mount. Currently only 'none' option is added
|
|
||||||
* for mounts with only 'name=xxx' and without real controller.
|
|
||||||
@@ -657,6 +673,9 @@ static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount, un
|
|
||||||
|
|
||||||
strncpy(mount->name, controller, sizeof(mount->name));
|
|
||||||
mount->name[sizeof(mount->name)-1] = '\0';
|
|
||||||
+ free(controller);
|
|
||||||
+ token = strtok_r(NULL, ",", &save);
|
|
||||||
+ continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncmp(token, "nodev", strlen("nodev")) == 0)
|
|
||||||
@@ -668,6 +687,15 @@ static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount, un
|
|
||||||
if (strncmp(token, "nosuid", strlen("nosuid")) == 0)
|
|
||||||
*flags |= MS_NOSUID;
|
|
||||||
|
|
||||||
+ if (is_valid_controller(token)) {
|
|
||||||
+ controller = strdup(token);
|
|
||||||
+ if (controller == NULL)
|
|
||||||
+ break;
|
|
||||||
+ strncat(mount->name, ",", FILENAME_MAX - strlen(mount->name)-1);
|
|
||||||
+ strncat(mount->name, controller, FILENAME_MAX - strlen(mount->name) - 1);
|
|
||||||
+ free(controller);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
} else if (!name_only) {
|
|
||||||
/*
|
|
||||||
* We have controller + name=, do the right thing,
|
|
||||||
@@ -679,7 +707,6 @@ static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount, un
|
|
||||||
token = strtok_r(NULL, ",", &save);
|
|
||||||
}
|
|
||||||
|
|
||||||
- free(controller);
|
|
||||||
free(opts);
|
|
||||||
|
|
||||||
if (name_only) {
|
|
||||||
--
|
|
||||||
2.25.1
|
|
||||||
|
|
||||||
18
cgconfig.service
Normal file
18
cgconfig.service
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Control Group configuration service
|
||||||
|
|
||||||
|
# The service should be able to start as soon as possible,
|
||||||
|
# before any 'normal' services:
|
||||||
|
DefaultDependencies=no
|
||||||
|
Conflicts=shutdown.target
|
||||||
|
Before=basic.target shutdown.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
Delegate=yes
|
||||||
|
ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf -s 1664
|
||||||
|
ExecStop=/usr/sbin/cgclear -l /etc/cgconfig.conf -e
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sysinit.target
|
||||||
13
config.patch
13
config.patch
@ -1,13 +0,0 @@
|
|||||||
--- libcgroup-3.1.0/samples/config/cgconfig.sysconfig.orig 2019-12-19 11:25:25.547000000 +0800
|
|
||||||
+++ libcgroup-3.1.0/samples/config/cgconfig.sysconfig 2019-12-19 11:26:01.142000000 +0800
|
|
||||||
@@ -5,8 +5,5 @@
|
|
||||||
# controller to limit cpu.shares of this default group and allowing some more
|
|
||||||
# important group take most of the CPU.
|
|
||||||
#
|
|
||||||
-# By default, create these groups:
|
|
||||||
-CREATE_DEFAULT=yes
|
|
||||||
-
|
|
||||||
-# Uncomment following line to disable creation of the default group on startup:
|
|
||||||
-# CREATE_DEFAULT=no
|
|
||||||
+# By default, do not create these groups:
|
|
||||||
+CREATE_DEFAULT=no
|
|
||||||
Binary file not shown.
107
libcgroup.spec
107
libcgroup.spec
@ -5,17 +5,13 @@
|
|||||||
Summary: Libcgroup is a library that abstracts the control group file system in Linux
|
Summary: Libcgroup is a library that abstracts the control group file system in Linux
|
||||||
Name: libcgroup
|
Name: libcgroup
|
||||||
Version: 3.1.0
|
Version: 3.1.0
|
||||||
Release: 6
|
Release: 1
|
||||||
License: LGPL-2.1-or-later
|
License: LGPLv2+
|
||||||
URL: https://libcg.sourceforge.net/
|
URL: http://libcg.sourceforge.net/
|
||||||
Source: https://github.com/%{name}/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
|
Source0: https://github.com/%{name}/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||||
Provides: libcgroup-pam = %{version}-%{release}
|
Source1: cgconfig.service
|
||||||
Provides: libcgroup-tools < %{version}-%{release}
|
Provides: libcgroup-pam libcgroup-tools
|
||||||
Obsoletes: libcgroup-pam = %{version}-%{release}
|
Obsoletes: libcgroup-pam libcgroup-tools
|
||||||
Obsoletes: libcgroup-tools < %{version}-%{release}
|
|
||||||
|
|
||||||
Patch0: config.patch
|
|
||||||
Patch1: Add-support-for-multiple-controllers-on-same-mount-point.patch
|
|
||||||
|
|
||||||
BuildRequires: autoconf, automake, libtool
|
BuildRequires: autoconf, automake, libtool
|
||||||
BuildRequires: gcc,gcc-c++,byacc
|
BuildRequires: gcc,gcc-c++,byacc
|
||||||
@ -36,32 +32,37 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
|
|||||||
Devel provides API for creating,deleting and modifying cgroup nodes.It allows
|
Devel provides API for creating,deleting and modifying cgroup nodes.It allows
|
||||||
the creation of cgroups' configuration and provides scripts for managing it.
|
the creation of cgroups' configuration and provides scripts for managing it.
|
||||||
|
|
||||||
%package_help
|
%package help
|
||||||
|
Summary: It provides helpful information for libcgroup
|
||||||
|
%description help
|
||||||
|
It provides helpful information for libcgroup-pam,libcgroup-devel,libcgroup-tools and libcgroup.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -p1 -n %{name}-%{version}
|
%setup -q -n %{name}-%{version}
|
||||||
|
|
||||||
%build
|
%build
|
||||||
autoreconf -vif
|
autoreconf -vif
|
||||||
%configure --enable-pam-module-dir=%{_libdir}/security --enable-opaque-hierarchy="name=systemd" --disable-daemon --disable-static
|
%configure --enable-pam-module-dir=%{_libdir}/security --enable-opaque-hierarchy="name=systemd" --disable-daemon
|
||||||
%ifarch sw_64
|
%ifarch sw_64
|
||||||
make
|
make
|
||||||
%else
|
%else
|
||||||
%make_build
|
make %{?_smp_mflags}
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%install
|
%install
|
||||||
%make_install
|
make DESTDIR=$RPM_BUILD_ROOT install
|
||||||
%delete_la
|
|
||||||
|
|
||||||
# config
|
# config
|
||||||
install -d ${RPM_BUILD_ROOT}%{_sysconfdir}
|
install -d ${RPM_BUILD_ROOT}%{_sysconfdir}
|
||||||
install -d ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig
|
install -d ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig
|
||||||
|
install -m 644 samples/config/cgconfig.conf $RPM_BUILD_ROOT%{_sysconfdir}/cgconfig.conf
|
||||||
install -m 644 samples/config/cgsnapshot_denylist.conf $RPM_BUILD_ROOT%{_sysconfdir}/cgsnapshot_denylist.conf
|
install -m 644 samples/config/cgsnapshot_denylist.conf $RPM_BUILD_ROOT%{_sysconfdir}/cgsnapshot_denylist.conf
|
||||||
|
|
||||||
# Only one pam_cgroup.so is needed
|
# Only one pam_cgroup.so is needed
|
||||||
#mv -f $RPM_BUILD_ROOT%{_libdir}/security/pam_cgroup.so $RPM_BUILD_ROOT%{_libdir}/security/pam_cgroup.so
|
#mv -f $RPM_BUILD_ROOT%{_libdir}/security/pam_cgroup.so $RPM_BUILD_ROOT%{_libdir}/security/pam_cgroup.so
|
||||||
rm -f $RPM_BUILD_ROOT%{_libdir}/security/pam_cgroup.so.*
|
rm -f $RPM_BUILD_ROOT%{_libdir}/security/pam_cgroup.{,l}a $RPM_BUILD_ROOT%{_libdir}/security/pam_cgroup.so.*
|
||||||
|
|
||||||
|
rm -f $RPM_BUILD_ROOT%{_libdir}/*.{,l}a
|
||||||
|
|
||||||
rm -f $RPM_BUILD_ROOT%{_libdir}/libcgroupfortesting.*
|
rm -f $RPM_BUILD_ROOT%{_libdir}/libcgroupfortesting.*
|
||||||
|
|
||||||
@ -69,29 +70,51 @@ rm -f $RPM_BUILD_ROOT%{_mandir}/man5/cgred.conf.5*
|
|||||||
rm -f $RPM_BUILD_ROOT%{_mandir}/man5/cgrules.conf.5*
|
rm -f $RPM_BUILD_ROOT%{_mandir}/man5/cgrules.conf.5*
|
||||||
rm -f $RPM_BUILD_ROOT%{_mandir}/man8/cgrulesengd.8*
|
rm -f $RPM_BUILD_ROOT%{_mandir}/man8/cgrulesengd.8*
|
||||||
|
|
||||||
|
# unit and sysconfig
|
||||||
|
install -d ${RPM_BUILD_ROOT}%{_unitdir}
|
||||||
|
install -m 644 %SOURCE1 ${RPM_BUILD_ROOT}%{_unitdir}/
|
||||||
|
|
||||||
%pre
|
%pre
|
||||||
getent group cgred >/dev/null || groupadd -r cgred
|
getent group cgred >/dev/null || groupadd -r cgred
|
||||||
|
|
||||||
|
%post
|
||||||
|
%systemd_post cgconfig.service
|
||||||
|
|
||||||
|
%preun
|
||||||
|
%systemd_preun cgconfig.service
|
||||||
|
|
||||||
|
%postun
|
||||||
|
%systemd_postun_with_restart cgconfig.service
|
||||||
|
|
||||||
|
%triggerun -- libcgroup < 0.38
|
||||||
|
/usr/bin/systemd-sysv-convert --save cgconfig >/dev/null 2>&1 ||:
|
||||||
|
/sbin/chkconfig --del cgconfig >/dev/null 2>&1 || :
|
||||||
|
/bin/systemctl try-restart cgconfig.service >/dev/null 2>&1 || :
|
||||||
|
|
||||||
%files
|
%files
|
||||||
|
%{!?_licensedir:%global license %%doc}
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%{_libdir}/libcgroup.so.*
|
%{_libdir}/libcgroup.so.*
|
||||||
%config(noreplace) %{_sysconfdir}/cgsnapshot_denylist.conf
|
%config(noreplace) %{_sysconfdir}/cgsnapshot_denylist.conf
|
||||||
%{_bindir}/cgget
|
%config(noreplace) %{_sysconfdir}/cgconfig.conf
|
||||||
%{_bindir}/cgset
|
/usr/bin/cgget
|
||||||
%{_bindir}/cgcreate
|
/usr/bin/cgset
|
||||||
%{_bindir}/cgdelete
|
/usr/bin/cgcreate
|
||||||
%{_bindir}/cgsnapshot
|
/usr/bin/cgdelete
|
||||||
%{_bindir}/lscgroup
|
/usr/bin/cgsnapshot
|
||||||
%{_bindir}/lssubsys
|
/usr/bin/lscgroup
|
||||||
%{_sbindir}/cgconfigparser
|
/usr/bin/lssubsys
|
||||||
%attr(2755, root, cgred) %{_bindir}/cgexec
|
/usr/sbin/cgconfigparser
|
||||||
%attr(2755, root, cgred) %{_bindir}/cgclassify
|
%attr(2755, root, cgred) /usr/bin/cgexec
|
||||||
|
%attr(2755, root, cgred) /usr/bin/cgclassify
|
||||||
%attr(0755, root, root) %{_libdir}/security/pam_cgroup.so
|
%attr(0755, root, root) %{_libdir}/security/pam_cgroup.so
|
||||||
|
%{_unitdir}/cgconfig.service
|
||||||
%{_bindir}/cgxget
|
%{_bindir}/cgxget
|
||||||
%{_bindir}/cgxset
|
%{_bindir}/cgxset
|
||||||
%{_bindir}/libcgroup_systemd_idle_thread
|
%{_bindir}/libcgroup_systemd_idle_thread
|
||||||
|
|
||||||
%files devel
|
%files devel
|
||||||
|
%{!?_licensedir:%global license %%doc}
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%{_libdir}/libcgroup.so
|
%{_libdir}/libcgroup.so
|
||||||
%{_libdir}/pkgconfig/libcgroup.pc
|
%{_libdir}/pkgconfig/libcgroup.pc
|
||||||
@ -99,39 +122,13 @@ getent group cgred >/dev/null || groupadd -r cgred
|
|||||||
%{_includedir}/libcgroup/*.h
|
%{_includedir}/libcgroup/*.h
|
||||||
|
|
||||||
%files help
|
%files help
|
||||||
|
%license COPYING
|
||||||
%doc README README_systemd
|
%doc README README_systemd
|
||||||
%attr(0644, root, root) %{_mandir}/man1/*
|
%attr(0644, root, root) %{_mandir}/man1/*
|
||||||
%attr(0644, root, root) %{_mandir}/man5/*
|
%attr(0644, root, root) %{_mandir}/man5/*
|
||||||
%attr(0644, root, root) %{_mandir}/man8/*
|
%attr(0644, root, root) %{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Tue Nov 26 2024 lipengyu <lipengyu@kylinos.cn> - 3.1.0-6
|
|
||||||
- Type:update
|
|
||||||
- Id:NA
|
|
||||||
- SUG:NA
|
|
||||||
- DESC:Add support for multiple controller mount to same point
|
|
||||||
|
|
||||||
* Fri Oct 11 2024 Funda Wang <fundawang@yeah.net> - 3.1.0-5
|
|
||||||
- apply patch
|
|
||||||
|
|
||||||
* Fri Jul 12 2024 liuxu <liuxu156@huawei.com> - 3.1.0-4
|
|
||||||
- Type: bugfix
|
|
||||||
- Id:NA
|
|
||||||
- SUG:NA
|
|
||||||
- DESC:fix config.patch
|
|
||||||
|
|
||||||
* Fri Apr 12 2024 liuxu <liuxu156@huawei.com> - 3.1.0-3
|
|
||||||
- Type: bugfix
|
|
||||||
- Id:NA
|
|
||||||
- SUG:NA
|
|
||||||
- DESC:fix corrupted libcgroup-3.1.0.tar.gz
|
|
||||||
|
|
||||||
* Mon Aug 28 2023 luoyujie <luoyujie5@huawei.com> - 3.1.0-2
|
|
||||||
- Type: enhancement
|
|
||||||
- Id:NA
|
|
||||||
- SUG:NA
|
|
||||||
- DESC:delete unnecessary cgconfig service support
|
|
||||||
|
|
||||||
* Wed Aug 16 2023 luoyujie <luoyujie5@huawei.com> - 3.1.0-1
|
* Wed Aug 16 2023 luoyujie <luoyujie5@huawei.com> - 3.1.0-1
|
||||||
- Type: upgrade
|
- Type: upgrade
|
||||||
- Id:NA
|
- Id:NA
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
version_control: github
|
version_control: github
|
||||||
src_repo: libcgroup/libcgroup
|
src_repo: libcgroup/libcgroup
|
||||||
tag_prefix: ^v
|
tag_prefix:
|
||||||
separator: "."
|
seperator: "."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user