提交 36c5989c 编写于 作者: P Pavel Hrdina

vircgroup: introduce virCgroupTaskFlags

Use flags in virCgroupAddTaskInternal instead of boolean parameter.
Following patch will add new flag to indicate thread instead of process.
Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 0772c346
...@@ -1152,8 +1152,21 @@ virCgroupNew(pid_t pid, ...@@ -1152,8 +1152,21 @@ virCgroupNew(pid_t pid,
} }
typedef enum {
/* Adds a whole process with all threads to specific cgroup except
* to systemd named controller. */
VIR_CGROUP_TASK_PROCESS = 1 << 0,
/* Same as VIR_CGROUP_TASK_PROCESS but it also adds the task to systemd
* named controller. */
VIR_CGROUP_TASK_SYSTEMD = 1 << 1,
} virCgroupTaskFlags;
static int static int
virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd) virCgroupAddTaskInternal(virCgroupPtr group,
pid_t pid,
unsigned int flags)
{ {
int ret = -1; int ret = -1;
size_t i; size_t i;
...@@ -1166,7 +1179,8 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd) ...@@ -1166,7 +1179,8 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
/* We must never add tasks in systemd's hierarchy /* We must never add tasks in systemd's hierarchy
* unless we're intentionally trying to move a * unless we're intentionally trying to move a
* task into a systemd machine scope */ * task into a systemd machine scope */
if (i == VIR_CGROUP_CONTROLLER_SYSTEMD && !withSystemd) if (i == VIR_CGROUP_CONTROLLER_SYSTEMD &&
!(flags & VIR_CGROUP_TASK_SYSTEMD))
continue; continue;
if (virCgroupSetValueI64(group, i, "tasks", pid) < 0) if (virCgroupSetValueI64(group, i, "tasks", pid) < 0)
...@@ -1192,7 +1206,7 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd) ...@@ -1192,7 +1206,7 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
int int
virCgroupAddProcess(virCgroupPtr group, pid_t pid) virCgroupAddProcess(virCgroupPtr group, pid_t pid)
{ {
return virCgroupAddTaskInternal(group, pid, false); return virCgroupAddTaskInternal(group, pid, VIR_CGROUP_TASK_PROCESS);
} }
/** /**
...@@ -1209,7 +1223,9 @@ virCgroupAddProcess(virCgroupPtr group, pid_t pid) ...@@ -1209,7 +1223,9 @@ virCgroupAddProcess(virCgroupPtr group, pid_t pid)
int int
virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid) virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid)
{ {
return virCgroupAddTaskInternal(group, pid, true); return virCgroupAddTaskInternal(group, pid,
VIR_CGROUP_TASK_PROCESS |
VIR_CGROUP_TASK_SYSTEMD);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册