|
|
c480ed |
From 39b7d11c4b75b3213054f7730887acca90f62969 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <39b7d11c4b75b3213054f7730887acca90f62969@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:07:34 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: introduce virCgroupV2(Set|Get)BlkioDeviceWeight
|
|
|
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 568f746eafce1194dc10cc91a41c91bf08fadd53)
|
|
|
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: <5dd74b70bcec7b3cd7186b53e76857dcf1d21c6f.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroupv2.c | 51 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
c480ed |
1 file changed, 51 insertions(+)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
c480ed |
index fcf39406e1..86b3fc127a 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv2.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv2.c
|
|
|
c480ed |
@@ -694,6 +694,55 @@ virCgroupV2GetBlkioIoDeviceServiced(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2SetBlkioDeviceWeight(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned int weight)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) str = NULL;
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) blkstr = NULL;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!(blkstr = virCgroupGetBlockDevString(path)))
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virAsprintf(&str, "%s%d", blkstr, weight) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return virCgroupSetValueStr(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ "io.weight",
|
|
|
c480ed |
+ str);
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2GetBlkioDeviceWeight(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned int *weight)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) str = NULL;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virCgroupGetValueForBlkDev(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ "io.weight",
|
|
|
c480ed |
+ path,
|
|
|
c480ed |
+ &str) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!str) {
|
|
|
c480ed |
+ *weight = 0;
|
|
|
c480ed |
+ } else if (virStrToLong_ui(str, NULL, 10, weight) < 0) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
+ _("Unable to parse '%s' as an integer"),
|
|
|
c480ed |
+ str);
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -720,6 +769,8 @@ virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.getBlkioWeight = virCgroupV2GetBlkioWeight,
|
|
|
c480ed |
.getBlkioIoServiced = virCgroupV2GetBlkioIoServiced,
|
|
|
c480ed |
.getBlkioIoDeviceServiced = virCgroupV2GetBlkioIoDeviceServiced,
|
|
|
c480ed |
+ .setBlkioDeviceWeight = virCgroupV2SetBlkioDeviceWeight,
|
|
|
c480ed |
+ .getBlkioDeviceWeight = virCgroupV2GetBlkioDeviceWeight,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|