提交 12264c12 编写于 作者: P Pavel Hrdina

vircgroup: extract virCgroupV1StealPlacement

Reviewed-by: NFabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 b549a66e
...@@ -1319,8 +1319,7 @@ virCgroupNewMachineSystemd(const char *name, ...@@ -1319,8 +1319,7 @@ virCgroupNewMachineSystemd(const char *name,
&init) < 0) &init) < 0)
return -1; return -1;
path = init->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement; path = init->backend->stealPlacement(init);
init->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement = NULL;
virCgroupFree(&init); virCgroupFree(&init);
if (!path || STREQ(path, "/") || path[0] != '/') { if (!path || STREQ(path, "/") || path[0] != '/') {
......
...@@ -66,6 +66,9 @@ typedef int ...@@ -66,6 +66,9 @@ typedef int
(*virCgroupValidatePlacementCB)(virCgroupPtr group, (*virCgroupValidatePlacementCB)(virCgroupPtr group,
pid_t pid); pid_t pid);
typedef char *
(*virCgroupStealPlacementCB)(virCgroupPtr group);
struct _virCgroupBackend { struct _virCgroupBackend {
virCgroupBackendType type; virCgroupBackendType type;
...@@ -77,6 +80,7 @@ struct _virCgroupBackend { ...@@ -77,6 +80,7 @@ struct _virCgroupBackend {
virCgroupDetectMountsCB detectMounts; virCgroupDetectMountsCB detectMounts;
virCgroupDetectPlacementCB detectPlacement; virCgroupDetectPlacementCB detectPlacement;
virCgroupValidatePlacementCB validatePlacement; virCgroupValidatePlacementCB validatePlacement;
virCgroupStealPlacementCB stealPlacement;
}; };
typedef struct _virCgroupBackend virCgroupBackend; typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr; typedef virCgroupBackend *virCgroupBackendPtr;
......
...@@ -402,6 +402,17 @@ virCgroupV1ValidatePlacement(virCgroupPtr group, ...@@ -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 = { virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1, .type = VIR_CGROUP_BACKEND_TYPE_V1,
...@@ -412,6 +423,7 @@ virCgroupBackend virCgroupV1Backend = { ...@@ -412,6 +423,7 @@ virCgroupBackend virCgroupV1Backend = {
.detectMounts = virCgroupV1DetectMounts, .detectMounts = virCgroupV1DetectMounts,
.detectPlacement = virCgroupV1DetectPlacement, .detectPlacement = virCgroupV1DetectPlacement,
.validatePlacement = virCgroupV1ValidatePlacement, .validatePlacement = virCgroupV1ValidatePlacement,
.stealPlacement = virCgroupV1StealPlacement,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册