mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
vircgroup: extract virCgroupV1ValidatePlacement
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
229a8b5d35
commit
b549a66edf
@ -345,36 +345,6 @@ virCgroupDetectPlacement(virCgroupPtr group,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virCgroupValidatePlacement(virCgroupPtr group,
|
||||
pid_t pid)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
||||
if (!group->controllers[i].mountPoint)
|
||||
continue;
|
||||
|
||||
if (!group->controllers[i].placement) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not find placement for controller %s at %s"),
|
||||
virCgroupControllerTypeToString(i),
|
||||
group->controllers[i].placement);
|
||||
return -1;
|
||||
}
|
||||
|
||||
VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid %lld",
|
||||
i,
|
||||
virCgroupControllerTypeToString(i),
|
||||
group->controllers[i].mountPoint,
|
||||
group->controllers[i].placement,
|
||||
(long long) pid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virCgroupDetectControllers(virCgroupPtr group,
|
||||
int controllers)
|
||||
@ -500,7 +470,7 @@ virCgroupDetect(virCgroupPtr group,
|
||||
return -1;
|
||||
|
||||
/* Check that for every mounted controller, we found our placement */
|
||||
if (virCgroupValidatePlacement(group, pid) < 0)
|
||||
if (group->backend->validatePlacement(group, pid) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -62,6 +62,10 @@ typedef int
|
||||
const char *controllers,
|
||||
const char *selfpath);
|
||||
|
||||
typedef int
|
||||
(*virCgroupValidatePlacementCB)(virCgroupPtr group,
|
||||
pid_t pid);
|
||||
|
||||
struct _virCgroupBackend {
|
||||
virCgroupBackendType type;
|
||||
|
||||
@ -72,6 +76,7 @@ struct _virCgroupBackend {
|
||||
virCgroupCopyPlacementCB copyPlacement;
|
||||
virCgroupDetectMountsCB detectMounts;
|
||||
virCgroupDetectPlacementCB detectPlacement;
|
||||
virCgroupValidatePlacementCB validatePlacement;
|
||||
};
|
||||
typedef struct _virCgroupBackend virCgroupBackend;
|
||||
typedef virCgroupBackend *virCgroupBackendPtr;
|
||||
|
@ -372,6 +372,36 @@ virCgroupV1DetectPlacement(virCgroupPtr group,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virCgroupV1ValidatePlacement(virCgroupPtr group,
|
||||
pid_t pid)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
||||
if (!group->controllers[i].mountPoint)
|
||||
continue;
|
||||
|
||||
if (!group->controllers[i].placement) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not find placement for v1 controller %s at %s"),
|
||||
virCgroupV1ControllerTypeToString(i),
|
||||
group->controllers[i].placement);
|
||||
return -1;
|
||||
}
|
||||
|
||||
VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid %lld",
|
||||
i,
|
||||
virCgroupV1ControllerTypeToString(i),
|
||||
group->controllers[i].mountPoint,
|
||||
group->controllers[i].placement,
|
||||
(long long) pid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virCgroupBackend virCgroupV1Backend = {
|
||||
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
||||
|
||||
@ -381,6 +411,7 @@ virCgroupBackend virCgroupV1Backend = {
|
||||
.copyPlacement = virCgroupV1CopyPlacement,
|
||||
.detectMounts = virCgroupV1DetectMounts,
|
||||
.detectPlacement = virCgroupV1DetectPlacement,
|
||||
.validatePlacement = virCgroupV1ValidatePlacement,
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user