Re: generator.py -- why?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting "Daniel P. Berrange" <berrange@xxxxxxxxxx>:
[snip]
Here's a program that produces the bug I tried to address:

import libvirt
def get_domain(dom_name):
    conn = libvirt.openReadOnly(None)
    domain = conn.lookupByName(dom_name)
    return domain
d = get_domain("mydomain")
print d.info()

[snip]
This is a also a very bad pattern to use. Not only is opening a new connection
a fairly heavyweight opertion - it has to connect to xenstore, xend, and fork
fork the proxy server. Now if each time to your get_domain the domain object
returned is associated with a different connection object. This bypasseses the caching of domain object instances which is done internal to libvirt, degrading
performance still further.


I agree with you completely.  However, there might be legitimate architectural
reasons for doing things the above way; it's possible that the programmer
didn't want that connection-creation code cluttering up the program-proper ;-).
IMHO, a robust library shouldn't make assumptions about how its users will use
it.  If the user wants to do something potentially dangerous, the library
should at least allow it, and definitely not bomb out.

Just my 2c.  :-)

Pete





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]