From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUoUA-0001SF-38 for qemu-devel@nongnu.org; Wed, 04 Feb 2009 15:36:38 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUoU8-0001RQ-0Q for qemu-devel@nongnu.org; Wed, 04 Feb 2009 15:36:37 -0500 Received: from [199.232.76.173] (port=38395 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUoU7-0001Qx-RV for qemu-devel@nongnu.org; Wed, 04 Feb 2009 15:36:35 -0500 Received: from e31.co.us.ibm.com ([32.97.110.149]:34269) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LUoU6-0005gh-Pe for qemu-devel@nongnu.org; Wed, 04 Feb 2009 15:36:34 -0500 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e31.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id n14KYKMK019882 for ; Wed, 4 Feb 2009 13:34:20 -0700 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id n14KaTWv202798 for ; Wed, 4 Feb 2009 13:36:29 -0700 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n14KaTnB020305 for ; Wed, 4 Feb 2009 13:36:29 -0700 Message-ID: <4989FC3B.7010407@us.ibm.com> Date: Wed, 04 Feb 2009 14:36:11 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1233750314-23301-1-git-send-email-avi@redhat.com> <1233750314-23301-2-git-send-email-avi@redhat.com> <4989EC29.9050705@us.ibm.com> <4989FACD.6090309@redhat.com> In-Reply-To: <4989FACD.6090309@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 1/4] Add a scatter-gather list type and accessors Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org Avi Kivity wrote: > Anthony Liguori wrote: >> Avi Kivity wrote: >>> Scatter-gather lists are used extensively in dma-capable devices; a >>> single data structure allows more code reuse later on. >>> >>> diff --git a/dma-helpers.c b/dma-helpers.c >>> new file mode 100644 >>> index 0000000..315834e >>> --- /dev/null >>> +++ b/dma-helpers.c >>> @@ -0,0 +1,29 @@ >>> >> >> Needs copyright/license. > > Sure. > > Is it possible to have a blanket license for files which don't have > explicit terms? I don't much like boilerplate. I'd greatly prefer not to. You can refer to a COPYING and we can have a default COPYING file but a copyright is really needed as far as I understand it. >> >>> +#include "dma.h" >>> + >>> + >>> +void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint) >>> +{ >>> + qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry)); >>> >> >> Would be nice to check for malloc failures and fail gracefully at least. > > Do you mean an exit(1)? If so we could just put it in qemu_malloc(). In theory, some users may be able to cope with malloc failure. In practice, I don't think anyone can. I'm open to suggestion. > I expect this to trigger rarely since the allocation hint should > suffice nearly 100% of the time. But in case we miss, it's better to > reallocate as little as possible. > > (what I really want is std::vector<>) Which I'm pretty sure has a linear growth strategy :-) Regards, Anthony Liguori