int
virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight)
{
- return virCgroupSetValueU64(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "blkio.weight",
- weight);
+ VIR_CGROUP_BACKEND_CALL(group, setBlkioWeight, -1, weight);
}
int
virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight)
{
- unsigned long long tmp;
- int ret;
- ret = virCgroupGetValueU64(group,
- VIR_CGROUP_CONTROLLER_BLKIO,
- "blkio.weight", &tmp);
- if (ret == 0)
- *weight = tmp;
- return ret;
+ VIR_CGROUP_BACKEND_CALL(group, getBlkioWeight, -1, weight);
}
/**
gid_t gid,
int controllers);
+typedef int
+(*virCgroupSetBlkioWeightCB)(virCgroupPtr group,
+ unsigned int weight);
+
+typedef int
+(*virCgroupGetBlkioWeightCB)(virCgroupPtr group,
+ unsigned int *weight);
+
struct _virCgroupBackend {
virCgroupBackendType type;
virCgroupHasEmptyTasksCB hasEmptyTasks;
virCgroupBindMountCB bindMount;
virCgroupSetOwnerCB setOwner;
+
+ /* Optional cgroup controller specific callbacks. */
+ virCgroupSetBlkioWeightCB setBlkioWeight;
+ virCgroupGetBlkioWeightCB getBlkioWeight;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
virCgroupBackendPtr *
virCgroupBackendGetAll(void);
+# define VIR_CGROUP_BACKEND_CALL(group, func, ret, ...) \
+ if (!group->backend->func) { \
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, \
+ _("operation '%s' not supported"), #func); \
+ return ret; \
+ } \
+ return group->backend->func(group, ##__VA_ARGS__);
+
#endif /* __VIR_CGROUP_BACKEND_H__ */
}
+static int
+virCgroupV1SetBlkioWeight(virCgroupPtr group,
+ unsigned int weight)
+{
+ return virCgroupSetValueU64(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "blkio.weight",
+ weight);
+}
+
+
+static int
+virCgroupV1GetBlkioWeight(virCgroupPtr group,
+ unsigned int *weight)
+{
+ unsigned long long tmp;
+ int ret;
+ ret = virCgroupGetValueU64(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ "blkio.weight", &tmp);
+ if (ret == 0)
+ *weight = tmp;
+ return ret;
+}
+
+
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
.hasEmptyTasks = virCgroupV1HasEmptyTasks,
.bindMount = virCgroupV1BindMount,
.setOwner = virCgroupV1SetOwner,
+
+ .setBlkioWeight = virCgroupV1SetBlkioWeight,
+ .getBlkioWeight = virCgroupV1GetBlkioWeight,
};