On 10/02/2018 10:44 AM, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina(a)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 30c400f129..eff410258c 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -657,6 +657,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 %sstats for block device
'%s'"),
+ value_names[i], str2);
+ return -1;
+ }
+
+ if (virStrToLong_ll(p1 + strlen(value_names[i]), &p1,
+ 10, value_ptrs[i]) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Cannot parse %sstat '%s'"),
+ value_names[i], p1 + strlen(value_names[i]));
Same comment here as in previous patch.
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
virCgroupBackend virCgroupV2Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V2,
@@ -682,6 +745,7 @@ virCgroupBackend virCgroupV2Backend = {
.setBlkioWeight = virCgroupV2SetBlkioWeight,
.getBlkioWeight = virCgroupV2GetBlkioWeight,
.getBlkioIoServiced = virCgroupV2GetBlkioIoServiced,
+ .getBlkioIoDeviceServiced = virCgroupV2GetBlkioIoDeviceServiced,
};
Otherwise looking good.
Michal