[libvirt] About libvirt.py stdout redirection

me,apporc appleorchard2000 at gmail.com
Thu Jan 16 10:31:02 UTC 2014

Dear developers,
As we know libvirt.py using libvirtmod.so, eg:

    def defineXML(self, xml):
        """Define a domain, but does not start it.
        This definition is persistent, until explicitly undefined with
        virDomainUndefine(). A previous definition for this domain would be
        overriden if it already exists. """
        ret = libvirtmod.virDomainDefineXML(self._o, xml)
        if ret is None:raise libvirtError('virDomainDefineXML() failed',
        __tmp = virDomain(self,_obj=ret)
        return __tmp

In my python program

import libvirt
conn.defineXML(xml) # Because i need this xml to be wrong for feature
testing here
 # Error will happen here, and error message is printed to stderr.

The error message is annoying.
I need to know how to hide the error message printing to stderr by

After i add sys.stderr = open('xxx', 'w') before invoking
conn.defineXML(xml),  the error message is still printed to the terminal.
Which means, i can redirect stderr to anywhere else in my python program,
 but it changes back to terminal when control flow go to libvirtmod.

Any ideas?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140116/e87d1b71/attachment-0001.htm>

More information about the libvir-list mailing list