qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends


From: Avi Kivity
Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends
Date: Sun, 06 Dec 2009 19:14:57 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091203 Fedora/3.0-3.13.rc2.fc12 Thunderbird/3.0

On 12/06/2009 06:52 PM, Ian Molton wrote:
Markus Armbruster wrote:

     p = malloc(n * sizeof(struct foo);
     if (n&&  !p)
         exit_no_mem();
     for (i = 0; i<  n; i++)
         compute_one(p, i);

With qemu_malloc(), the error handling moves into qemu_malloc():

     p = qemu_malloc(n * sizeof(struct foo);
     for (i = 0; i<  n; i++)
         compute_one(p, i);
And you lose the ability to fail gracefully...

We never had it. Suppose p is allocated in response to an SCSI register write, and we allocate a scatter-gather list. What do you do if you OOM?

1) Introduce an error path that works synchronously off the stack and so does not need to allocate memory 2) Don't allocate in the first place, always read guest memory and transform it for sglists, preallocate everything else 3) Have a per-thread emergency pool, stall the vcpu until all memory is returned to the emergency pool

all of these options are pretty horrible, either to the code or to the guest, for something that never happens.

--
error compiling committee.c: too many arguments to function





reply via email to

[Prev in Thread] Current Thread [Next in Thread]