[libvirt-users] libvirt printing to stderr

I'm writing an app and using the Python bindings for libvirt. Everything is fine but, in some cases I need to call lookupByName(). There are a lot of times when the name will not exist, I trap the exception, however I still get this message printed to stderr: libvir: QEMU error : Domain not found: no domain with matching name 'foo' Is there any way to turn this off? This is a command-line program so the extra output makes the interface confusing. I've tried re-assigning sys.stderr before calling lookupByName(), but that doesn't seem to have any affect. tia, -albert

于 2010年12月13日 13:43, Albert Hopkins 写道:
I'm writing an app and using the Python bindings for libvirt.
Everything is fine but, in some cases I need to call lookupByName(). There are a lot of times when the name will not exist, I trap the exception, however I still get this message printed to stderr:
libvir: QEMU error : Domain not found: no domain with matching name 'foo'
Is there any way to turn this off? This is a command-line program so the extra output makes the interface confusing.
I've tried re-assigning sys.stderr before calling lookupByName(), but that doesn't seem to have any affect.
actually there is a bug for this problem, it should be warning, but not error, and will be fixed upstream soon. - Osier

2010/12/13 Osier Yang <jyang@redhat.com>:
于 2010年12月13日 13:43, Albert Hopkins 写道:
I'm writing an app and using the Python bindings for libvirt.
Everything is fine but, in some cases I need to call lookupByName(). There are a lot of times when the name will not exist, I trap the exception, however I still get this message printed to stderr:
libvir: QEMU error : Domain not found: no domain with matching name 'foo'
Is there any way to turn this off? This is a command-line program so the extra output makes the interface confusing.
I've tried re-assigning sys.stderr before calling lookupByName(), but that doesn't seem to have any affect.
actually there is a bug for this problem, it should be warning, but not error, and will be fixed upstream soon.
- Osier
Really? Why should this be a warning? When virDomainLookupByName() fails because there is no domain with the given name then we need to report an error. I don't see what could be changed there. Albert, libvirt's default error handler prints to stderr, you can override it like this: import libvirt def errorHandler(ctx, err): pass libvirt.registerErrorHandler(errorHandler, None) Matthias

于 2010年12月13日 15:47, Matthias Bolte 写道:
2010/12/13 Osier Yang<jyang@redhat.com>:
于 2010年12月13日 13:43, Albert Hopkins 写道:
I'm writing an app and using the Python bindings for libvirt.
Everything is fine but, in some cases I need to call lookupByName(). There are a lot of times when the name will not exist, I trap the exception, however I still get this message printed to stderr:
libvir: QEMU error : Domain not found: no domain with matching name 'foo'
Is there any way to turn this off? This is a command-line program so the extra output makes the interface confusing.
I've tried re-assigning sys.stderr before calling lookupByName(), but that doesn't seem to have any affect.
actually there is a bug for this problem, it should be warning, but not error, and will be fixed upstream soon.
- Osier
Really? Why should this be a warning? When virDomainLookupByName() fails because there is no domain with the given name then we need to report an error. I don't see what could be changed there.
ah, yeah, didn't read the message carefully, confused it with a storage volume lookup API. :-) - Osier

On Mon, 2010-12-13 at 08:47 +0100, Matthias Bolte wrote:
Albert, libvirt's default error handler prints to stderr, you can override it like this:
import libvirt
def errorHandler(ctx, err): pass
libvirt.registerErrorHandler(errorHandler, None)
Matthias
Oh, thanks (now I that I know where to look i see it in the docs). Thanks again, -albert
participants (3)
-
Albert Hopkins
-
Matthias Bolte
-
Osier Yang