提交 7b526ea5 编写于 作者: P Pavel Hrdina

vircgroup: introduce virCgroupAddThread

Once we introduce cgroup v2 support we need to handle processes and
threads differently.
Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 36c5989c
...@@ -1500,6 +1500,7 @@ virBufferVasprintf; ...@@ -1500,6 +1500,7 @@ virBufferVasprintf;
# util/vircgroup.h # util/vircgroup.h
virCgroupAddMachineProcess; virCgroupAddMachineProcess;
virCgroupAddProcess; virCgroupAddProcess;
virCgroupAddThread;
virCgroupAllowAllDevices; virCgroupAllowAllDevices;
virCgroupAllowDevice; virCgroupAllowDevice;
virCgroupAllowDevicePath; virCgroupAllowDevicePath;
......
...@@ -2549,7 +2549,7 @@ qemuProcessSetupPid(virDomainObjPtr vm, ...@@ -2549,7 +2549,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
goto cleanup; goto cleanup;
/* Move the thread to the sub dir */ /* Move the thread to the sub dir */
if (virCgroupAddProcess(cgroup, pid) < 0) if (virCgroupAddThread(cgroup, pid) < 0)
goto cleanup; goto cleanup;
} }
......
...@@ -1160,6 +1160,10 @@ typedef enum { ...@@ -1160,6 +1160,10 @@ typedef enum {
/* Same as VIR_CGROUP_TASK_PROCESS but it also adds the task to systemd /* Same as VIR_CGROUP_TASK_PROCESS but it also adds the task to systemd
* named controller. */ * named controller. */
VIR_CGROUP_TASK_SYSTEMD = 1 << 1, VIR_CGROUP_TASK_SYSTEMD = 1 << 1,
/* Moves only specific thread into cgroup except to systemd
* named controller. */
VIR_CGROUP_TASK_THREAD = 1 << 2,
} virCgroupTaskFlags; } virCgroupTaskFlags;
...@@ -1228,6 +1232,24 @@ virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid) ...@@ -1228,6 +1232,24 @@ virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid)
VIR_CGROUP_TASK_SYSTEMD); 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 static int
virCgroupSetPartitionSuffix(const char *path, char **res) virCgroupSetPartitionSuffix(const char *path, char **res)
...@@ -4229,6 +4251,16 @@ virCgroupAddMachineProcess(virCgroupPtr group ATTRIBUTE_UNUSED, ...@@ -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 int
virCgroupGetBlkioIoServiced(virCgroupPtr group ATTRIBUTE_UNUSED, virCgroupGetBlkioIoServiced(virCgroupPtr group ATTRIBUTE_UNUSED,
long long *bytes_read ATTRIBUTE_UNUSED, long long *bytes_read ATTRIBUTE_UNUSED,
......
...@@ -120,6 +120,7 @@ int virCgroupPathOfController(virCgroupPtr group, ...@@ -120,6 +120,7 @@ int virCgroupPathOfController(virCgroupPtr group,
int virCgroupAddProcess(virCgroupPtr group, pid_t pid); int virCgroupAddProcess(virCgroupPtr group, pid_t pid);
int virCgroupAddMachineProcess(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 virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight); int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册