From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>
Subject: [Qemu-devel] [RFC PATCH] file ram alloc: fail if cannot preallocate
Date: Mon, 10 Feb 2014 17:32:55 +1100 [thread overview]
Message-ID: <1392013975-1656-1-git-send-email-aik@ozlabs.ru> (raw)
At the moment if the user asked for huge pages and there is no more huge
pages, QEMU prints warning and falls back to the anonymous memory
allocator which is quite easy not to notice. QEMU also does so even
if the user specified -mem-prealloc and it seems wrong as the user
specifically requested huge pages for the entire RAM but QEMU failed to do
so and continued. On PPC64 this will produce a fragile guest as QEMU
tells the guest via device-tree that it can use huge pages when it
actually cannot.
This adds message+exit if RAM cannot be preallocated from huge pages.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
exec.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/exec.c b/exec.c
index 9ad0a4b..deb8279 100644
--- a/exec.c
+++ b/exec.c
@@ -1041,6 +1041,10 @@ static void *file_ram_alloc(RAMBlock *block,
area = mmap(0, memory, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
if (area == MAP_FAILED) {
+ if (mem_prealloc) {
+ perror("file_ram_alloc: failed to preallocate RAM");
+ exit(1);
+ }
perror("file_ram_alloc: can't mmap RAM pages");
close(fd);
return (NULL);
--
1.8.4.rc4
next reply other threads:[~2014-02-10 6:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-10 6:32 Alexey Kardashevskiy [this message]
2014-02-21 4:57 ` [Qemu-devel] [RFC PATCH] file ram alloc: fail if cannot preallocate Alexey Kardashevskiy
2014-02-21 8:57 ` Alexander Graf
2014-02-21 12:56 ` Alexey Kardashevskiy
2014-02-21 13:02 ` Alexander Graf
2014-02-21 13:04 ` Alexey Kardashevskiy
2014-02-21 13:10 ` Alexander Graf
2014-02-21 13:18 ` Alexey Kardashevskiy
2014-02-21 13:22 ` Paolo Bonzini
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=1392013975-1656-1-git-send-email-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).