Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
src/util/vircgroup.c | 13 +------------
src/util/vircgroupbackend.h | 5 +++++
src/util/vircgroupv1.c | 20 ++++++++++++++++++++
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 5dd736930b..f5ae23836f 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -3467,18 +3467,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
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 4661d82132..1964a48ff0 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -114,6 +114,10 @@ typedef int
pid_t pid,
unsigned int flags);
+typedef int
+(*virCgroupHasEmptyTasksCB)(virCgroupPtr cgroup,
+ int controller);
+
struct _virCgroupBackend {
virCgroupBackendType type;
@@ -133,6 +137,7 @@ struct _virCgroupBackend {
virCgroupMakeGroupCB makeGroup;
virCgroupRemoveCB remove;
virCgroupAddTaskCB addTask;
+ virCgroupHasEmptyTasksCB hasEmptyTasks;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index c9f6fd925a..57bcb6a685 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -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,
};
--
2.17.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list