On Mon, May 10, 2010 at 4:39 AM, Avi Kivity <a...@redhat.com> wrote:
> On 04/21/2010 08:53 PM, Cam Macdonell wrote:
>>
>> This avoids the need of using qemu_ram_alloc and mmap with MAP_FIXED to
>> map a
>> host file into guest RAM.  This function mmaps the opened file anywhere
>> and adds
>> the memory to the ram blocks.
>>
>> Usage is
>>
>> qemu_ram_mmap(fd, size, MAP_SHARED, offset);
>>
>
> Signoff?
>>
>> +ram_addr_t qemu_ram_mmap(int fd, ram_addr_t size, int flags, off_t
>> offset)
>> +{
>> +    RAMBlock *new_block;
>> +
>> +    size = TARGET_PAGE_ALIGN(size);
>> +    new_block = qemu_malloc(sizeof(*new_block));
>> +
>> +    /* map the file passed as a parameter to be this part of memory */
>> +    new_block->host = mmap(0, size, PROT_READ|PROT_WRITE, flags, fd,
>> offset);
>> +
>> +    if (new_block->host == MAP_FAILED)
>> +        exit(1);
>>
>
> Braces after if ()
>
>> +    if (kvm_enabled())
>> +        kvm_setup_guest_memory(new_block->host, size);
>> +
>>
>
> More braces.
>

This function is possibly made redundant by Marcelo's patch for qemu_ram_map

http://kerneltrap.org/mailarchive/linux-kvm/2010/4/26/6261299

qemu_ram_map isn't merged yet either, but I'm fine with either one.
Marcelo's requires the device to map the memory and then pass the
pointer to be added to the memory allocation, so it gives the device
full mapping control.  Alternatively, I could add the protection flag
to my function (I think that's all that is missing).

Let me know and I'll change my patch if necessary.

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

Reply via email to