Pablo Greco 40546a
From 40a3ab5f35bb847ae210160b5bcb2b3ab8990e5a Mon Sep 17 00:00:00 2001
Pablo Greco 40546a
Message-Id: <40a3ab5f35bb847ae210160b5bcb2b3ab8990e5a@dist-git>
Pablo Greco 40546a
From: Pavel Hrdina <phrdina@redhat.com>
Pablo Greco 40546a
Date: Mon, 1 Jul 2019 17:07:28 +0200
Pablo Greco 40546a
Subject: [PATCH] vircgroup: introduce virCgroupV2HasEmptyTasks
Pablo Greco 40546a
MIME-Version: 1.0
Pablo Greco 40546a
Content-Type: text/plain; charset=UTF-8
Pablo Greco 40546a
Content-Transfer-Encoding: 8bit
Pablo Greco 40546a
Pablo Greco 40546a
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Pablo Greco 40546a
(cherry picked from commit 38411bb831a8c5086145b9781168349bc64fbc25)
Pablo Greco 40546a
Pablo Greco 40546a
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
Pablo Greco 40546a
Pablo Greco 40546a
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Pablo Greco 40546a
Message-Id: <36bb2bd62faa6528de46da822d026f67be9f6d16.1561993100.git.phrdina@redhat.com>
Pablo Greco 40546a
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Pablo Greco 40546a
---
Pablo Greco 40546a
 src/util/vircgroupv2.c | 17 +++++++++++++++++
Pablo Greco 40546a
 1 file changed, 17 insertions(+)
Pablo Greco 40546a
Pablo Greco 40546a
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
Pablo Greco 40546a
index 6ffb5ce786..074e6ec110 100644
Pablo Greco 40546a
--- a/src/util/vircgroupv2.c
Pablo Greco 40546a
+++ b/src/util/vircgroupv2.c
Pablo Greco 40546a
@@ -446,6 +446,22 @@ virCgroupV2AddTask(virCgroupPtr group,
Pablo Greco 40546a
 }
Pablo Greco 40546a
 
Pablo Greco 40546a
 
Pablo Greco 40546a
+static int
Pablo Greco 40546a
+virCgroupV2HasEmptyTasks(virCgroupPtr cgroup,
Pablo Greco 40546a
+                         int controller)
Pablo Greco 40546a
+{
Pablo Greco 40546a
+    int ret = -1;
Pablo Greco 40546a
+    VIR_AUTOFREE(char *) content = NULL;
Pablo Greco 40546a
+
Pablo Greco 40546a
+    ret = virCgroupGetValueStr(cgroup, controller, "cgroup.procs", &content);
Pablo Greco 40546a
+
Pablo Greco 40546a
+    if (ret == 0 && content[0] == '\0')
Pablo Greco 40546a
+        ret = 1;
Pablo Greco 40546a
+
Pablo Greco 40546a
+    return ret;
Pablo Greco 40546a
+}
Pablo Greco 40546a
+
Pablo Greco 40546a
+
Pablo Greco 40546a
 virCgroupBackend virCgroupV2Backend = {
Pablo Greco 40546a
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
Pablo Greco 40546a
 
Pablo Greco 40546a
@@ -464,6 +480,7 @@ virCgroupBackend virCgroupV2Backend = {
Pablo Greco 40546a
     .makeGroup = virCgroupV2MakeGroup,
Pablo Greco 40546a
     .remove = virCgroupV2Remove,
Pablo Greco 40546a
     .addTask = virCgroupV2AddTask,
Pablo Greco 40546a
+    .hasEmptyTasks = virCgroupV2HasEmptyTasks,
Pablo Greco 40546a
 };
Pablo Greco 40546a
 
Pablo Greco 40546a
 
Pablo Greco 40546a
-- 
Pablo Greco 40546a
2.22.0
Pablo Greco 40546a