mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
vircgroup: extract virCgroupNewDetect from virCgroupNew
The current code uses virCgroupNew() as a single point of entry and calls into virCgroupDetect() as well. Both have logic for several paths which is difficult to figure out. Extract the actually used code path from the two functions to make it obvious what's happening in this case. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
f8ca962589
commit
234769b0d5
@ -1048,7 +1048,28 @@ virCgroupNewDetect(pid_t pid,
|
|||||||
int controllers,
|
int controllers,
|
||||||
virCgroupPtr *group)
|
virCgroupPtr *group)
|
||||||
{
|
{
|
||||||
return virCgroupNew(pid, "", NULL, controllers, group);
|
g_autoptr(virCgroup) new = g_new0(virCgroup, 1);
|
||||||
|
|
||||||
|
VIR_DEBUG("pid=%lld controllers=%d group=%p",
|
||||||
|
(long long) pid, controllers, group);
|
||||||
|
|
||||||
|
if (virCgroupSetBackends(new) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virCgroupDetectMounts(new) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virCgroupDetectPlacement(new, pid, "") < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virCgroupValidatePlacement(new, pid) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virCgroupDetectControllers(new, controllers, NULL) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
*group = g_steal_pointer(&new);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user