<div><br>
                </div>
                <div><div><br></div><div>-- </div><div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">Best regards </div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">Eli</div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">天涯无处不重逢</div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0); font-family: "Microsoft YaHei", Verdana, arial, sans-serif;">a leaf duckweed belongs to the sea, where not to meet in life </span></div></div><div>Sent with <a href="http://www.sparrowmailapp.com/?sig">Sparrow</a></div><div><br></div></div>
                 
                <p style="color: #A0A0A8;">On Monday, 20 February 2017 at 5:07 PM, Martin Kletzander wrote:</p>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
                    <span><div><div><div>On Mon, Feb 20, 2017 at 04:32:19PM +0800, Eli Qiao wrote:</div><blockquote type="cite"><div><div><br></div><div><br></div><div>--</div><div>Best regards</div><div>Eli</div><div><br></div><div>天涯无处不重逢</div><div>a leaf duckweed belongs to the sea, where not to meet in life</div><div><br></div><div>Sent with Sparrow (<a href="http://www.sparrowmailapp.com/?sig">http://www.sparrowmailapp.com/?sig</a>)</div><div><br></div><div><br></div><div>On Sunday, 19 February 2017 at 10:51 PM, Marcelo Tosatti wrote:</div><div><br></div><blockquote type="cite"><div><div><br></div><div>Hi Eli Qiao,</div><div><br></div><div>Question about removing resctrlfs directories with empty "tasks" file.</div><div><br></div><div><br></div><div>/* This domain is not created by libvirt, so we don't care</div><div>* about the tasks, add a fake one to prevent</div><div>* virResCtrlRefresh</div><div>* remove it from sysfs */</div><div>virResCtrlAddTask(p, 1);</div><div>virResCtrlAppendDomain(p);</div><div><br></div><div>/* Refresh all domains', remove the domains which has no task ids.</div><div>* This will be used after VM pause, restart, destroy etc.</div><div>*/</div><div>static int</div><div>virResCtrlRefresh(void)</div><div><br></div><div>Why are you doing this (removing directories which have no tasks in</div><div>them) ? The code should only read information from other</div><div>CAT reservations, not write to them.</div></div></blockquote><div>When a VM get shutdown, their pids will disappear from resctrl’s directory, we can check pids to see if VM get KIlled or not.</div><div><br></div><div>The reason why I would like check if tasks file empty is that: there maybe cases that libvirtd not tracking VM’s status, and the VM gone, left a empty directory with no tasks assigned, and cause resource leak.</div><div><br></div><div>I think I can refine this later, keep a pointer of ResDomain in VM’s private data and use that to destroy VM’s resctrl directory.</div><div><br></div><div>but this won’t work for exception, still resource leak happened.</div></div></blockquote><div><br></div><div>Function qemuProcessStop() will *always* be called to cleanup after VMs,</div><div>all exceptions should be taken into account, so don't worry, just do</div><div>proper cleanup.</div></div></div></span></blockquote><div>hi Martin, thanks for your reply, I am thinking if qemu process being killed while libvirtd not running? will qemuProcessStop called in such case? </div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><span><div><div><div><br></div><blockquote type="cite"><div><blockquote type="cite"><div><div>This is not for cleanup purposes, since on VM shutdown the resctrlfs</div><div>directories are properly removed:</div><div><br></div><div>/* Remove the Domain from sysfs, this should only success no pids in</div><div>* tasks</div><div>* of a partition.</div><div>*/</div><div>static</div><div>int virResCtrlRemoveDomain(const char *name)</div><div>{</div><div>char *path = NULL;</div><div>int rc = 0;</div><div><br></div><div>if ((rc = virAsprintf(&path, "%s/%s", RESCTRL_DIR, name)) < 0)</div><div>return rc;</div><div>rc = rmdir(path);</div><div>VIR_FREE(path);</div><div>return rc;</div><div>}</div><div><br></div><div>Should not write to other directories 'tasks' file.</div></div></blockquote><div><br></div><div>Other Apps can have a lock to resctrl before it write tasks to prevent libvirtd remove empty task directory.</div></div></blockquote></div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>
                    <br>
                </div>