mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
vircgroup: introduce virCgroupV2GetBlkioIoServiced
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
11bb7f1561
commit
709260add9
@ -566,6 +566,70 @@ virCgroupV2GetBlkioWeight(virCgroupPtr group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virCgroupV2GetBlkioIoServiced(virCgroupPtr group,
|
||||||
|
long long *bytes_read,
|
||||||
|
long long *bytes_write,
|
||||||
|
long long *requests_read,
|
||||||
|
long long *requests_write)
|
||||||
|
{
|
||||||
|
long long stats_val;
|
||||||
|
VIR_AUTOFREE(char *) str1 = 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
|
||||||
|
};
|
||||||
|
|
||||||
|
*bytes_read = 0;
|
||||||
|
*bytes_write = 0;
|
||||||
|
*requests_read = 0;
|
||||||
|
*requests_write = 0;
|
||||||
|
|
||||||
|
if (virCgroupGetValueStr(group,
|
||||||
|
VIR_CGROUP_CONTROLLER_BLKIO,
|
||||||
|
"io.stat", &str1) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* sum up all entries of the same kind, from all devices */
|
||||||
|
for (i = 0; i < ARRAY_CARDINALITY(value_names); i++) {
|
||||||
|
p1 = str1;
|
||||||
|
|
||||||
|
while ((p1 = strstr(p1, value_names[i]))) {
|
||||||
|
p1 += strlen(value_names[i]);
|
||||||
|
if (virStrToLong_ll(p1, &p1, 10, &stats_val) < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Cannot parse byte '%s' stat '%s'"),
|
||||||
|
value_names[i], p1);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stats_val < 0 ||
|
||||||
|
(stats_val > 0 && *value_ptrs[i] > (LLONG_MAX - stats_val))) {
|
||||||
|
virReportError(VIR_ERR_OVERFLOW,
|
||||||
|
_("Sum of byte '%s' stat overflows"),
|
||||||
|
value_names[i]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*value_ptrs[i] += stats_val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virCgroupBackend virCgroupV2Backend = {
|
virCgroupBackend virCgroupV2Backend = {
|
||||||
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
||||||
|
|
||||||
@ -590,6 +654,7 @@ virCgroupBackend virCgroupV2Backend = {
|
|||||||
|
|
||||||
.setBlkioWeight = virCgroupV2SetBlkioWeight,
|
.setBlkioWeight = virCgroupV2SetBlkioWeight,
|
||||||
.getBlkioWeight = virCgroupV2GetBlkioWeight,
|
.getBlkioWeight = virCgroupV2GetBlkioWeight,
|
||||||
|
.getBlkioIoServiced = virCgroupV2GetBlkioIoServiced,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user