On Tue, Sep 18, 2018 at 2:17 PM, Pavel Hrdina <phrdina@xxxxxxxxxx> wrote:
Use flags in virCgroupAddTaskInternal instead of boolean parameter.
Following patch will ad new flag to indicate thread instead of process.
typo: ad -> add
Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
src/util/vircgroup.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index cf510fb019..1d361762c5 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1156,8 +1156,16 @@ virCgroupNew(pid_t pid,
}
+typedef enum {
+ VIR_CGROUP_TASK_PROCESS = 0,
+ VIR_CGROUP_TASK_SYSTEMD = 1 << 0,
Although not strictly needed, would be nice to have a comment describing what the flags mean.
+} virCgroupTaskFlags;
+
+
static int
-virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
+virCgroupAddTaskInternal(virCgroupPtr group,
+ pid_t pid,
+ unsigned int flags)
{
int ret = -1;
size_t i;
@@ -1170,7 +1178,8 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
/* We must never add tasks in systemd's hierarchy
* unless we're intentionally trying to move a
* 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;
if (virCgroupSetValueI64(group, i, "tasks", pid) < 0)
@@ -1196,7 +1205,7 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
int
virCgroupAddProcess(virCgroupPtr group, pid_t pid)
{
- return virCgroupAddTaskInternal(group, pid, false);
+ return virCgroupAddTaskInternal(group, pid, VIR_CGROUP_TASK_PROCESS);
}
/**
@@ -1213,7 +1222,9 @@ virCgroupAddProcess(virCgroupPtr group, pid_t pid)
int
virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid)
{
- return virCgroupAddTaskInternal(group, pid, true);
+ return virCgroupAddTaskInternal(group, pid,
+ VIR_CGROUP_TASK_PROCESS |
+ VIR_CGROUP_TASK_SYSTEMD);
}
--
2.17.1
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list
Reviewed-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list