mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 03:21:19 +00:00
vircgroup: introduce virCgroupAddThread
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>
This commit is contained in:
parent
36c5989c54
commit
7b526ea57c
@ -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,
|
|||||||
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 {
|
|||||||
/* 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)
|
|||||||
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,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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,
|
|||||||
|
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user