[libvirt] PATCH: Fix leak in storage driver

A recent change to keep the storage pools active upon shutdown, exposed a minor flaw in the code which free's a virStoragePoolObj instance. It never free's the associated volumes, since it presumed you'd never free a pool, which was still active. A bogus assumption, causing us to leak memory upon daemon shutdown, thus annoying valgrind. Daniel diff -r 3e95abd6df89 src/storage_conf.c --- a/src/storage_conf.c Fri Jan 30 11:01:10 2009 +0000 +++ b/src/storage_conf.c Fri Jan 30 11:01:29 2009 +0000 @@ -296,6 +296,8 @@ virStoragePoolObjFree(virStoragePoolObjP if (!obj) return; + virStoragePoolObjClearVols(obj); + virStoragePoolDefFree(obj->def); virStoragePoolDefFree(obj->newDef); -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Fri, Jan 30, 2009 at 11:43:03AM +0000, Daniel P. Berrange wrote:
A recent change to keep the storage pools active upon shutdown, exposed a minor flaw in the code which free's a virStoragePoolObj instance. It never free's the associated volumes, since it presumed you'd never free a pool, which was still active. A bogus assumption, causing us to leak memory upon daemon shutdown, thus annoying valgrind.
Okay, fine, +1 Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

"Daniel P. Berrange" <berrange@redhat.com> wrote:
A recent change to keep the storage pools active upon shutdown, exposed a minor flaw in the code which free's a virStoragePoolObj instance. It never free's the associated volumes, since it presumed you'd never free a pool, which was still active. A bogus assumption, causing us to leak memory upon daemon shutdown, thus annoying valgrind.
Daniel
diff -r 3e95abd6df89 src/storage_conf.c --- a/src/storage_conf.c Fri Jan 30 11:01:10 2009 +0000 +++ b/src/storage_conf.c Fri Jan 30 11:01:29 2009 +0000 @@ -296,6 +296,8 @@ virStoragePoolObjFree(virStoragePoolObjP if (!obj) return;
+ virStoragePoolObjClearVols(obj); +
ACK. This is crying for integration testing...

On Fri, Jan 30, 2009 at 04:55:40PM +0100, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@redhat.com> wrote:
A recent change to keep the storage pools active upon shutdown, exposed a minor flaw in the code which free's a virStoragePoolObj instance. It never free's the associated volumes, since it presumed you'd never free a pool, which was still active. A bogus assumption, causing us to leak memory upon daemon shutdown, thus annoying valgrind.
Daniel
diff -r 3e95abd6df89 src/storage_conf.c --- a/src/storage_conf.c Fri Jan 30 11:01:10 2009 +0000 +++ b/src/storage_conf.c Fri Jan 30 11:01:29 2009 +0000 @@ -296,6 +296,8 @@ virStoragePoolObjFree(virStoragePoolObjP if (!obj) return;
+ virStoragePoolObjClearVols(obj); +
ACK. This is crying for integration testing...
This scenario really ought to have been caught by tests of the storage impl in test:///default driver - it could be that our impl in the test driver is not complete enough. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Jim Meyering