From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=52631 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PHjeG-0004ad-Lf for qemu-devel@nongnu.org; Sun, 14 Nov 2010 15:58:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PHjeF-0005j1-JK for qemu-devel@nongnu.org; Sun, 14 Nov 2010 15:58:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11858) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PHjeF-0005ij-9k for qemu-devel@nongnu.org; Sun, 14 Nov 2010 15:58:03 -0500 Date: Sun, 14 Nov 2010 22:57:50 +0200 From: "Michael S. Tsirkin" Message-ID: <20101114205750.GD14828@redhat.com> References: <1289749181-12070-1-git-send-email-gleb@redhat.com> <1289749181-12070-16-git-send-email-gleb@redhat.com> <20101114184137.GB12570@redhat.com> <20101114185237.GI6798@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101114185237.GI6798@redhat.com> Subject: [Qemu-devel] Re: [PATCHv4 15/15] Pass boot device list to firmware. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, armbru@redhat.com, blauwirbel@gmail.com, alex.williamson@redhat.com, kevin@koconnor.net On Sun, Nov 14, 2010 at 08:52:37PM +0200, Gleb Natapov wrote: > > > + > > > + len = strlen(bootpath); > > > + list = qemu_realloc(list, total + len + 1); > > > + list[total++] = len; > > > + memcpy(&list[total], bootpath, len); > > > + total += len; > > > + c++; > > > + qemu_free(bootpath); > > > > Man, is this tricky. > > > Nah, not at all. I think it will be easier if we don't try to do this in one pass. 1. pass: calculate total length and # of devices 2. allocate 2. pass fill in > -- > Gleb.