|
Pablo Greco |
40546a |
From eca0f75e6f67ec9e445b90685143992b6929cef0 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <eca0f75e6f67ec9e445b90685143992b6929cef0@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:07:36 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: introduce virCgroupV2(Set|Get)BlkioDeviceWriteIops
|
|
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 438587033bdaf714238a98703c9efc7b0dada51f)
|
|
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: <7937bd2aa5da315f8351e3f312f5aee71b682c30.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 | 70 ++++++++++++++++++++++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
1 file changed, 70 insertions(+)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
index 8cecc43f76..1d25c0ae1f 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
@@ -811,6 +811,74 @@ virCgroupV2GetBlkioDeviceReadIops(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV2SetBlkioDeviceWriteIops(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ unsigned int wiops)
|
|
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 (wiops == 0) {
|
|
Pablo Greco |
40546a |
+ if (virAsprintf(&str, "%swiops=max", blkstr) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ } else {
|
|
Pablo Greco |
40546a |
+ if (virAsprintf(&str, "%swiops=%u", blkstr, wiops) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ return virCgroupSetValueStr(group,
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "io.max",
|
|
Pablo Greco |
40546a |
+ str);
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV2GetBlkioDeviceWriteIops(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ unsigned int *wiops)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) str = NULL;
|
|
Pablo Greco |
40546a |
+ const char *name = "wiops=";
|
|
Pablo Greco |
40546a |
+ char *tmp;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virCgroupGetValueForBlkDev(group,
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "io.max",
|
|
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 |
+ *wiops = 0;
|
|
Pablo Greco |
40546a |
+ } else {
|
|
Pablo Greco |
40546a |
+ if (!(tmp = strstr(str, name))) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
Pablo Greco |
40546a |
+ _("Unable to find '%s' limit for block device '%s'"),
|
|
Pablo Greco |
40546a |
+ name, path);
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+ tmp += strlen(name);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (STREQLEN(tmp, "max", 3)) {
|
|
Pablo Greco |
40546a |
+ *wiops = 0;
|
|
Pablo Greco |
40546a |
+ } else if (virStrToLong_ui(tmp, NULL, 10, wiops) < 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 |
+
|
|
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 |
@@ -841,6 +909,8 @@ virCgroupBackend virCgroupV2Backend = {
|
|
Pablo Greco |
40546a |
.getBlkioDeviceWeight = virCgroupV2GetBlkioDeviceWeight,
|
|
Pablo Greco |
40546a |
.setBlkioDeviceReadIops = virCgroupV2SetBlkioDeviceReadIops,
|
|
Pablo Greco |
40546a |
.getBlkioDeviceReadIops = virCgroupV2GetBlkioDeviceReadIops,
|
|
Pablo Greco |
40546a |
+ .setBlkioDeviceWriteIops = virCgroupV2SetBlkioDeviceWriteIops,
|
|
Pablo Greco |
40546a |
+ .getBlkioDeviceWriteIops = virCgroupV2GetBlkioDeviceWriteIops,
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|