From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6nR5-0005nN-RI for qemu-devel@nongnu.org; Tue, 27 Apr 2010 12:14:59 -0400 Received: from [140.186.70.92] (port=47210 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6nR3-0005ml-Pm for qemu-devel@nongnu.org; Tue, 27 Apr 2010 12:14:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6nQy-0000Op-5f for qemu-devel@nongnu.org; Tue, 27 Apr 2010 12:14:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41703) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6nQx-0000Of-Ua for qemu-devel@nongnu.org; Tue, 27 Apr 2010 12:14:52 -0400 Date: Tue, 27 Apr 2010 11:50:20 -0300 From: Marcelo Tosatti Message-ID: <20100427145020.GD23249@amt.cnet> References: <2e085c19aac78e6c4335eac4fffeb5cfca4bbb26.1272304746.git.mtosatti@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH 10/10] introduce qemu_ram_map List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cam Macdonell Cc: Anthony Liguori , qemu-devel@nongnu.org, kvm@vger.kernel.org On Tue, Apr 27, 2010 at 08:32:27AM -0600, Cam Macdonell wrote: > > > > +ram_addr_t qemu_ram_map(ram_addr_t size, void *host) > > +{ > > + =A0 =A0RAMBlock *new_block; > > + > > + =A0 =A0size =3D TARGET_PAGE_ALIGN(size); > > + =A0 =A0new_block =3D qemu_malloc(sizeof(*new_block)); > > + > > + =A0 =A0new_block->host =3D host; > > + > > + =A0 =A0new_block->offset =3D last_ram_offset; > > + =A0 =A0new_block->length =3D size; > > + > > + =A0 =A0new_block->next =3D ram_blocks; > > + =A0 =A0ram_blocks =3D new_block; > > + > > + =A0 =A0phys_ram_dirty =3D qemu_realloc(phys_ram_dirty, > > + =A0 =A0 =A0 =A0(last_ram_offset + size) >> TARGET_PAGE_BITS); > > + =A0 =A0memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS= ), > > + =A0 =A0 =A0 =A0 =A0 0xff, size >> TARGET_PAGE_BITS); > > + > > + =A0 =A0last_ram_offset +=3D size; > > + > > + =A0 =A0if (kvm_enabled()) > > + =A0 =A0 =A0 =A0kvm_setup_guest_memory(new_block->host, size); > > + > > + =A0 =A0return new_block->offset; > > +} > > + > > =A0ram_addr_t qemu_ram_alloc(ram_addr_t size) > > =A0{ > > =A0 =A0 RAMBlock *new_block; > > -- > > 1.6.6.1 > > >=20 > Sorry for being late to reply, is there a strong reason not to have > the function handle the mmap itself? As As Anthony points out, that > way we don't have worry about realloc changing the pointer in the > function. The caller might want a different protection for the memory map.