From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: hugetlbfs not working Date: Mon, 31 Mar 2008 14:01:08 -0300 Message-ID: <20080331170108.GA10944@dmt> References: <47EBBB1A.30109@qumranet.com> <80C24060-EF44-44C5-96E2-C629F0A52EBD@csgraf.de> <47EBC626.4010801@codemonkey.ws> <47EBC6D4.3070803@qumranet.com> <20080327215510.GA11511@dmt> <47EC9302.40103@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm-devel , Alexander Graf To: Avi Kivity Return-path: Content-Disposition: inline In-Reply-To: <47EC9302.40103@qumranet.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org On Fri, Mar 28, 2008 at 09:41:06AM +0300, Avi Kivity wrote: > >mmap() should fail if anything goes wrong with ftruncate and the file > >length is not extented on tmpfs. > > > >--- vl.c.orig 2008-03-27 18:51:31.000000000 -0300 > >+++ vl.c 2008-03-27 18:52:40.000000000 -0300 > >@@ -8749,11 +8749,7 @@ > > > > memory = (memory+hpagesize-1) & ~(hpagesize-1); > > > >- if (ftruncate(fd, memory) == -1) { > >- perror("ftruncate"); > >- close(fd); > >- return NULL; > >- } > >+ ftruncate(fd, memory); > > > > I'm sure a patch will follow to add a missing error check, so how about > a comment here? > > btw, we use signoffs on kvm-userspace, too. QEMU/KVM: ftruncate() is not supported by hugetlbfs on older hosts Signed-off-by: Marcelo Tosatti diff --git a/qemu/vl.c b/qemu/vl.c index 5627862..6a240bf 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -8739,11 +8739,13 @@ void *alloc_mem_area(unsigned long memory, const char *path) memory = (memory+hpagesize-1) & ~(hpagesize-1); - if (ftruncate(fd, memory) == -1) { - perror("ftruncate"); - close(fd); - return NULL; - } + /* + * ftruncate is not supported by hugetlbfs in older + * hosts, so don't bother checking for errors. + * If anything goes wrong with it under other filesystems, + * mmap will fail. + */ + ftruncate(fd, memory); area = mmap(0, memory, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); if (area == MAP_FAILED) { ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace