From: Glauber Costa Subject: [PATCH 03/12] coalesce memory allocation Date: Wed, 10 Sep 2008 16:20:57 -0300 Message-ID: <1221074466-12276-4-git-send-email-gcosta@redhat.com> References: <1220902221-7536-1-git-send-email-gcosta@redhat.com> Cc: avi@qumranet.com, aliguori@us.ibm.com, Glauber Costa To: kvm@vger.kernel.org Return-path: Received: from mx2.redhat.com ([66.187.237.31]:38660 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751258AbYIJTb1 (ORCPT ); Wed, 10 Sep 2008 15:31:27 -0400 In-Reply-To: <1220902221-7536-1-git-send-email-gcosta@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: From: Glauber Costa Put all memory allocation under qemu_alloc_physram(). Protect the mem_area code with #ifdef USE_KVM. Although it is not really needed, it help us keep track of the fact that this is a kvm-only feature to the moment. Signed-off-by: Glauber Costa --- qemu/vl.c | 19 ++++++++----------- 1 files changed, 8 insertions(+), 11 deletions(-) diff --git a/qemu/vl.c b/qemu/vl.c index 0484a3b..022b3b8 100644 --- a/qemu/vl.c +++ b/qemu/vl.c @@ -9019,8 +9019,10 @@ void *qemu_alloc_physram(unsigned long memory) void *area = NULL; unsigned long map_len = memory; +#ifdef USE_KVM if (mem_path) area = alloc_mem_area(memory, &map_len, mem_path); +#endif if (!area) area = qemu_vmalloc(memory); #ifdef USE_KVM @@ -9934,17 +9936,12 @@ int main(int argc, char **argv) fprintf(stderr, "Could not create KVM context\n"); exit(1); } - phys_ram_base = qemu_alloc_physram(phys_ram_size); - if (!phys_ram_base) { - fprintf(stderr, "Could not allocate physical memory\n"); - exit(1); - } - } else { - phys_ram_base = qemu_vmalloc(phys_ram_size); - if (!phys_ram_base) { - fprintf(stderr, "Could not allocate physical memory\n"); - exit(1); - } + } + + phys_ram_base = qemu_alloc_physram(phys_ram_size); + if (!phys_ram_base) { + fprintf(stderr, "Could not allocate physical memory\n"); + exit(1); } /* init the dynamic translator */ -- 1.5.5.1