From patchwork Fri Aug 15 10:07:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 380150 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 39DE31400B6 for ; Fri, 15 Aug 2014 20:14:09 +1000 (EST) Received: from localhost ([::1]:58344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIEWN-00038f-9v for incoming@patchwork.ozlabs.org; Fri, 15 Aug 2014 06:14:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIESe-00053h-Ou for qemu-devel@nongnu.org; Fri, 15 Aug 2014 06:10:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIESZ-0008V3-S7 for qemu-devel@nongnu.org; Fri, 15 Aug 2014 06:10:16 -0400 Received: from [59.151.112.132] (port=56060 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIESZ-0008Dk-Gi for qemu-devel@nongnu.org; Fri, 15 Aug 2014 06:10:11 -0400 X-IronPort-AV: E=Sophos;i="5.04,333,1406563200"; d="scan'208";a="34653679" Received: from localhost (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Aug 2014 18:07:18 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s7FAA8fB030608; Fri, 15 Aug 2014 18:10:08 +0800 Received: from G08FNSTD100614.fnst.cn.fujitsu.com (10.167.226.102) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 15 Aug 2014 18:10:16 +0800 From: Hu Tao To: Date: Fri, 15 Aug 2014 18:07:24 +0800 Message-ID: X-Mailer: git-send-email 1.9.3 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.102] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Peter Crosthwaite , "Michael S. Tsirkin" , Yasuaki Isimatu , Paolo Bonzini , Yasunori Goto Subject: [Qemu-devel] [PATCH v7 6/8] exec: file_ram_alloc: don't exit if failed to preallocate memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When using monitor command object_add to add a memory backend file but failed to preallocate memory for it, qemu exits silently. In the case we'd better give an error message and keep guest running. The problem can be reproduced as follows: 1. run qemu with -mem-prealloc 2. (monitor)object_add memory-backend-file,size=100000G,mem-path=/hugepages,id=mem-file0 Signed-off-by: Hu Tao Reviewed-by: Peter Crosthwaite --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 787cc7a..c361752 100644 --- a/exec.c +++ b/exec.c @@ -1094,8 +1094,8 @@ static void *file_ram_alloc(RAMBlock *block, return area; error: - if (mem_prealloc) { - exit(1); + if (area && area != MAP_FAILED) { + munmap(area, memory); } return NULL; }