Re: [PATCH 5/9] substitute is_allocated_mem with more general is_containing_region

Glauber Costa
2008-08-13T13:02:08Z

On Wed, Aug 13, 2008 at 8:41 AM, Avi Kivity <avi@qumranet.com> wrote:
> Glauber Costa wrote:
>>
>> Signed-off-by: Glauber Costa <gcosta@redhat.com>
>> ---
>> libkvm/libkvm.c | 34 +++++++++++++++++++++-------------
>> libkvm/libkvm.h | 2 +-
>> qemu/qemu-kvm.c | 2 +-
>> 3 files changed, 23 insertions(+), 15 deletions(-)
>>
>> diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
>> index 33f00b7..c885dee 100644
>> --- a/libkvm/libkvm.c
>> +++ b/libkvm/libkvm.c
>> @@ -140,6 +140,27 @@ int get_intersecting_slot(unsigned long phys_addr)
>> return -1;
>> }
>> +/* Returns -1 if this slot is not totally contained on any other,
>> + * and the number of the slot otherwise */
>> +int get_container_slot(uint64_t phys_addr, unsigned long size)
>> +{
>> + int i;
>> +
>> + for (i = 0; i < KVM_MAX_NUM_MEM_REGIONS ; ++i)
>> + if (slots[i].len && slots[i].phys_addr <= phys_addr &&
>> + (slots[i].phys_addr + slots[i].len) >= phys_addr +
>> size)
>> + return i;
>> + return -1;
>> +}
>> +
>>
>
> What about partially containing (or: overlapping) slots?

That would be handled by kvm_is_intersecting_memory. Ideally, I would
like to have a single function for both.
Now that the default action for intersecting memory is to do nothing
but return, that would be possible.

I'll make sure I address that in a later version

> --
> error compiling committee.c: too many arguments to function
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

--
Glauber Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."