107 lines
3.3 KiB
Diff
107 lines
3.3 KiB
Diff
From e549b6a2270598ad1e736837430573fafb6a7e64 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <e549b6a2270598ad1e736837430573fafb6a7e64@dist-git>
|
|
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Date: Mon, 1 Jul 2019 17:07:33 +0200
|
|
Subject: [PATCH] vircgroup: introduce virCgroupV2GetBlkioIoDeviceServiced
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
(cherry picked from commit 93fa369df5edbf693cee472a9a8c2caa313ae2a0)
|
|
|
|
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Message-Id: <c5774ab538aab66d306032ebcc330f36d47d318a.1561993100.git.phrdina@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
---
|
|
src/util/vircgroupv2.c | 64 ++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 64 insertions(+)
|
|
|
|
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
index 000fd4c747..fcf39406e1 100644
|
|
--- a/src/util/vircgroupv2.c
|
|
+++ b/src/util/vircgroupv2.c
|
|
@@ -631,6 +631,69 @@ virCgroupV2GetBlkioIoServiced(virCgroupPtr group,
|
|
}
|
|
|
|
|
|
+static int
|
|
+virCgroupV2GetBlkioIoDeviceServiced(virCgroupPtr group,
|
|
+ const char *path,
|
|
+ long long *bytes_read,
|
|
+ long long *bytes_write,
|
|
+ long long *requests_read,
|
|
+ long long *requests_write)
|
|
+{
|
|
+ VIR_AUTOFREE(char *) str1 = NULL;
|
|
+ VIR_AUTOFREE(char *) str2 = NULL;
|
|
+ char *p1;
|
|
+ size_t i;
|
|
+
|
|
+ const char *value_names[] = {
|
|
+ "rbytes=",
|
|
+ "wbytes=",
|
|
+ "rios=",
|
|
+ "wios=",
|
|
+ };
|
|
+ long long *value_ptrs[] = {
|
|
+ bytes_read,
|
|
+ bytes_write,
|
|
+ requests_read,
|
|
+ requests_write
|
|
+ };
|
|
+
|
|
+ if (virCgroupGetValueStr(group,
|
|
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
+ "io.stat", &str1) < 0) {
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ if (!(str2 = virCgroupGetBlockDevString(path)))
|
|
+ return -1;
|
|
+
|
|
+ if (!(p1 = strstr(str1, str2))) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
+ _("Cannot find byte stats for block device '%s'"),
|
|
+ str2);
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ for (i = 0; i < ARRAY_CARDINALITY(value_names); i++) {
|
|
+ if (!(p1 = strstr(p1, value_names[i]))) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
+ _("Cannot find byte '%s' stats for block device '%s'"),
|
|
+ value_names[i], str2);
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ p1 += strlen(value_names[i]);
|
|
+ if (virStrToLong_ll(p1, &p1, 10, value_ptrs[i]) < 0) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
+ _("Cannot parse '%s' stat '%s'"),
|
|
+ value_names[i], p1);
|
|
+ return -1;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+
|
|
virCgroupBackend virCgroupV2Backend = {
|
|
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
|
|
@@ -656,6 +719,7 @@ virCgroupBackend virCgroupV2Backend = {
|
|
.setBlkioWeight = virCgroupV2SetBlkioWeight,
|
|
.getBlkioWeight = virCgroupV2GetBlkioWeight,
|
|
.getBlkioIoServiced = virCgroupV2GetBlkioIoServiced,
|
|
+ .getBlkioIoDeviceServiced = virCgroupV2GetBlkioIoDeviceServiced,
|
|
};
|
|
|
|
|
|
--
|
|
2.22.0
|
|
|