render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
9119d9
From e64cbebf99fab42662b0e72a44f3a5bdef69bf8d Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <e64cbebf99fab42662b0e72a44f3a5bdef69bf8d@dist-git>
9119d9
From: Martin Kletzander <mkletzan@redhat.com>
9119d9
Date: Thu, 15 Jan 2015 15:03:44 +0100
9119d9
Subject: [PATCH] util: Add function virCgroupHasEmptyTasks
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1161540
9119d9
9119d9
That function helps checking whether there's a task in that cgroup.
9119d9
9119d9
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9119d9
(cherry picked from commit 1a80b97ddfb096a21af60d63a42d1af280fb6886)
9119d9
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/libvirt_private.syms |  1 +
9119d9
 src/util/vircgroup.c     | 23 +++++++++++++++++++++++
9119d9
 src/util/vircgroup.h     |  4 +++-
9119d9
 3 files changed, 27 insertions(+), 1 deletion(-)
9119d9
9119d9
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
9119d9
index cf3c842..62f4f08 100644
9119d9
--- a/src/libvirt_private.syms
9119d9
+++ b/src/libvirt_private.syms
9119d9
@@ -1087,6 +1087,7 @@ virCgroupGetMemSwapHardLimit;
9119d9
 virCgroupGetMemSwapUsage;
9119d9
 virCgroupGetPercpuStats;
9119d9
 virCgroupHasController;
9119d9
+virCgroupHasEmptyTasks;
9119d9
 virCgroupIsolateMount;
9119d9
 virCgroupKill;
9119d9
 virCgroupKillPainfully;
9119d9
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
9119d9
index 152ef96..dbe7ee7 100644
9119d9
--- a/src/util/vircgroup.c
9119d9
+++ b/src/util/vircgroup.c
9119d9
@@ -3915,6 +3915,20 @@ virCgroupSupportsCpuBW(virCgroupPtr cgroup)
9119d9
     return ret;
9119d9
 }
9119d9
 
9119d9
+int
9119d9
+virCgroupHasEmptyTasks(virCgroupPtr cgroup, int controller)
9119d9
+{
9119d9
+    int ret = -1;
9119d9
+    char *content = NULL;
9119d9
+
9119d9
+    ret = virCgroupGetValueStr(cgroup, controller, "tasks", &content);
9119d9
+
9119d9
+    if (ret == 0 && content[0] == '\0')
9119d9
+        ret = 1;
9119d9
+
9119d9
+    VIR_FREE(content);
9119d9
+    return ret;
9119d9
+}
9119d9
 
9119d9
 #else /* !VIR_CGROUP_SUPPORTED */
9119d9
 
9119d9
@@ -4633,4 +4647,13 @@ virCgroupSetOwner(virCgroupPtr cgroup ATTRIBUTE_UNUSED,
9119d9
     return -1;
9119d9
 }
9119d9
 
9119d9
+int
9119d9
+virCgroupHasEmptyTasks(virCgroupPtr cgroup ATTRIBUTE_UNUSED,
9119d9
+                       int controller ATTRIBUTE_UNUSED)
9119d9
+{
9119d9
+    virReportSystemError(ENOSYS, "%s",
9119d9
+                         _("Control groups not supported on this platform"));
9119d9
+    return -1;
9119d9
+}
9119d9
+
9119d9
 #endif /* !VIR_CGROUP_SUPPORTED */
9119d9
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
9119d9
index 19e82d1..3dbae12 100644
9119d9
--- a/src/util/vircgroup.h
9119d9
+++ b/src/util/vircgroup.h
9119d9
@@ -1,7 +1,7 @@
9119d9
 /*
9119d9
  * vircgroup.h: methods for managing control cgroups
9119d9
  *
9119d9
- * Copyright (C) 2011-2013 Red Hat, Inc.
9119d9
+ * Copyright (C) 2011-2014 Red Hat, Inc.
9119d9
  * Copyright IBM Corp. 2008
9119d9
  *
9119d9
  * This library is free software; you can redistribute it and/or
9119d9
@@ -265,4 +265,6 @@ int virCgroupSetOwner(virCgroupPtr cgroup,
9119d9
                       gid_t gid,
9119d9
                       int controllers);
9119d9
 
9119d9
+int virCgroupHasEmptyTasks(virCgroupPtr cgroup, int controller);
9119d9
+
9119d9
 #endif /* __VIR_CGROUP_H__ */
9119d9
-- 
9119d9
2.2.1
9119d9