serialcon: Close the console at the end of the stream

When LXC guest was shut down while its console was open, virt-manager
got stuck in a loop due to the fact that the readable event was not
properly removed from the callback.  Mimicking the behavior from
libvirt's tolls/console.c file, this patch properly closes the console
in case stream.recv() returns empty string.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=968896

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2013-06-11 09:32:13 +02:00
parent 1ca9d6ebd2
commit 77fb38e602

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2006 Red Hat, Inc.
# Copyright (C) 2006, 2013 Red Hat, Inc.
# Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
@ -158,6 +158,8 @@ class LibvirtConsoleConnection(ConsoleConnection):
if got == -2:
return
if len(got) == 0:
self.close()
queued_text = bool(self.streamToTerminal)
self.streamToTerminal += got