From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=46745 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OBUxo-0007N5-0E for qemu-devel@nongnu.org; Mon, 10 May 2010 11:32:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OBUxf-0002xU-QR for qemu-devel@nongnu.org; Mon, 10 May 2010 11:32:11 -0400 Received: from mail-vw0-f45.google.com ([209.85.212.45]:52373) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OBUxf-0002xK-KV for qemu-devel@nongnu.org; Mon, 10 May 2010 11:32:03 -0400 Received: by vws10 with SMTP id 10so170512vws.4 for ; Mon, 10 May 2010 08:32:02 -0700 (PDT) MIME-Version: 1.0 Sender: camm@ualberta.ca In-Reply-To: <4BE7E25F.20208@redhat.com> References: <1271872408-22842-1-git-send-email-cam@cs.ualberta.ca> <1271872408-22842-2-git-send-email-cam@cs.ualberta.ca> <1271872408-22842-3-git-send-email-cam@cs.ualberta.ca> <4BE7E25F.20208@redhat.com> Date: Mon, 10 May 2010 09:32:02 -0600 Message-ID: From: Cam Macdonell Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH v5 2/5] Support adding a file to qemu's ram allocation List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: mtosatti@redhat.com, "qemu-devel@nongnu.org Developers" , kvm@vger.kernel.org On Mon, May 10, 2010 at 4:39 AM, Avi Kivity wrote: > On 04/21/2010 08:53 PM, Cam Macdonell wrote: >> >> This avoids the need of using qemu_ram_alloc and mmap with MAP_FIXED to >> map a >> host file into guest RAM. =A0This function mmaps the opened file anywher= e >> and adds >> the memory to the ram blocks. >> >> Usage is >> >> qemu_ram_mmap(fd, size, MAP_SHARED, offset); >> > > Signoff? >> >> +ram_addr_t qemu_ram_mmap(int fd, ram_addr_t size, int flags, off_t >> offset) >> +{ >> + =A0 =A0RAMBlock *new_block; >> + >> + =A0 =A0size =3D TARGET_PAGE_ALIGN(size); >> + =A0 =A0new_block =3D qemu_malloc(sizeof(*new_block)); >> + >> + =A0 =A0/* map the file passed as a parameter to be this part of memory= */ >> + =A0 =A0new_block->host =3D mmap(0, size, PROT_READ|PROT_WRITE, flags, = fd, >> offset); >> + >> + =A0 =A0if (new_block->host =3D=3D MAP_FAILED) >> + =A0 =A0 =A0 =A0exit(1); >> > > Braces after if () > >> + =A0 =A0if (kvm_enabled()) >> + =A0 =A0 =A0 =A0kvm_setup_guest_memory(new_block->host, size); >> + >> > > More braces. > This function is possibly made redundant by Marcelo's patch for qemu_ram_ma= p http://kerneltrap.org/mailarchive/linux-kvm/2010/4/26/6261299 qemu_ram_map isn't merged yet either, but I'm fine with either one. Marcelo's requires the device to map the memory and then pass the pointer to be added to the memory allocation, so it gives the device full mapping control. Alternatively, I could add the protection flag to my function (I think that's all that is missing). Let me know and I'll change my patch if necessary. > -- > error compiling committee.c: too many arguments to function > >