|
Pablo Greco |
40546a |
From e549b6a2270598ad1e736837430573fafb6a7e64 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <e549b6a2270598ad1e736837430573fafb6a7e64@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:07:33 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: introduce virCgroupV2GetBlkioIoDeviceServiced
|
|
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 93fa369df5edbf693cee472a9a8c2caa313ae2a0)
|
|
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: <c5774ab538aab66d306032ebcc330f36d47d318a.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 | 64 ++++++++++++++++++++++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
1 file changed, 64 insertions(+)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
index 000fd4c747..fcf39406e1 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
@@ -631,6 +631,69 @@ virCgroupV2GetBlkioIoServiced(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV2GetBlkioIoDeviceServiced(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ long long *bytes_read,
|
|
Pablo Greco |
40546a |
+ long long *bytes_write,
|
|
Pablo Greco |
40546a |
+ long long *requests_read,
|
|
Pablo Greco |
40546a |
+ long long *requests_write)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) str1 = NULL;
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) str2 = NULL;
|
|
Pablo Greco |
40546a |
+ char *p1;
|
|
Pablo Greco |
40546a |
+ size_t i;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ const char *value_names[] = {
|
|
Pablo Greco |
40546a |
+ "rbytes=",
|
|
Pablo Greco |
40546a |
+ "wbytes=",
|
|
Pablo Greco |
40546a |
+ "rios=",
|
|
Pablo Greco |
40546a |
+ "wios=",
|
|
Pablo Greco |
40546a |
+ };
|
|
Pablo Greco |
40546a |
+ long long *value_ptrs[] = {
|
|
Pablo Greco |
40546a |
+ bytes_read,
|
|
Pablo Greco |
40546a |
+ bytes_write,
|
|
Pablo Greco |
40546a |
+ requests_read,
|
|
Pablo Greco |
40546a |
+ requests_write
|
|
Pablo Greco |
40546a |
+ };
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virCgroupGetValueStr(group,
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "io.stat", &str1) < 0) {
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (!(str2 = virCgroupGetBlockDevString(path)))
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (!(p1 = strstr(str1, str2))) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
Pablo Greco |
40546a |
+ _("Cannot find byte stats for block device '%s'"),
|
|
Pablo Greco |
40546a |
+ str2);
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ for (i = 0; i < ARRAY_CARDINALITY(value_names); i++) {
|
|
Pablo Greco |
40546a |
+ if (!(p1 = strstr(p1, value_names[i]))) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
Pablo Greco |
40546a |
+ _("Cannot find byte '%s' stats for block device '%s'"),
|
|
Pablo Greco |
40546a |
+ value_names[i], str2);
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ p1 += strlen(value_names[i]);
|
|
Pablo Greco |
40546a |
+ if (virStrToLong_ll(p1, &p1, 10, value_ptrs[i]) < 0) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
Pablo Greco |
40546a |
+ _("Cannot parse '%s' stat '%s'"),
|
|
Pablo Greco |
40546a |
+ value_names[i], p1);
|
|
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 |
@@ -656,6 +719,7 @@ virCgroupBackend virCgroupV2Backend = {
|
|
Pablo Greco |
40546a |
.setBlkioWeight = virCgroupV2SetBlkioWeight,
|
|
Pablo Greco |
40546a |
.getBlkioWeight = virCgroupV2GetBlkioWeight,
|
|
Pablo Greco |
40546a |
.getBlkioIoServiced = virCgroupV2GetBlkioIoServiced,
|
|
Pablo Greco |
40546a |
+ .getBlkioIoDeviceServiced = virCgroupV2GetBlkioIoDeviceServiced,
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|