mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 04:55:18 +00:00
vircgroup: extract virCgroupV1HasEmptyTasks
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
064024e70a
commit
c4047141a0
@ -3461,18 +3461,7 @@ virCgroupSupportsCpuBW(virCgroupPtr cgroup)
|
||||
int
|
||||
virCgroupHasEmptyTasks(virCgroupPtr cgroup, int controller)
|
||||
{
|
||||
int ret = -1;
|
||||
VIR_AUTOFREE(char *) content = NULL;
|
||||
|
||||
if (!cgroup)
|
||||
return -1;
|
||||
|
||||
ret = virCgroupGetValueStr(cgroup, controller, "tasks", &content);
|
||||
|
||||
if (ret == 0 && content[0] == '\0')
|
||||
ret = 1;
|
||||
|
||||
return ret;
|
||||
return cgroup->backend->hasEmptyTasks(cgroup, controller);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -122,6 +122,10 @@ typedef int
|
||||
pid_t pid,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virCgroupHasEmptyTasksCB)(virCgroupPtr cgroup,
|
||||
int controller);
|
||||
|
||||
struct _virCgroupBackend {
|
||||
virCgroupBackendType type;
|
||||
|
||||
@ -141,6 +145,7 @@ struct _virCgroupBackend {
|
||||
virCgroupMakeGroupCB makeGroup;
|
||||
virCgroupRemoveCB remove;
|
||||
virCgroupAddTaskCB addTask;
|
||||
virCgroupHasEmptyTasksCB hasEmptyTasks;
|
||||
};
|
||||
typedef struct _virCgroupBackend virCgroupBackend;
|
||||
typedef virCgroupBackend *virCgroupBackendPtr;
|
||||
|
@ -735,6 +735,25 @@ virCgroupV1AddTask(virCgroupPtr group,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virCgroupV1HasEmptyTasks(virCgroupPtr cgroup,
|
||||
int controller)
|
||||
{
|
||||
int ret = -1;
|
||||
VIR_AUTOFREE(char *) content = NULL;
|
||||
|
||||
if (!cgroup)
|
||||
return -1;
|
||||
|
||||
ret = virCgroupGetValueStr(cgroup, controller, "tasks", &content);
|
||||
|
||||
if (ret == 0 && content[0] == '\0')
|
||||
ret = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
virCgroupBackend virCgroupV1Backend = {
|
||||
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
||||
|
||||
@ -753,6 +772,7 @@ virCgroupBackend virCgroupV1Backend = {
|
||||
.makeGroup = virCgroupV1MakeGroup,
|
||||
.remove = virCgroupV1Remove,
|
||||
.addTask = virCgroupV1AddTask,
|
||||
.hasEmptyTasks = virCgroupV1HasEmptyTasks,
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user