Re: "I have been thinking about the issue of restarting libvirtd in del. Yes, it is a potential problem. But I can not catch a good solution for it. 
After all, I think the solution in current code is ok to me. It will be ignored if restart libvirtd fail. But we can get the error message."

It's not just about it being "potential problem", in my experience &#95;&#95;del&#95;&#95;() related problems are very difficult to to debug (assuming not familiar with problem code).  Reason is because it functionality is hidden inside &#95;&#95;del&#95;&#95; which should only have limited scope (sometimes restart libvirtd, but not 100% always, even for TCP).  The behavior of &#95;&#95;del&#95;&#95;() is operations may not happen at the time you think (they happen at GC time, not del time) or may not happen at all (if sys.exit() happens before GC)

Can't user/test of these classes simply call close_session() and conn_finish() manually, before &#95;&#95;del&#95;&#95;() can happen?  It is a small amount of work to ask from test, but it will make code-path obvious to any reader.  I just do not think it is good reason to 'hide' restart of libvirtd, better to make it obvious.