-- 
Best regards 
Eli

天涯无处不重逢
a leaf duckweed belongs to the sea, where not to meet in life 
Sent with Sparrow

On Tuesday, 21 February 2017 at 4:54 AM, Marcelo Tosatti wrote:

Can you explain how the resource leak can happen?

1. libvirtd creates a qemu process and create a resctrl directory for it, add it’s pids to tasks
2. stop libvirtd or it’s down.
3. qemu process, and tasks file is empty now.
4. libvirt restart, well, the resctrl directory should be deleted as qemu process gone.
Why it is not possible to maintain that information inside libvirt
itself?

This is not for cleanup purposes, since on VM shutdown the resctrlfs 
directories are properly removed:
/* Remove the Domain from sysfs, this should only success no pids in
* tasks
* of a partition.
*/
static
int virResCtrlRemoveDomain(const char *name)
{
char *path = NULL;
int rc = 0;
if ((rc = virAsprintf(&path, "%s/%s", RESCTRL_DIR, name)) < 0)
return rc;
rc = rmdir(path);
VIR_FREE(path);
return rc;
}
Should not write to other directories 'tasks' file.

Other Apps can have a lock to resctrl before it write tasks to prevent libvirtd remove empty task directory.

Well then libvirt will never be able to change resctrl filesystem?
no, Apps only grant lock when it creates new cache allocation, should release the lock after adding the app’s pid to tasks.