提交 47941ea7 编写于 作者: P Pavel Hrdina

vircgroup: extract virCgroupV1CopyMounts

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 61629d5b
......@@ -231,27 +231,6 @@ virCgroupPartitionEscape(char **path)
}
static int
virCgroupCopyMounts(virCgroupPtr group,
virCgroupPtr parent)
{
size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
if (!parent->controllers[i].mountPoint)
continue;
if (VIR_STRDUP(group->controllers[i].mountPoint,
parent->controllers[i].mountPoint) < 0)
return -1;
if (VIR_STRDUP(group->controllers[i].linkPoint,
parent->controllers[i].linkPoint) < 0)
return -1;
}
return 0;
}
static int
virCgroupResolveMountLink(const char *mntDir,
const char *typeStr,
......@@ -649,7 +628,7 @@ virCgroupDetect(virCgroupPtr group,
}
if (parent) {
if (virCgroupCopyMounts(group, parent) < 0)
if (group->backend->copyMounts(group, parent) < 0)
return -1;
} else {
if (virCgroupDetectMounts(group) < 0)
......
......@@ -41,12 +41,17 @@ typedef bool
const char *drivername,
const char *machinename);
typedef int
(*virCgroupCopyMountsCB)(virCgroupPtr group,
virCgroupPtr parent);
struct _virCgroupBackend {
virCgroupBackendType type;
/* Mandatory callbacks that need to be implemented for every backend. */
virCgroupAvailableCB available;
virCgroupValidateMachineGroupCB validateMachineGroup;
virCgroupCopyMountsCB copyMounts;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
......
......@@ -159,11 +159,33 @@ virCgroupV1ValidateMachineGroup(virCgroupPtr group,
}
static int
virCgroupV1CopyMounts(virCgroupPtr group,
virCgroupPtr parent)
{
size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
if (!parent->controllers[i].mountPoint)
continue;
if (VIR_STRDUP(group->controllers[i].mountPoint,
parent->controllers[i].mountPoint) < 0)
return -1;
if (VIR_STRDUP(group->controllers[i].linkPoint,
parent->controllers[i].linkPoint) < 0)
return -1;
}
return 0;
}
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
.available = virCgroupV1Available,
.validateMachineGroup = virCgroupV1ValidateMachineGroup,
.copyMounts = virCgroupV1CopyMounts,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册