|
|
c480ed |
From b5ce0e989440de2c3d4bfb8b325d85ca25ace4ca Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <b5ce0e989440de2c3d4bfb8b325d85ca25ace4ca@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:07:38 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: introduce virCgroupV2(Set|Get)BlkioDeviceWriteBps
|
|
|
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 91756fb64a370e48a6bcdd1973126a8c7a36e4f7)
|
|
|
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: <3d70ebb985fa8132e45ba12bbb8e78ac80557a78.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroupv2.c | 70 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
c480ed |
1 file changed, 70 insertions(+)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
c480ed |
index b303e9cb10..52d31925c2 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv2.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv2.c
|
|
|
c480ed |
@@ -947,6 +947,74 @@ virCgroupV2GetBlkioDeviceReadBps(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2SetBlkioDeviceWriteBps(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned long long wbps)
|
|
|
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 (wbps == 0) {
|
|
|
c480ed |
+ if (virAsprintf(&str, "%swbps=max", blkstr) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ } else {
|
|
|
c480ed |
+ if (virAsprintf(&str, "%swbps=%llu", blkstr, wbps) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return virCgroupSetValueStr(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ "io.max",
|
|
|
c480ed |
+ str);
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned long long *wbps)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) str = NULL;
|
|
|
c480ed |
+ const char *name = "wbps=";
|
|
|
c480ed |
+ char *tmp;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virCgroupGetValueForBlkDev(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ "io.max",
|
|
|
c480ed |
+ path,
|
|
|
c480ed |
+ &str) < 0) {
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!str) {
|
|
|
c480ed |
+ *wbps = 0;
|
|
|
c480ed |
+ } else {
|
|
|
c480ed |
+ if (!(tmp = strstr(str, name))) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
+ _("Unable to find '%s' limit for block device '%s'"),
|
|
|
c480ed |
+ name, path);
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ tmp += strlen(name);
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (STREQLEN(tmp, "max", 3)) {
|
|
|
c480ed |
+ *wbps = 0;
|
|
|
c480ed |
+ } else if (virStrToLong_ull(tmp, NULL, 10, wbps) < 0) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
+ _("Unable to parse '%s' as an integer"),
|
|
|
c480ed |
+ str);
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -981,6 +1049,8 @@ virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.getBlkioDeviceWriteIops = virCgroupV2GetBlkioDeviceWriteIops,
|
|
|
c480ed |
.setBlkioDeviceReadBps = virCgroupV2SetBlkioDeviceReadBps,
|
|
|
c480ed |
.getBlkioDeviceReadBps = virCgroupV2GetBlkioDeviceReadBps,
|
|
|
c480ed |
+ .setBlkioDeviceWriteBps = virCgroupV2SetBlkioDeviceWriteBps,
|
|
|
c480ed |
+ .getBlkioDeviceWriteBps = virCgroupV2GetBlkioDeviceWriteBps,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|