|
|
c480ed |
From ba7babc00b91a08c7c62858b6c34f1f0c77af0ce Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <ba7babc00b91a08c7c62858b6c34f1f0c77af0ce@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:07:31 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: introduce virCgroupV2(Set|Get)BlkioWeight
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 11bb7f1561be311b71f3899332dfabe61c55a793)
|
|
|
c480ed |
|
|
|
c480ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Message-Id: <8e485d7c092d35f80e10da00af74fd30554b43bf.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroupv2.c | 49 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
c480ed |
1 file changed, 49 insertions(+)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
c480ed |
index 27519d80e3..f7863a5690 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv2.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv2.c
|
|
|
c480ed |
@@ -521,6 +521,52 @@ virCgroupV2SetOwner(virCgroupPtr cgroup,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2SetBlkioWeight(virCgroupPtr group,
|
|
|
c480ed |
+ unsigned int weight)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) value = NULL;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virAsprintf(&value, "default %u", weight) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return virCgroupSetValueStr(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ "io.weight",
|
|
|
c480ed |
+ value);
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2GetBlkioWeight(virCgroupPtr group,
|
|
|
c480ed |
+ unsigned int *weight)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) value = NULL;
|
|
|
c480ed |
+ char *tmp;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ "io.weight", &value) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!(tmp = strstr(value, "default "))) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
c480ed |
+ _("Cannot find default io weight."));
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ tmp += strlen("default ");
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virStrToLong_ui(tmp, NULL, 10, weight) < 0) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
+ _("Unable to parse '%s' as an integer"),
|
|
|
c480ed |
+ tmp);
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -542,6 +588,9 @@ virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.hasEmptyTasks = virCgroupV2HasEmptyTasks,
|
|
|
c480ed |
.bindMount = virCgroupV2BindMount,
|
|
|
c480ed |
.setOwner = virCgroupV2SetOwner,
|
|
|
c480ed |
+
|
|
|
c480ed |
+ .setBlkioWeight = virCgroupV2SetBlkioWeight,
|
|
|
c480ed |
+ .getBlkioWeight = virCgroupV2GetBlkioWeight,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|