[libvirt] PATCH: 1/4: Add OOM hooks to the memory allocator
Daniel Veillard
veillard at redhat.com
Wed May 28 13:35:19 UTC 2008
On Thu, May 22, 2008 at 06:17:27PM +0100, Daniel P. Berrange wrote:
> This patch adds extra code to src/memory.c which allows us to force an OOM
> condition on specific allocations. This is not code you *ever* want to use
> in a production build, so its all conditional on TEST_OOM, which is enabled
> by passing --enable-test-oom to the configure script.
>
> The hooks work as follows...
>
> - The test suite first calls virAllocTestInit() to initialize the hooks.
> This causes it to start counting allocations.
>
> ....then run the code you want to check for OOM...
>
> - Next call virAllocTestCount() to find out how many allocations were
> made.
>
> - Given a number of allocations 'n', we need to repeat 'n' times...
>
> - Call virAllocTestOOM(n, m) to tell it to fail the n'th allocation
> upto the (n + m -1)'th allocation. eg, virAllocTestOOM(3, 2)
> will cause allocations 3 and 4 to fail.
>
> ... run the code you want to check and verify it reports OOM
> in the way you expect.
>
>
> It can be quite hard to find out just where allocation failure bugs are
> hiding. So there is also a virAllocTestHook() function which lets you
> register a callback to be invoked at the time an allocation is artificially
> failed. Obvious use for this is to capture a stack trace.
Fine by me. +1
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard at redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
More information about the libvir-list
mailing list