From: "Glauber Costa" Subject: Re: [PATCH 5/9] substitute is_allocated_mem with more general is_containing_region Date: Wed, 13 Aug 2008 10:02:08 -0300 Message-ID: <5d6222a80808130602n3acca86k3a8bb35cd3158354@mail.gmail.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> <48A2C86D.5030706@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "Glauber Costa" , kvm@vger.kernel.org, aliguori@us.ibm.com To: "Avi Kivity" Return-path: Received: from rv-out-0506.google.com ([209.85.198.237]:28020 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752578AbYHMNCI (ORCPT ); Wed, 13 Aug 2008 09:02:08 -0400 Received: by rv-out-0506.google.com with SMTP id k40so3292185rvb.1 for ; Wed, 13 Aug 2008 06:02:08 -0700 (PDT) In-Reply-To: <48A2C86D.5030706@qumranet.com> Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Aug 13, 2008 at 8:41 AM, Avi Kivity wrote: > 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? 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."