On Tue, Aug 09, 2011 at 10:59:02AM +0100, Daniel P. Berrange wrote:
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.
Thanks, that was the problem; calling remove fixed it.
What I'm trying to do is to write a console that does not exit when
the domain is down, and the code is now working, at least for a short
while. However, I am seeing a strange behavior. After the domain has
been powered off twice--regardless of whether the domain was started
or stopped when the console program is started--when starting the
domain the next time the console hangs and no callbacks are called. I
attached to the process with gdb and the backtraces are very different
when the process is responsive vs. when it is ok.
Any ideas on what's going wrong?
Dave