From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCHv4 15/15] Pass boot device list to firmware. Date: Sun, 14 Nov 2010 22:57:50 +0200 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 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, blauwirbel@gmail.com, armbru@redhat.com, alex.williamson@redhat.com, kevin@koconnor.net To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:40720 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753221Ab0KNU6D (ORCPT ); Sun, 14 Nov 2010 15:58:03 -0500 Content-Disposition: inline In-Reply-To: <20101114185237.GI6798@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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.