[libvirt] Python stream callback removal

Daniel P. Berrange berrange at redhat.com
Tue Aug 9 09:59:02 UTC 2011


On Mon, Aug 08, 2011 at 06:04:50PM -0400, Dave Allan wrote:
> I'm trying to write an example serial console implementation in python
> (attached), but I'm having some trouble getting stream events to do
> what I want.  The console itself works fine as long as the domain
> stays up, but as soon as the domain shuts down the python script goes
> into a tight loop repeatedly calling the stream event callback.
> Debugging indicates that the stream event callback is being requested
> to be removed, but it never actually is removed which makes me think I
> am not properly releasing some resource, but I was under the
> impression that an error on a stream resulting in the stream aborting
> was supposed to free all the resources for me.  Is that not correct?

No where in your code do you ever invoke eventRemoveCallback.
When the stream is "aborted" this just means that libvirtd
has released server side resource & reported the error back
to the client. You still have to remove your event callbacks
otherwise you'll just be invoked forever. See tools/console.c
for example code doing what you're attempting, but in C.
In particular the places which call virConsoleShutdown.
Your code in Python should  basically be a straight conversion
of tools/console.c from C into Python.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list