提交 6a24bd75 编写于 作者: P Pavel Hrdina

vircgroup: introduce virCgroupV2DevicesRemoveProg

We need to close our FD that we have for BPF program and map in order
to let kernel remove all resources once the cgroup is removed as well.
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 ef747499
......@@ -1722,6 +1722,7 @@ virCgroupV2DevicesAvailable;
virCgroupV2DevicesCreateProg;
virCgroupV2DevicesDetectProg;
virCgroupV2DevicesPrepareProg;
virCgroupV2DevicesRemoveProg;
# util/virclosecallbacks.h
virCloseCallbacksGet;
......
......@@ -488,6 +488,9 @@ virCgroupV2Remove(virCgroupPtr group)
if (virCgroupV2PathOfController(group, controller, "", &grppath) < 0)
return 0;
if (virCgroupV2DevicesRemoveProg(group) < 0)
return -1;
return virCgroupRemoveRecursively(grppath);
}
......
......@@ -538,6 +538,25 @@ virCgroupV2DevicesPrepareProg(virCgroupPtr group)
return 0;
}
int
virCgroupV2DevicesRemoveProg(virCgroupPtr group)
{
if (virCgroupV2DevicesDetectProg(group) < 0)
return -1;
if (group->unified.devices.progfd <= 0 && group->unified.devices.mapfd <= 0)
return 0;
if (group->unified.devices.mapfd >= 0)
VIR_FORCE_CLOSE(group->unified.devices.mapfd);
if (group->unified.devices.progfd >= 0)
VIR_FORCE_CLOSE(group->unified.devices.progfd);
return 0;
}
#else /* !HAVE_DECL_BPF_CGROUP_DEVICE */
bool
virCgroupV2DevicesAvailable(virCgroupPtr group G_GNUC_UNUSED)
......@@ -586,4 +605,11 @@ virCgroupV2DevicesPrepareProg(virCgroupPtr group G_GNUC_UNUSED)
"with this kernel"));
return -1;
}
int
virCgroupV2DevicesRemoveProg(virCgroupPtr group G_GNUC_UNUSED)
{
return 0;
}
#endif /* !HAVE_DECL_BPF_CGROUP_DEVICE */
......@@ -36,3 +36,6 @@ virCgroupV2DevicesCreateProg(virCgroupPtr group);
int
virCgroupV2DevicesPrepareProg(virCgroupPtr group);
int
virCgroupV2DevicesRemoveProg(virCgroupPtr group);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册