mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
vircgroup: introduce virCgroupV2(Set|Get)BlkioDeviceReadIops
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
568f746eaf
commit
862f630825
@ -742,6 +742,74 @@ virCgroupV2GetBlkioDeviceWeight(virCgroupPtr group,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virCgroupV2SetBlkioDeviceReadIops(virCgroupPtr group,
|
||||
const char *path,
|
||||
unsigned int riops)
|
||||
{
|
||||
VIR_AUTOFREE(char *) str = NULL;
|
||||
VIR_AUTOFREE(char *) blkstr = NULL;
|
||||
|
||||
if (!(blkstr = virCgroupGetBlockDevString(path)))
|
||||
return -1;
|
||||
|
||||
if (riops == 0) {
|
||||
if (virAsprintf(&str, "%sriops=max", blkstr) < 0)
|
||||
return -1;
|
||||
} else {
|
||||
if (virAsprintf(&str, "%sriops=%u", blkstr, riops) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return virCgroupSetValueStr(group,
|
||||
VIR_CGROUP_CONTROLLER_BLKIO,
|
||||
"io.max",
|
||||
str);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virCgroupV2GetBlkioDeviceReadIops(virCgroupPtr group,
|
||||
const char *path,
|
||||
unsigned int *riops)
|
||||
{
|
||||
VIR_AUTOFREE(char *) str = NULL;
|
||||
const char *name = "riops=";
|
||||
char *tmp;
|
||||
|
||||
if (virCgroupGetValueForBlkDev(group,
|
||||
VIR_CGROUP_CONTROLLER_BLKIO,
|
||||
"io.max",
|
||||
path,
|
||||
&str) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!str) {
|
||||
*riops = 0;
|
||||
} else {
|
||||
if (!(tmp = strstr(str, name))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to find '%s' limit for block device '%s'"),
|
||||
name, path);
|
||||
return -1;
|
||||
}
|
||||
tmp += strlen(name);
|
||||
|
||||
if (STREQLEN(tmp, "max", 3)) {
|
||||
*riops = 0;
|
||||
} else if (virStrToLong_ui(tmp, NULL, 10, riops) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to parse '%s' as an integer"),
|
||||
str);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virCgroupBackend virCgroupV2Backend = {
|
||||
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
||||
|
||||
@ -770,6 +838,8 @@ virCgroupBackend virCgroupV2Backend = {
|
||||
.getBlkioIoDeviceServiced = virCgroupV2GetBlkioIoDeviceServiced,
|
||||
.setBlkioDeviceWeight = virCgroupV2SetBlkioDeviceWeight,
|
||||
.getBlkioDeviceWeight = virCgroupV2GetBlkioDeviceWeight,
|
||||
.setBlkioDeviceReadIops = virCgroupV2SetBlkioDeviceReadIops,
|
||||
.getBlkioDeviceReadIops = virCgroupV2GetBlkioDeviceReadIops,
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user