On Thu, Jul 19, 2012 at 01:37:11PM +0200, Paolo Bonzini wrote: > Il 18/07/2012 17:35, Daniel P. Berrange ha scritto: > > Oh, and will this library depend on glib > > Yes, in all likelihood. > > , and will it have the > > abort-on-oom behaviour QEMU has ? From a libvirt POV, we won't > > use any library that aborts-on-oom. > > Out of curiosity, how do you test OOM?
There's two aspects to it. First we forbid use of malloc/free/realloc in favour of an alternative set of APIs designed such that we can get compile time errors when people don't check the result for NULL. http://berrange.com/posts/2008/05/23/better-living-through-api-design-low-level-memory-allocation/ This has been very successful in ensuring code checks for OOM correctly. Second there is a mode in our test suites where you can run under simulated OOM - it runs once to count the total set of mallocs in the test, and then re-run it 'n' times failing each malloc in turn and verifying that we correctly report the OOM error condition. 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 :|