vircgroup: extract virCgroupV1StealPlacement

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:
Pavel Hrdina 2018-08-17 12:00:29 +02:00
parent b549a66edf
commit 12264c12c8
3 changed files with 17 additions and 2 deletions

View File

@ -1319,8 +1319,7 @@ virCgroupNewMachineSystemd(const char *name,
&init) < 0)
return -1;
path = init->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement;
init->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement = NULL;
path = init->backend->stealPlacement(init);
virCgroupFree(&init);
if (!path || STREQ(path, "/") || path[0] != '/') {

View File

@ -66,6 +66,9 @@ typedef int
(*virCgroupValidatePlacementCB)(virCgroupPtr group,
pid_t pid);
typedef char *
(*virCgroupStealPlacementCB)(virCgroupPtr group);
struct _virCgroupBackend {
virCgroupBackendType type;
@ -77,6 +80,7 @@ struct _virCgroupBackend {
virCgroupDetectMountsCB detectMounts;
virCgroupDetectPlacementCB detectPlacement;
virCgroupValidatePlacementCB validatePlacement;
virCgroupStealPlacementCB stealPlacement;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;

View File

@ -402,6 +402,17 @@ virCgroupV1ValidatePlacement(virCgroupPtr group,
}
static char *
virCgroupV1StealPlacement(virCgroupPtr group)
{
char *ret = NULL;
VIR_STEAL_PTR(ret, group->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement);
return ret;
}
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
@ -412,6 +423,7 @@ virCgroupBackend virCgroupV1Backend = {
.detectMounts = virCgroupV1DetectMounts,
.detectPlacement = virCgroupV1DetectPlacement,
.validatePlacement = virCgroupV1ValidatePlacement,
.stealPlacement = virCgroupV1StealPlacement,
};