mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceReadIops
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
8f50f9ca24
commit
dfaf5c6de1
@ -1381,19 +1381,7 @@ virCgroupSetBlkioDeviceReadIops(virCgroupPtr group,
|
|||||||
const char *path,
|
const char *path,
|
||||||
unsigned int riops)
|
unsigned int riops)
|
||||||
{
|
{
|
||||||
VIR_AUTOFREE(char *) str = NULL;
|
VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceReadIops, -1, path, riops);
|
||||||
VIR_AUTOFREE(char *) blkstr = NULL;
|
|
||||||
|
|
||||||
if (!(blkstr = virCgroupGetBlockDevString(path)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (virAsprintf(&str, "%s%u", blkstr, riops) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return virCgroupSetValueStr(group,
|
|
||||||
VIR_CGROUP_CONTROLLER_BLKIO,
|
|
||||||
"blkio.throttle.read_iops_device",
|
|
||||||
str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1513,25 +1501,7 @@ virCgroupGetBlkioDeviceReadIops(virCgroupPtr group,
|
|||||||
const char *path,
|
const char *path,
|
||||||
unsigned int *riops)
|
unsigned int *riops)
|
||||||
{
|
{
|
||||||
VIR_AUTOFREE(char *) str = NULL;
|
VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceReadIops, -1, path, riops);
|
||||||
|
|
||||||
if (virCgroupGetValueForBlkDev(group,
|
|
||||||
VIR_CGROUP_CONTROLLER_BLKIO,
|
|
||||||
"blkio.throttle.read_iops_device",
|
|
||||||
path,
|
|
||||||
&str) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!str) {
|
|
||||||
*riops = 0;
|
|
||||||
} else if (virStrToLong_ui(str, NULL, 10, riops) < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Unable to parse '%s' as an integer"),
|
|
||||||
str);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,6 +170,16 @@ typedef int
|
|||||||
const char *path,
|
const char *path,
|
||||||
unsigned int *weight);
|
unsigned int *weight);
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(*virCgroupSetBlkioDeviceReadIopsCB)(virCgroupPtr group,
|
||||||
|
const char *path,
|
||||||
|
unsigned int riops);
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(*virCgroupGetBlkioDeviceReadIopsCB)(virCgroupPtr group,
|
||||||
|
const char *path,
|
||||||
|
unsigned int *riops);
|
||||||
|
|
||||||
struct _virCgroupBackend {
|
struct _virCgroupBackend {
|
||||||
virCgroupBackendType type;
|
virCgroupBackendType type;
|
||||||
|
|
||||||
@ -200,6 +210,8 @@ struct _virCgroupBackend {
|
|||||||
virCgroupGetBlkioIoDeviceServicedCB getBlkioIoDeviceServiced;
|
virCgroupGetBlkioIoDeviceServicedCB getBlkioIoDeviceServiced;
|
||||||
virCgroupSetBlkioDeviceWeightCB setBlkioDeviceWeight;
|
virCgroupSetBlkioDeviceWeightCB setBlkioDeviceWeight;
|
||||||
virCgroupGetBlkioDeviceWeightCB getBlkioDeviceWeight;
|
virCgroupGetBlkioDeviceWeightCB getBlkioDeviceWeight;
|
||||||
|
virCgroupSetBlkioDeviceReadIopsCB setBlkioDeviceReadIops;
|
||||||
|
virCgroupGetBlkioDeviceReadIopsCB getBlkioDeviceReadIops;
|
||||||
};
|
};
|
||||||
typedef struct _virCgroupBackend virCgroupBackend;
|
typedef struct _virCgroupBackend virCgroupBackend;
|
||||||
typedef virCgroupBackend *virCgroupBackendPtr;
|
typedef virCgroupBackend *virCgroupBackendPtr;
|
||||||
|
@ -1185,6 +1185,54 @@ virCgroupV1GetBlkioDeviceWeight(virCgroupPtr group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virCgroupV1SetBlkioDeviceReadIops(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 (virAsprintf(&str, "%s%u", blkstr, riops) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return virCgroupSetValueStr(group,
|
||||||
|
VIR_CGROUP_CONTROLLER_BLKIO,
|
||||||
|
"blkio.throttle.read_iops_device",
|
||||||
|
str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virCgroupV1GetBlkioDeviceReadIops(virCgroupPtr group,
|
||||||
|
const char *path,
|
||||||
|
unsigned int *riops)
|
||||||
|
{
|
||||||
|
VIR_AUTOFREE(char *) str = NULL;
|
||||||
|
|
||||||
|
if (virCgroupGetValueForBlkDev(group,
|
||||||
|
VIR_CGROUP_CONTROLLER_BLKIO,
|
||||||
|
"blkio.throttle.read_iops_device",
|
||||||
|
path,
|
||||||
|
&str) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!str) {
|
||||||
|
*riops = 0;
|
||||||
|
} else if (virStrToLong_ui(str, NULL, 10, riops) < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Unable to parse '%s' as an integer"),
|
||||||
|
str);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virCgroupBackend virCgroupV1Backend = {
|
virCgroupBackend virCgroupV1Backend = {
|
||||||
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
||||||
|
|
||||||
@ -1213,6 +1261,8 @@ virCgroupBackend virCgroupV1Backend = {
|
|||||||
.getBlkioIoDeviceServiced = virCgroupV1GetBlkioIoDeviceServiced,
|
.getBlkioIoDeviceServiced = virCgroupV1GetBlkioIoDeviceServiced,
|
||||||
.setBlkioDeviceWeight = virCgroupV1SetBlkioDeviceWeight,
|
.setBlkioDeviceWeight = virCgroupV1SetBlkioDeviceWeight,
|
||||||
.getBlkioDeviceWeight = virCgroupV1GetBlkioDeviceWeight,
|
.getBlkioDeviceWeight = virCgroupV1GetBlkioDeviceWeight,
|
||||||
|
.setBlkioDeviceReadIops = virCgroupV1SetBlkioDeviceReadIops,
|
||||||
|
.getBlkioDeviceReadIops = virCgroupV1GetBlkioDeviceReadIops,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user