[libvirt] [PATCH] virsh: Free stream when shutdown console

Otherwise connection of hypervisor driver will be leaked when one shutdown the guest in console. e.g. [root@localhost]# init 0 ...... init: Re-executing /sbin/init Halting system... Power down. error: Failed to disconnect from the hypervisor, 1 leaked reference(s) --- tools/console.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/tools/console.c b/tools/console.c index b9dd268..01d8bd1 100644 --- a/tools/console.c +++ b/tools/console.c @@ -91,6 +91,8 @@ static void virConsoleShutdown(virConsolePtr con) { con->quit = true; + if (con->st) + virStreamFree(con->st); virStreamEventRemoveCallback(con->st); if (con->stdinWatch != -1) virEventRemoveHandle(con->stdinWatch); -- 1.7.4

On 03/11/2011 06:56 AM, Osier Yang wrote:
Otherwise connection of hypervisor driver will be leaked when one shutdown the guest in console. e.g.
[root@localhost]# init 0 ...... init: Re-executing /sbin/init Halting system... Power down.
error: Failed to disconnect from the hypervisor, 1 leaked reference(s) --- tools/console.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/console.c b/tools/console.c index b9dd268..01d8bd1 100644 --- a/tools/console.c +++ b/tools/console.c @@ -91,6 +91,8 @@ static void virConsoleShutdown(virConsolePtr con) { con->quit = true; + if (con->st) + virStreamFree(con->st); virStreamEventRemoveCallback(con->st);
Shouldn't you free the stream _after_ you remove the callback from it? Otherwise, you are referencing a freed stream. ACK if you swap those two lines. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

于 2011年03月11日 23:19, Eric Blake 写道:
On 03/11/2011 06:56 AM, Osier Yang wrote:
Otherwise connection of hypervisor driver will be leaked when one shutdown the guest in console. e.g.
[root@localhost]# init 0 ...... init: Re-executing /sbin/init Halting system... Power down.
error: Failed to disconnect from the hypervisor, 1 leaked reference(s) --- tools/console.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/console.c b/tools/console.c index b9dd268..01d8bd1 100644 --- a/tools/console.c +++ b/tools/console.c @@ -91,6 +91,8 @@ static void virConsoleShutdown(virConsolePtr con) { con->quit = true; + if (con->st) + virStreamFree(con->st); virStreamEventRemoveCallback(con->st);
Shouldn't you free the stream _after_ you remove the callback from it? Otherwise, you are referencing a freed stream.
ACK if you swap those two lines.
Pushed with that fixed. Thanks. Osier
participants (2)
-
Eric Blake
-
Osier Yang