sbindir=${exec_prefix}/sbin
libdir=${exec_prefix}/lib
includedir=${prefix}/include
-prefix=/usr/local
+prefix=/usr
exec_prefix=${prefix}
INSTALL=install
INSTALL_DATA=install -m 644
CFLAGS=-g -O2 $(INC) -DPACKAGE_VERSION=$(PACKAGE_VERSION)
VERSION=1
-all: libcgroup.so cgconfigparser cgexec cgclassify cgrulesengd
+TARGETS = libcgroup.so cgconfigparser cgexec cgclassify cgrulesengd
+
+all: $(TARGETS)
cgconfigparser: libcgroup.so cgconfig.c libcgroup.h
$(CC) $(CFLAGS) $(INC) -Wall -o $@ cgconfig.c $(LDFLAGS) $(LIBS)
$(CC) $(CFLAGS) -shared -fPIC -Wall -o $@ pam_cgroup.c $(LDFLAGS) \
$(LIBS) -lpam
-install: libcgroup.so cgexec cgclassify cgconfigparser
+install: $(TARGETS)
$(INSTALL_DATA) -D libcgroup.h $(DESTDIR)$(includedir)/libcgroup.h
$(INSTALL) -D libcgroup.so $(DESTDIR)$(libdir)/libcgroup-$(PACKAGE_VERSION).so
ln -sf libcgroup-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libcgroup.so.$(VERSION)
ln -sf libcgroup.so.$(VERSION) $(DESTDIR)$(libdir)/libcgroup.so
- $(INSTALL) -D cgconfigparser $(DESTDIR)$(sbindir)
+ $(INSTALL) -D cgconfigparser $(DESTDIR)$(sbindir)/cgconfigparser
$(INSTALL) -D cgexec $(DESTDIR)$(bindir)/cgexec
$(INSTALL) -D cgclassify $(DESTDIR)$(bindir)/cgclassify
$(INSTALL) -D cgrulesengd $(DESTDIR)$(bindir)/cgrulesengd
clean:
\rm -f y.tab.c y.tab.h lex.yy.c y.output libcgroup.so cgclassify \
- libcgroup.so.$(VERSION) cgconfigparser config.log config.status cgexec \
- pam_cgroup.so cgrulesengd
+ libcgroup.so.$(VERSION) $(TARGETS)
CFLAGS=@CFLAGS@ $(INC) -DPACKAGE_VERSION=$(PACKAGE_VERSION)
VERSION=1
-all: libcgroup.so cgconfigparser cgexec cgclassify cgrulesengd
+TARGETS = libcgroup.so cgconfigparser cgexec cgclassify cgrulesengd
+
+all: $(TARGETS)
cgconfigparser: libcgroup.so cgconfig.c libcgroup.h
$(CC) $(CFLAGS) $(INC) -Wall -o $@ cgconfig.c $(LDFLAGS) $(LIBS)
$(CC) $(CFLAGS) -shared -fPIC -Wall -o $@ pam_cgroup.c $(LDFLAGS) \
$(LIBS) -lpam
-install: libcgroup.so cgexec cgclassify cgconfigparser
+install: $(TARGETS)
$(INSTALL_DATA) -D libcgroup.h $(DESTDIR)$(includedir)/libcgroup.h
$(INSTALL) -D libcgroup.so $(DESTDIR)$(libdir)/libcgroup-$(PACKAGE_VERSION).so
ln -sf libcgroup-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libcgroup.so.$(VERSION)
clean:
\rm -f y.tab.c y.tab.h lex.yy.c y.output libcgroup.so cgclassify \
- libcgroup.so.$(VERSION) cgconfigparser config.log config.status cgexec \
- pam_cgroup.so cgrulesengd
+ libcgroup.so.$(VERSION) $(TARGETS)
&hierarchy, &num_cgroups, &enabled);
if (err < 0)
break;
- controllers[i] = (char *)malloc(strlen(subsys_name));
+ controllers[i] = (char *)malloc(strlen(subsys_name) + 1);
strcpy(controllers[i], subsys_name);
i++;
}
}
}
+ free(temp_ent);
+
if (!found_mnt) {
cg_mount_table[0].name[0] = '\0';
ret = ECGROUPNOTMOUNTED;
FILE *proc_mount;
struct mntent *ent, *temp_ent;
char mntent_buff[4 * FILENAME_MAX];
+ int ret = 1;
proc_mount = fopen("/proc/mounts", "r");
if (proc_mount == NULL) {
while (strcmp(ent->mnt_type, "cgroup") !=0) {
ent = getmntent_r(proc_mount, temp_ent, mntent_buff,
sizeof(mntent_buff));
- if (ent == NULL)
- return 0;
+ if (ent == NULL) {
+ ret = 0;
+ goto done;
+ }
}
+done:
fclose(proc_mount);
- return 1;
+ free(temp_ent);
+ return ret;
}
static inline pid_t cg_gettid()
char *fts_path[2], base[FILENAME_MAX], *path;
int i, j, k;
int error = 0;
+ int retval = 0;
if (!cgroup_initialized)
return ECGROUPNOTINITIALIZED;
cgroup->controller[k]->values[j]->value);
/*
* Should we undo, what we've done in the loops above?
- * An error should not be treated as fatal, since we have
- * several read-only files and several files that
+ * An error should not be treated as fatal, since we
+ * have several read-only files and several files that
* are only conditionally created in the child.
+ *
+ * A middle ground would be to track that there
+ * was an error and return that value.
*/
- if (error)
+ if (error) {
+ retval = error;
continue;
+ }
}
if (!ignore_ownership) {
err:
free(path);
+ if (retval && !error)
+ error = retval;
return error;
}
base_tasks = fopen(path, "w");
if (!base_tasks)
- goto base_open_err;
+ goto open_err;
if (!cg_build_path(cgroup->name, path,
- cgroup->controller[i]->name))
+ cgroup->controller[i]->name)) {
+ fclose(base_tasks);
continue;
+ }
strcat(path, "tasks");
delete_tasks = fopen(path, "r");
- if (!delete_tasks)
- goto del_open_err;
+ if (!delete_tasks) {
+ fclose(base_tasks);
+ goto open_err;
+ }
while (!feof(delete_tasks)) {
ret = fscanf(delete_tasks, "%d", &tids);
- /*
- * Don't know how to handle EOF yet, so
- * ignore it
- */
+ if (ret == EOF || ret < 1)
+ break;
fprintf(base_tasks, "%d", tids);
}
+ fclose(delete_tasks);
+ fclose(base_tasks);
+
if (!cg_build_path(cgroup->name, path,
cgroup->controller[i]->name))
continue;
error = rmdir(path);
-
- fclose(delete_tasks);
}
-del_open_err:
- if (base_tasks)
- fclose(base_tasks);
-base_open_err:
+open_err:
if (ignore_migration) {
for (i = 0; i < cgroup->index; i++) {
if (!cg_build_path(cgroup->name, path,
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
int main(int argc, char *argv[])
{
ret = cgroup_config_load_config(filename);
if (ret) {
printf("Loading configuration file %s "
- "failed, ret = %d\n", filename, ret);
+ "failed, error: %s\n", filename,
+ strerror(errno));
+ printf("return code = %d\n", ret);
exit(3);
}
break;
config_cgroup->tasks_gid = val;
}
+ free(perm_type);
+ free(value);
return 1;
group_task_error:
config_cgroup->control_gid = val;
}
+ free(perm_type);
+ free(value);
return 1;
admin_error:
BuildRequires: byacc
BuildRequires: flex
BuildRequires: coreutils
+Requires(post): chkconfig, /sbin/service
%description
Control groups infrastructure. The tools and library help manipulate, control,
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
+mkdir -p $RPM_BUILD_ROOT/%{_initrddir}
+cp scripts/init.d/cgconfig $RPM_BUILD_ROOT/%{_initrddir}/cgconfig
+cp scripts/init.d/cgred $RPM_BUILD_ROOT/%{_initrddir}/cgred
+
%clean
rm -rf $RPM_BUILD_ROOT
-%post -p /sbin/ldconfig
+%post
+/sbin/ldconfig
+#
+# Do this later if required
+#
+#/sbin/chkconfig --add cgred
+#/sbin/chkconfig --add cgconfig
+
+%preun
+/sbin/service cgred stop > /dev/null 2>&1 || :
+/sbin/service cgconfig stop > /dev/null 2>&1 || :
+/sbin/chkconfig --del cgconfig
+/sbin/chkconfig --del cgred
%postun -p /sbin/ldconfig
%defattr(-,root,root,-)
%{_libdir}/libcgroup-%{version}.so
%{_libdir}/libcgroup.so.*
-%doc COPYING INSTALL
+%{_bindir}/cgexec
+%{_bindir}/cgclassify
+%{_sbindir}/cgconfigparser
+%{_bindir}/cgrulesengd
+%attr(0755,root,root) %{_initrddir}/cgconfig
+%attr(0755,root,root) %{_initrddir}/cgred
+
+%doc COPYING INSTALL README_daemon
%files devel
%defattr(-,root,root,-)
%{_includedir}/libcgroup.h
%{_libdir}/libcgroup.so
-%doc COPYING INSTALL
+%doc COPYING INSTALL
%changelog
+* Fri Oct 10 2008 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.32-1
+- Update to latest upstream
+* Thu Sep 11 2008 Dhaval Giani <dhaval@linux-vnet.ibm.com> 0.31-1
+- Update to latest upstream
+* Sat Aug 2 2008 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.1c-3
+- Change release to fix broken upgrade path
* Wed Jun 11 2008 Dhaval Giani <dhaval@linux.vnet.ibm.com> 0.1c-1
- Update to latest upstream version
* Tue Jun 3 2008 Balbir Singh <balbir@linux.vnet.ibm.com> 0.1b-3
perm {
task {
uid = root;
- gid = kvm;
+ gid = root;
}
admin {
- uid = root;
- gid = root;
+ uid = balbir;
+ gid = balbir;
}
}
+#!/bin/bash
#
# Start/Stop the workload manager
#
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
+# cgconfig Control Groups Configuration Startup
+# chkconfig: 2345 80 20
+# description: This script runs the cgconfigparser utility to parse and setup
+# the control group filesystem. It uses /etc/cgconfig.conf
+# and parses the configuration specified in there.
-#### BEGIN INIT INFO
+### BEGIN INIT INFO
# Provides: cgconfig
# Required-Start: $local_fs $syslog $time
# Required-Stop: $local_fs $syslog
# Default-Stop: 0 1 6
# Short-Description: start and stop the WLM configuration
# Description: This script allows us to create a default configuration
-#### END INIT INFO
+### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin:.
MOUNTS_FILE=/proc/mounts
declare -a MOUNTPOINT
declare -a MOUNTOPTS
maxindex=0
+servicename=cgconfig
#
# Source LSB routines
}
start() {
- if [ -f /var/lock/cgconfig ]
+ if [ -f /var/lock/subsys/$servicename ]
then
log_warning_msg "lock file already exists"
return
if [ $? -eq 0 ]
then
- log_progress_msg "Starting cgconfig service: "
+ #log_progress_msg "Starting cgconfig service: "
cgconfigparser -l $CONFIG_FILE
fi
- [ $? == 0 ] && touch /var/lock/cgconfig
+ [ $? == 0 ] && touch /var/lock/subsys/$servicename
return $?
}
;;
*)
class=${i#./*}
- log_progress_msg "Removing class $class"
+ #log_progress_msg "Removing class $class"
sed -nu p < ./$i/tasks > tasks
rmdir $i
;;
stop() {
move_all_to_init_class
umount_fs
- rm -f /var/lock/cgconfig
+ rm -f /var/lock/subsys/$servicename
}
trapped() {
}
usage() {
- echo "$0 <start|stop>"
+ echo "$0 <start|stop|restart|condrestart|status>"
exit 1
}
stop
start
;;
+ 'condrestart')
+ if [ -f /var/lock/subsys/$servicename ] ; then
+ stop
+ start
+ fi
+ ;;
+ 'status')
+ if [ -f /var/lock/subsys/$servicename ] ; then
+ echo "Running"
+ else
+ echo "Stopped"
+ fi
+ ;;
*)
usage
;;
#
### BEGIN INIT INFO
# Provides: cgrulesengd
-# Required-Start: $local_fs $syslog $wlm
+# Required-Start: $local_fs $syslog $cgconfig
# Required-Stop: $local_fs $syslog
# Should-Start:
# Should-Stop: