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