qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	kvm-devel <kvm@vger.kernel.org>
Subject: Re: [Qemu-devel] file_ram_alloc: unify mem-path, mem-prealloc error handling
Date: Fri, 07 Feb 2014 09:39:33 +0100	[thread overview]
Message-ID: <52F49BC5.7090309@redhat.com> (raw)
In-Reply-To: <20140204184153.GA25368@amt.cnet>

Il 04/02/2014 19:41, Marcelo Tosatti ha scritto:
>
> -mem-prealloc asks to preallocate memory residing on -mem-path path.
>
> Currently QEMU exits in case:
>
> - Memory file has been created but allocation via explicit write
> fails.
>
> And it fallbacks to malloc in case:
> - Querying huge page size fails.
> - Lack of sync MMU support.
> - Open fails.
> - mmap fails.
>
> Have the same behaviour for all cases: fail in case -mem-path and
> -mem-prealloc are specified for regions where the requested size is
> suitable for hugepages.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> diff --git a/exec.c b/exec.c
> index 9ad0a4b..1da1ba7 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -996,7 +996,7 @@ static void *file_ram_alloc(RAMBlock *block,
>
>      hpagesize = gethugepagesize(path);
>      if (!hpagesize) {
> -        return NULL;
> +        goto error;
>      }
>
>      if (memory < hpagesize) {
> @@ -1005,7 +1005,7 @@ static void *file_ram_alloc(RAMBlock *block,
>
>      if (kvm_enabled() && !kvm_has_sync_mmu()) {
>          fprintf(stderr, "host lacks kvm mmu notifiers, -mem-path unsupported\n");
> -        return NULL;
> +        goto error;
>      }
>
>      /* Make name safe to use with mkstemp by replacing '/' with '_'. */
> @@ -1023,7 +1023,7 @@ static void *file_ram_alloc(RAMBlock *block,
>      if (fd < 0) {
>          perror("unable to create backing store for hugepages");
>          g_free(filename);
> -        return NULL;
> +        goto error;
>      }
>      unlink(filename);
>      g_free(filename);
> @@ -1043,7 +1043,7 @@ static void *file_ram_alloc(RAMBlock *block,
>      if (area == MAP_FAILED) {
>          perror("file_ram_alloc: can't mmap RAM pages");
>          close(fd);
> -        return (NULL);
> +        goto error;
>      }
>
>      if (mem_prealloc) {
> @@ -1087,6 +1087,12 @@ static void *file_ram_alloc(RAMBlock *block,
>
>      block->fd = fd;
>      return area;
> +
> +error:
> +    if (mem_prealloc) {
> +        exit(1);
> +    }
> +    return NULL;
>  }
>  #else
>  static void *file_ram_alloc(RAMBlock *block,
>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Will apply soon.

  parent reply	other threads:[~2014-02-07  8:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-04 18:41 [Qemu-devel] file_ram_alloc: unify mem-path, mem-prealloc error handling Marcelo Tosatti
2014-02-04 18:43 ` Marcelo Tosatti
2014-02-07  8:39 ` Paolo Bonzini [this message]
2014-02-27 18:30 ` Paolo Bonzini
2014-02-28  1:05   ` Marcelo Tosatti
2014-02-28 12:55   ` Igor Mammedov

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=52F49BC5.7090309@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).