mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
vircgroup: extract virCgroupV1CopyMounts
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
61629d5be3
commit
47941ea7f5
@ -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
|
static int
|
||||||
virCgroupResolveMountLink(const char *mntDir,
|
virCgroupResolveMountLink(const char *mntDir,
|
||||||
const char *typeStr,
|
const char *typeStr,
|
||||||
@ -649,7 +628,7 @@ virCgroupDetect(virCgroupPtr group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
if (virCgroupCopyMounts(group, parent) < 0)
|
if (group->backend->copyMounts(group, parent) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
if (virCgroupDetectMounts(group) < 0)
|
if (virCgroupDetectMounts(group) < 0)
|
||||||
|
@ -41,12 +41,17 @@ typedef bool
|
|||||||
const char *drivername,
|
const char *drivername,
|
||||||
const char *machinename);
|
const char *machinename);
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(*virCgroupCopyMountsCB)(virCgroupPtr group,
|
||||||
|
virCgroupPtr parent);
|
||||||
|
|
||||||
struct _virCgroupBackend {
|
struct _virCgroupBackend {
|
||||||
virCgroupBackendType type;
|
virCgroupBackendType type;
|
||||||
|
|
||||||
/* Mandatory callbacks that need to be implemented for every backend. */
|
/* Mandatory callbacks that need to be implemented for every backend. */
|
||||||
virCgroupAvailableCB available;
|
virCgroupAvailableCB available;
|
||||||
virCgroupValidateMachineGroupCB validateMachineGroup;
|
virCgroupValidateMachineGroupCB validateMachineGroup;
|
||||||
|
virCgroupCopyMountsCB copyMounts;
|
||||||
};
|
};
|
||||||
typedef struct _virCgroupBackend virCgroupBackend;
|
typedef struct _virCgroupBackend virCgroupBackend;
|
||||||
typedef virCgroupBackend *virCgroupBackendPtr;
|
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 = {
|
virCgroupBackend virCgroupV1Backend = {
|
||||||
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
||||||
|
|
||||||
.available = virCgroupV1Available,
|
.available = virCgroupV1Available,
|
||||||
.validateMachineGroup = virCgroupV1ValidateMachineGroup,
|
.validateMachineGroup = virCgroupV1ValidateMachineGroup,
|
||||||
|
.copyMounts = virCgroupV1CopyMounts,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user