bool cgm_enter(const char *cg) { if ( cgmanager_move_pid_sync(NULL, cgroup_manager, ctrl_list, cg, (int32_t) getpid()) != 0 ) { NihError *nerr; nerr = nih_error_get(); fprintf(stderr, "call to move_pid (%s:%s, %d) failed: %s\n", ctrl_list, cg, (int)getpid(), nerr->message); nih_free(nerr); return false; } return true; }
/* * Use the cgmanager to move a task into a cgroup for a particular * hierarchy. * All the subsystems in this hierarchy are co-mounted, so we only * need to transition the task into one of the cgroups */ static bool lxc_cgmanager_enter(pid_t pid, const char *controller, const char *cgroup_path) { if (cgmanager_move_pid_sync(NULL, cgroup_manager, controller, cgroup_path, pid) != 0) { NihError *nerr; nerr = nih_error_get(); ERROR("call to cgmanager_move_pid_sync failed: %s", nerr->message); nih_free(nerr); return false; } return true; }
bool cgm_move_pid(const char *controller, const char *cgroup, pid_t pid) { if (!cgm_dbus_connect()) { return false; } if ( cgmanager_move_pid_sync(NULL, cgroup_manager, controller, cgroup, (int32_t) pid) != 0 ) { NihError *nerr; nerr = nih_error_get(); fprintf(stderr, "call to move_pid (%s:%s, %d) failed: %s\n", controller, cgroup, pid, nerr->message); nih_free(nerr); cgm_dbus_disconnect(); return false; } cgm_dbus_disconnect(); return true; }
/* * Use the cgmanager to move a task into a cgroup for a particular * hierarchy. * All the subsystems in this hierarchy are co-mounted, so we only * need to transition the task into one of the cgroups * * Internal helper, must be called with cgmanager dbus socket open */ static bool lxc_cgmanager_enter(pid_t pid, const char *controller, const char *cgroup_path, bool abs) { int ret; if (abs) ret = cgmanager_move_pid_abs_sync(NULL, cgroup_manager, controller, cgroup_path, pid); else ret = cgmanager_move_pid_sync(NULL, cgroup_manager, controller, cgroup_path, pid); if (ret != 0) { NihError *nerr; nerr = nih_error_get(); ERROR("call to cgmanager_move_pid_%ssync failed: %s", abs ? "abs_" : "", nerr->message); nih_free(nerr); return false; } return true; }