From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH v5 2/5] Support adding a file to qemu's ram allocation Date: Mon, 10 May 2010 13:39:27 +0300 Message-ID: <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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org To: Cam Macdonell Return-path: Received: from mx1.redhat.com ([209.132.183.28]:50766 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755831Ab0EJKjb (ORCPT ); Mon, 10 May 2010 06:39:31 -0400 In-Reply-To: <1271872408-22842-3-git-send-email-cam@cs.ualberta.ca> Sender: kvm-owner@vger.kernel.org List-ID: 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. This function mmaps the opened file anywhere 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) > +{ > + RAMBlock *new_block; > + > + size = TARGET_PAGE_ALIGN(size); > + new_block = qemu_malloc(sizeof(*new_block)); > + > + /* map the file passed as a parameter to be this part of memory */ > + new_block->host = mmap(0, size, PROT_READ|PROT_WRITE, flags, fd, offset); > + > + if (new_block->host == MAP_FAILED) > + exit(1); > Braces after if () > + if (kvm_enabled()) > + kvm_setup_guest_memory(new_block->host, size); > + > More braces. -- error compiling committee.c: too many arguments to function