|
Pablo Greco |
40546a |
From 482d6964af9e1f8a4d52253e6474ce11f4a1ca5f Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <482d6964af9e1f8a4d52253e6474ce11f4a1ca5f@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:06:15 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: introduce virCgroupTaskFlags
|
|
Pablo Greco |
40546a |
MIME-Version: 1.0
|
|
Pablo Greco |
40546a |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
40546a |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Use flags in virCgroupAddTaskInternal instead of boolean parameter.
|
|
Pablo Greco |
40546a |
Following patch will add new flag to indicate thread instead of process.
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
(cherry picked from commit 36c5989c54cf335b365f4e179a4d7ab7d174bd6e)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <a2cf781e5090f8f3ba2aec04aadb80c957001f7c.1561993099.git.phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/util/vircgroup.c | 24 ++++++++++++++++++++----
|
|
Pablo Greco |
40546a |
1 file changed, 20 insertions(+), 4 deletions(-)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
index cf510fb019..5aa8596b9c 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
@@ -1156,8 +1156,21 @@ virCgroupNew(pid_t pid,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+typedef enum {
|
|
Pablo Greco |
40546a |
+ /* Adds a whole process with all threads to specific cgroup except
|
|
Pablo Greco |
40546a |
+ * to systemd named controller. */
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_TASK_PROCESS = 1 << 0,
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ /* Same as VIR_CGROUP_TASK_PROCESS but it also adds the task to systemd
|
|
Pablo Greco |
40546a |
+ * named controller. */
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_TASK_SYSTEMD = 1 << 1,
|
|
Pablo Greco |
40546a |
+} virCgroupTaskFlags;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
static int
|
|
Pablo Greco |
40546a |
-virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
|
|
Pablo Greco |
40546a |
+virCgroupAddTaskInternal(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ pid_t pid,
|
|
Pablo Greco |
40546a |
+ unsigned int flags)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
int ret = -1;
|
|
Pablo Greco |
40546a |
size_t i;
|
|
Pablo Greco |
40546a |
@@ -1170,7 +1183,8 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
|
|
Pablo Greco |
40546a |
/* We must never add tasks in systemd's hierarchy
|
|
Pablo Greco |
40546a |
* unless we're intentionally trying to move a
|
|
Pablo Greco |
40546a |
* task into a systemd machine scope */
|
|
Pablo Greco |
40546a |
- if (i == VIR_CGROUP_CONTROLLER_SYSTEMD && !withSystemd)
|
|
Pablo Greco |
40546a |
+ if (i == VIR_CGROUP_CONTROLLER_SYSTEMD &&
|
|
Pablo Greco |
40546a |
+ !(flags & VIR_CGROUP_TASK_SYSTEMD))
|
|
Pablo Greco |
40546a |
continue;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
if (virCgroupSetValueI64(group, i, "tasks", pid) < 0)
|
|
Pablo Greco |
40546a |
@@ -1196,7 +1210,7 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
|
|
Pablo Greco |
40546a |
int
|
|
Pablo Greco |
40546a |
virCgroupAddProcess(virCgroupPtr group, pid_t pid)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- return virCgroupAddTaskInternal(group, pid, false);
|
|
Pablo Greco |
40546a |
+ return virCgroupAddTaskInternal(group, pid, VIR_CGROUP_TASK_PROCESS);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
/**
|
|
Pablo Greco |
40546a |
@@ -1213,7 +1227,9 @@ virCgroupAddProcess(virCgroupPtr group, pid_t pid)
|
|
Pablo Greco |
40546a |
int
|
|
Pablo Greco |
40546a |
virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- return virCgroupAddTaskInternal(group, pid, true);
|
|
Pablo Greco |
40546a |
+ return virCgroupAddTaskInternal(group, pid,
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_TASK_PROCESS |
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_TASK_SYSTEMD);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|