From 0b20d14d799771c12c1fb3553d0bd2fb830d887c Mon Sep 17 00:00:00 2001 Message-Id: <0b20d14d799771c12c1fb3553d0bd2fb830d887c.1380723420.git.minovotn@redhat.com> In-Reply-To: <68de4f1434a46df7d1b6e59cb348f11c92dbf17c.1380723420.git.minovotn@redhat.com> References: <68de4f1434a46df7d1b6e59cb348f11c92dbf17c.1380723420.git.minovotn@redhat.com> From: Markus Armbruster Date: Tue, 1 Oct 2013 08:12:03 +0200 Subject: [PATCH 02/13] exec: Don't abort when we can't allocate guest memory RH-Author: Markus Armbruster Message-id: <1380615123-24391-3-git-send-email-armbru@redhat.com> Patchwork-id: 54613 O-Subject: [PATCH 6.5 qemu-kvm v2 2/2] exec: Don't abort when we can't allocate guest memory Bugzilla: 867921 RH-Acked-by: Paolo Bonzini RH-Acked-by: Eduardo Habkost RH-Acked-by: Igor Mammedov From: Markus Armbruster Upstream commit 3922825 doesn't apply, and its preliminary cleanups don't apply either. Reimplement it. Signed-off-by: Markus Armbruster --- exec.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) Signed-off-by: Michal Novotny --- exec.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 2f43733..f970450 100644 --- a/exec.c +++ b/exec.c @@ -48,6 +48,7 @@ #if defined(CONFIG_USER_ONLY) #include #endif +#include "trace.h" //#define DEBUG_TB_INVALIDATE //#define DEBUG_FLUSH @@ -2765,11 +2766,20 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, MAP_SHARED | MAP_ANONYMOUS, -1, 0); #else size_t align = getpagesize(); + void *ptr; + int ret; #ifdef PREFERRED_RAM_ALIGN if (size >= PREFERRED_RAM_ALIGN && !running_on_valgrind) align = PREFERRED_RAM_ALIGN; #endif - new_block->host = qemu_memalign(align, size); + ret = posix_memalign(&ptr, align, size); + trace_qemu_memalign(align, size, ptr); + if (ret) { + fprintf(stderr, "Cannot set up guest memory '%s': %s\n", + new_block->idstr, strerror(ret)); + exit(1); + } + new_block->host = ptr; #endif #ifdef MADV_MERGEABLE if (!disable_KSM) -- 1.7.11.7