|
Pablo Greco |
40546a |
From 83b13b08025476233d7acc7d37297abda861be32 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <83b13b08025476233d7acc7d37297abda861be32@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:06:16 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: introduce virCgroupAddThread
|
|
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 |
Once we introduce cgroup v2 support we need to handle processes and
|
|
Pablo Greco |
40546a |
threads differently.
|
|
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 7b526ea57c8ca02e49f6a8cc71a6910f56803bde)
|
|
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: <ed2085fc086090e3865b08758e973e0eedd78a4d.1561993099.git.phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/libvirt_private.syms | 1 +
|
|
Pablo Greco |
40546a |
src/qemu/qemu_process.c | 2 +-
|
|
Pablo Greco |
40546a |
src/util/vircgroup.c | 32 ++++++++++++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
src/util/vircgroup.h | 1 +
|
|
Pablo Greco |
40546a |
4 files changed, 35 insertions(+), 1 deletion(-)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
Pablo Greco |
40546a |
index 5dd24e2e66..f8c1a0df16 100644
|
|
Pablo Greco |
40546a |
--- a/src/libvirt_private.syms
|
|
Pablo Greco |
40546a |
+++ b/src/libvirt_private.syms
|
|
Pablo Greco |
40546a |
@@ -1515,6 +1515,7 @@ virBufferVasprintf;
|
|
Pablo Greco |
40546a |
# util/vircgroup.h
|
|
Pablo Greco |
40546a |
virCgroupAddMachineProcess;
|
|
Pablo Greco |
40546a |
virCgroupAddProcess;
|
|
Pablo Greco |
40546a |
+virCgroupAddThread;
|
|
Pablo Greco |
40546a |
virCgroupAllowAllDevices;
|
|
Pablo Greco |
40546a |
virCgroupAllowDevice;
|
|
Pablo Greco |
40546a |
virCgroupAllowDevicePath;
|
|
Pablo Greco |
40546a |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
Pablo Greco |
40546a |
index c21586fa12..0cd61f02bb 100644
|
|
Pablo Greco |
40546a |
--- a/src/qemu/qemu_process.c
|
|
Pablo Greco |
40546a |
+++ b/src/qemu/qemu_process.c
|
|
Pablo Greco |
40546a |
@@ -2538,7 +2538,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
/* Move the thread to the sub dir */
|
|
Pablo Greco |
40546a |
- if (virCgroupAddProcess(cgroup, pid) < 0)
|
|
Pablo Greco |
40546a |
+ if (virCgroupAddThread(cgroup, pid) < 0)
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
index 5aa8596b9c..f08fe3600e 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
@@ -1164,6 +1164,10 @@ typedef enum {
|
|
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 |
+
|
|
Pablo Greco |
40546a |
+ /* Moves only specific thread into cgroup except to systemd
|
|
Pablo Greco |
40546a |
+ * named controller. */
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_TASK_THREAD = 1 << 2,
|
|
Pablo Greco |
40546a |
} virCgroupTaskFlags;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -1232,6 +1236,24 @@ virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid)
|
|
Pablo Greco |
40546a |
VIR_CGROUP_TASK_SYSTEMD);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+/**
|
|
Pablo Greco |
40546a |
+ * virCgroupAddThread:
|
|
Pablo Greco |
40546a |
+ *
|
|
Pablo Greco |
40546a |
+ * @group: The cgroup to add a thread to
|
|
Pablo Greco |
40546a |
+ * @pid: The pid of the thread to add
|
|
Pablo Greco |
40546a |
+ *
|
|
Pablo Greco |
40546a |
+ * Will add the thread to all controllers, except the
|
|
Pablo Greco |
40546a |
+ * systemd unit controller.
|
|
Pablo Greco |
40546a |
+ *
|
|
Pablo Greco |
40546a |
+ * Returns: 0 on success, -1 on error
|
|
Pablo Greco |
40546a |
+ */
|
|
Pablo Greco |
40546a |
+int
|
|
Pablo Greco |
40546a |
+virCgroupAddThread(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ pid_t pid)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ return virCgroupAddTaskInternal(group, pid, VIR_CGROUP_TASK_THREAD);
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
static int
|
|
Pablo Greco |
40546a |
virCgroupSetPartitionSuffix(const char *path, char **res)
|
|
Pablo Greco |
40546a |
@@ -4233,6 +4255,16 @@ virCgroupAddMachineProcess(virCgroupPtr group ATTRIBUTE_UNUSED,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+int
|
|
Pablo Greco |
40546a |
+virCgroupAddThread(virCgroupPtr group ATTRIBUTE_UNUSED,
|
|
Pablo Greco |
40546a |
+ pid_t pid ATTRIBUTE_UNUSED)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ virReportSystemError(ENXIO, "%s",
|
|
Pablo Greco |
40546a |
+ _("Control groups not supported on this platform"));
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
int
|
|
Pablo Greco |
40546a |
virCgroupGetBlkioIoServiced(virCgroupPtr group ATTRIBUTE_UNUSED,
|
|
Pablo Greco |
40546a |
long long *bytes_read ATTRIBUTE_UNUSED,
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
|
|
Pablo Greco |
40546a |
index bbd4c2ed57..1f676f21c3 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroup.h
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroup.h
|
|
Pablo Greco |
40546a |
@@ -120,6 +120,7 @@ int virCgroupPathOfController(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
int virCgroupAddProcess(virCgroupPtr group, pid_t pid);
|
|
Pablo Greco |
40546a |
int virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid);
|
|
Pablo Greco |
40546a |
+int virCgroupAddThread(virCgroupPtr group, pid_t pid);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
|
|
Pablo Greco |
40546a |
int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight);
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|