From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 5/9] substitute is_allocated_mem with more general is_containing_region Date: Wed, 13 Aug 2008 14:41:33 +0300 Message-ID: <48A2C86D.5030706@qumranet.com> References: <1218588489-17182-1-git-send-email-gcosta@redhat.com> <1218588489-17182-2-git-send-email-gcosta@redhat.com> <1218588489-17182-3-git-send-email-gcosta@redhat.com> <1218588489-17182-4-git-send-email-gcosta@redhat.com> <1218588489-17182-5-git-send-email-gcosta@redhat.com> <1218588489-17182-6-git-send-email-gcosta@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, aliguori@us.ibm.com To: Glauber Costa Return-path: Received: from il.qumranet.com ([212.179.150.194]:32919 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752742AbYHMLlh (ORCPT ); Wed, 13 Aug 2008 07:41:37 -0400 In-Reply-To: <1218588489-17182-6-git-send-email-gcosta@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Glauber Costa wrote: > Signed-off-by: Glauber Costa > --- > 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? -- error compiling committee.c: too many arguments to function