int
-virCgroupGetValueForBlkDev(virCgroupPtr group,
- int controller,
- const char *key,
+virCgroupGetValueForBlkDev(const char *str,
const char *path,
char **value)
{
VIR_AUTOFREE(char *) prefix = NULL;
- VIR_AUTOFREE(char *) str = NULL;
char **lines = NULL;
int ret = -1;
- if (virCgroupGetValueStr(group, controller, key, &str) < 0)
- goto error;
-
if (!(prefix = virCgroupGetBlockDevString(path)))
goto error;
char *virCgroupGetBlockDevString(const char *path);
-int virCgroupGetValueForBlkDev(virCgroupPtr group,
- int controller,
- const char *key,
- const char *path,
+int virCgroupGetValueForBlkDev(const char *str,
+ const char *devPath,
char **value);
int virCgroupNew(pid_t pid,
unsigned int *weight)
{
VIR_AUTOFREE(char *) str = NULL;
+ VIR_AUTOFREE(char *) value = NULL;
- if (virCgroupGetValueForBlkDev(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "blkio.weight_device",
- path,
- &str) < 0)
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "blkio.weight_device",
+ &value) < 0) {
+ return -1;
+ }
+
+ if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
return -1;
if (!str) {
unsigned int *riops)
{
VIR_AUTOFREE(char *) str = NULL;
+ VIR_AUTOFREE(char *) value = NULL;
- if (virCgroupGetValueForBlkDev(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "blkio.throttle.read_iops_device",
- path,
- &str) < 0)
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "blkio.throttle.read_iops_device",
+ &value) < 0) {
+ return -1;
+ }
+
+ if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
return -1;
if (!str) {
unsigned int *wiops)
{
VIR_AUTOFREE(char *) str = NULL;
+ VIR_AUTOFREE(char *) value = NULL;
- if (virCgroupGetValueForBlkDev(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "blkio.throttle.write_iops_device",
- path,
- &str) < 0)
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "blkio.throttle.write_iops_device",
+ &value) < 0) {
+ return -1;
+ }
+
+ if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
return -1;
if (!str) {
unsigned long long *rbps)
{
VIR_AUTOFREE(char *) str = NULL;
+ VIR_AUTOFREE(char *) value = NULL;
+
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "blkio.throttle.read_bps_device",
+ &value) < 0) {
+ return -1;
+ }
- if (virCgroupGetValueForBlkDev(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "blkio.throttle.read_bps_device",
- path,
- &str) < 0)
+ if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
return -1;
if (!str) {
unsigned long long *wbps)
{
VIR_AUTOFREE(char *) str = NULL;
+ VIR_AUTOFREE(char *) value = NULL;
+
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "blkio.throttle.write_bps_device",
+ &value) < 0) {
+ return -1;
+ }
- if (virCgroupGetValueForBlkDev(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "blkio.throttle.write_bps_device",
- path,
- &str) < 0)
+ if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
return -1;
if (!str) {
unsigned int *weight)
{
VIR_AUTOFREE(char *) str = NULL;
+ VIR_AUTOFREE(char *) value = NULL;
- if (virCgroupGetValueForBlkDev(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "io.weight",
- path,
- &str) < 0) {
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "io.weight",
+ &value) < 0) {
return -1;
}
+ if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
+ return -1;
+
if (!str) {
*weight = 0;
} else if (virStrToLong_ui(str, NULL, 10, weight) < 0) {
unsigned int *riops)
{
VIR_AUTOFREE(char *) str = NULL;
+ VIR_AUTOFREE(char *) value = NULL;
const char *name = "riops=";
char *tmp;
- if (virCgroupGetValueForBlkDev(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "io.max",
- path,
- &str) < 0) {
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "io.max",
+ &value) < 0) {
return -1;
}
+ if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
+ return -1;
+
if (!str) {
*riops = 0;
} else {
unsigned int *wiops)
{
VIR_AUTOFREE(char *) str = NULL;
+ VIR_AUTOFREE(char *) value = NULL;
const char *name = "wiops=";
char *tmp;
- if (virCgroupGetValueForBlkDev(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "io.max",
- path,
- &str) < 0) {
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "io.max",
+ &value) < 0) {
return -1;
}
+ if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
+ return -1;
+
if (!str) {
*wiops = 0;
} else {
unsigned long long *rbps)
{
VIR_AUTOFREE(char *) str = NULL;
+ VIR_AUTOFREE(char *) value = NULL;
const char *name = "rbps=";
char *tmp;
- if (virCgroupGetValueForBlkDev(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "io.max",
- path,
- &str) < 0) {
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "io.max",
+ &value) < 0) {
return -1;
}
+ if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
+ return -1;
+
if (!str) {
*rbps = 0;
} else {
unsigned long long *wbps)
{
VIR_AUTOFREE(char *) str = NULL;
+ VIR_AUTOFREE(char *) value = NULL;
const char *name = "wbps=";
char *tmp;
- if (virCgroupGetValueForBlkDev(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "io.max",
- path,
- &str) < 0) {
+ if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "io.max",
+ &value) < 0) {
return -1;
}
+ if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
+ return -1;
+
if (!str) {
*wbps = 0;
} else {