diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index d263ff8b22..3fd7b7b087 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -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] != '/') { diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index 086cfb8090..9c0bd89793 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -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; diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 269fe68f49..ba42d10d3c 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -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, };