[PATCH 2/3] cgroup: Implement blkio.weight tuning API.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Implement blkio.weight tuning API.

Signed-off-by: Gui Jianfeng <guijianfeng@xxxxxxxxxxxxxx>
---
 src/libvirt_private.syms |    2 ++
 src/util/cgroup.c        |   36 ++++++++++++++++++++++++++++++++++++
 src/util/cgroup.h        |    3 +++
 3 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2ce4bed..97b9851 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -77,6 +77,8 @@ virCgroupMounted;
 virCgroupRemove;
 virCgroupSetCpuShares;
 virCgroupSetFreezerState;
+virCgroupSetWeight;
+virCgroupGetWeight;
 virCgroupSetMemory;
 virCgroupSetMemoryHardLimit;
 virCgroupSetMemorySoftLimit;
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 309f4e9..a3d3f29 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -851,6 +851,42 @@ int virCgroupForDomain(virCgroupPtr driver ATTRIBUTE_UNUSED,
 #endif
 
 /**
+ * virCgroupSetWeight:
+ *
+ * @group: The cgroup to change io weight for
+ * @weight: The Weight for this cgroup
+ *
+ * Returns: 0 on success
+ */
+int virCgroupSetWeight(virCgroupPtr group, unsigned long weight)
+{
+    return virCgroupSetValueU64(group,
+                                VIR_CGROUP_CONTROLLER_BLKIO,
+                                "blkio.weight",
+                                weight);
+}
+
+/**
+ * virCgroupGetWeight:
+ *
+ * @group: The cgroup to get weight for
+ * @Weight: Pointer to returned weight
+ *
+ * Returns: 0 on success
+ */
+int virCgroupGetWeight(virCgroupPtr group, unsigned long *weight)
+{
+    long long unsigned int __weight;
+    int ret;
+    ret = virCgroupGetValueU64(group,
+                               VIR_CGROUP_CONTROLLER_BLKIO,
+                               "blkio.weight", &__weight);
+    if (ret == 0)
+        *weight = (unsigned long) __weight;
+    return ret;
+}
+
+/**
  * virCgroupSetMemory:
  *
  * @group: The cgroup to change memory for
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index 67b1299..99c1cfe 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -41,6 +41,9 @@ int virCgroupForDomain(virCgroupPtr driver,
 
 int virCgroupAddTask(virCgroupPtr group, pid_t pid);
 
+int virCgroupSetWeight(virCgroupPtr group, unsigned long weight);
+int virCgroupGetWeight(virCgroupPtr group, unsigned long *weight);
+
 int virCgroupSetMemory(virCgroupPtr group, unsigned long long kb);
 int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb);
 
-- 
1.7.1



--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]