]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircgroup: introduce virCgroupAddThread
authorPavel Hrdina <phrdina@redhat.com>
Mon, 24 Sep 2018 22:54:04 +0000 (00:54 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 25 Sep 2018 07:59:23 +0000 (09:59 +0200)
Once we introduce cgroup v2 support we need to handle processes and
threads differently.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/libvirt_private.syms
src/qemu/qemu_process.c
src/util/vircgroup.c
src/util/vircgroup.h

index 825f68005ef74b70a62bdf72418dee3bb5899f39..61b454761cfb48f83a9086ca8185c688ba00ff66 100644 (file)
@@ -1500,6 +1500,7 @@ virBufferVasprintf;
 # util/vircgroup.h
 virCgroupAddMachineProcess;
 virCgroupAddProcess;
+virCgroupAddThread;
 virCgroupAllowAllDevices;
 virCgroupAllowDevice;
 virCgroupAllowDevicePath;
index ca0fb0504d435dad924a553c9e56da88f56f243a..a471a1e8397c1b994ba5dcf518c417af6f10127d 100644 (file)
@@ -2549,7 +2549,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
             goto cleanup;
 
         /* Move the thread to the sub dir */
-        if (virCgroupAddProcess(cgroup, pid) < 0)
+        if (virCgroupAddThread(cgroup, pid) < 0)
             goto cleanup;
 
     }
index 946cfb50b775632bb3b3437c388cd27df0886814..bbb0969964e0c449655913521fcec37037ad3ae7 100644 (file)
@@ -1160,6 +1160,10 @@ typedef enum {
     /* Same as VIR_CGROUP_TASK_PROCESS but it also adds the task to systemd
      * named controller. */
     VIR_CGROUP_TASK_SYSTEMD = 1 << 1,
+
+    /* Moves only specific thread into cgroup except to systemd
+     * named controller. */
+    VIR_CGROUP_TASK_THREAD = 1 << 2,
 } virCgroupTaskFlags;
 
 
@@ -1228,6 +1232,24 @@ virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid)
                                     VIR_CGROUP_TASK_SYSTEMD);
 }
 
+/**
+ * virCgroupAddThread:
+ *
+ * @group: The cgroup to add a thread to
+ * @pid: The pid of the thread to add
+ *
+ * Will add the thread to all controllers, except the
+ * systemd unit controller.
+ *
+ * Returns: 0 on success, -1 on error
+ */
+int
+virCgroupAddThread(virCgroupPtr group,
+                   pid_t pid)
+{
+    return virCgroupAddTaskInternal(group, pid, VIR_CGROUP_TASK_THREAD);
+}
+
 
 static int
 virCgroupSetPartitionSuffix(const char *path, char **res)
@@ -4229,6 +4251,16 @@ virCgroupAddMachineProcess(virCgroupPtr group ATTRIBUTE_UNUSED,
 }
 
 
+int
+virCgroupAddThread(virCgroupPtr group ATTRIBUTE_UNUSED,
+                   pid_t pid ATTRIBUTE_UNUSED)
+{
+    virReportSystemError(ENXIO, "%s",
+                         _("Control groups not supported on this platform"));
+    return -1;
+}
+
+
 int
 virCgroupGetBlkioIoServiced(virCgroupPtr group ATTRIBUTE_UNUSED,
                             long long *bytes_read ATTRIBUTE_UNUSED,
index bbd4c2ed57cbc3fc696d12830b0f3ae9b442c291..1f676f21c38009f94c2bb91fc0de724d9799d780 100644 (file)
@@ -120,6 +120,7 @@ int virCgroupPathOfController(virCgroupPtr group,
 
 int virCgroupAddProcess(virCgroupPtr group, pid_t pid);
 int virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid);
+int virCgroupAddThread(virCgroupPtr group, pid_t pid);
 
 int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
 int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight);