public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <marcelo@kvack.org>
To: Avi Kivity <avi@qumranet.com>
Cc: Marcelo Tosatti <marcelo@kvack.org>,
	kvm-devel <kvm-devel@lists.sourceforge.net>,
	Alexander Graf <alex@csgraf.de>
Subject: Re: hugetlbfs not working
Date: Mon, 31 Mar 2008 14:01:08 -0300	[thread overview]
Message-ID: <20080331170108.GA10944@dmt> (raw)
In-Reply-To: <47EC9302.40103@qumranet.com>

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 <mtosatti@redhat.com>

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

  parent reply	other threads:[~2008-03-31 17:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-27 15:10 hugetlbfs not working Alexander Graf
2008-03-27 15:19 ` Avi Kivity
2008-03-27 15:30   ` Alexander Graf
2008-03-27 16:07     ` Anthony Liguori
2008-03-27 16:09       ` Avi Kivity
2008-03-27 16:35         ` Marcelo Tosatti
2008-03-27 21:55         ` Marcelo Tosatti
     [not found]           ` <47EC9302.40103@qumranet.com>
2008-03-31 17:01             ` Marcelo Tosatti [this message]
2008-03-31 17:17               ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080331170108.GA10944@dmt \
    --to=marcelo@kvack.org \
    --cc=alex@csgraf.de \
    --cc=avi@qumranet.com \
    --cc=kvm-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox