提交 57890b2a 编写于 作者: P Pavel Hrdina

vircgroup: extract virCgroupV1PathOfController

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 d6564037
......@@ -1456,27 +1456,7 @@ virCgroupPathOfController(virCgroupPtr group,
return -1;
}
if (group->controllers[controller].mountPoint == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Controller '%s' is not mounted"),
virCgroupControllerTypeToString(controller));
return -1;
}
if (group->controllers[controller].placement == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Controller '%s' is not enabled for group"),
virCgroupControllerTypeToString(controller));
return -1;
}
if (virAsprintf(path, "%s%s/%s",
group->controllers[controller].mountPoint,
group->controllers[controller].placement,
key ? key : "") < 0)
return -1;
return 0;
return group->backend->pathOfController(group, controller, key, path);
}
......
......@@ -80,6 +80,12 @@ typedef bool
typedef int
(*virCgroupGetAnyControllerCB)(virCgroupPtr group);
typedef int
(*virCgroupPathOfControllerCB)(virCgroupPtr group,
int controller,
const char *key,
char **path);
struct _virCgroupBackend {
virCgroupBackendType type;
......@@ -95,6 +101,7 @@ struct _virCgroupBackend {
virCgroupDetectControllersCB detectControllers;
virCgroupHasControllerCB hasController;
virCgroupGetAnyControllerCB getAnyController;
virCgroupPathOfControllerCB pathOfController;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
......
......@@ -506,6 +506,36 @@ virCgroupV1GetAnyController(virCgroupPtr group)
}
static int
virCgroupV1PathOfController(virCgroupPtr group,
int controller,
const char *key,
char **path)
{
if (group->controllers[controller].mountPoint == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("v1 controller '%s' is not mounted"),
virCgroupV1ControllerTypeToString(controller));
return -1;
}
if (group->controllers[controller].placement == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("v1 controller '%s' is not enabled for group"),
virCgroupV1ControllerTypeToString(controller));
return -1;
}
if (virAsprintf(path, "%s%s/%s",
group->controllers[controller].mountPoint,
group->controllers[controller].placement,
key ? key : "") < 0)
return -1;
return 0;
}
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
......@@ -520,6 +550,7 @@ virCgroupBackend virCgroupV1Backend = {
.detectControllers = virCgroupV1DetectControllers,
.hasController = virCgroupV1HasController,
.getAnyController = virCgroupV1GetAnyController,
.pathOfController = virCgroupV1PathOfController,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册