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