From patchwork Sat Jun 14 04:48:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 359752 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 CE0C114009F for ; Sat, 14 Jun 2014 14:53:09 +1000 (EST) Received: from localhost ([::1]:34181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wvfxj-0003TK-JQ for incoming@patchwork.ozlabs.org; Sat, 14 Jun 2014 00:53:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wvfvr-000052-72 for qemu-devel@nongnu.org; Sat, 14 Jun 2014 00:51:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wvfvg-0000ii-OL for qemu-devel@nongnu.org; Sat, 14 Jun 2014 00:51:11 -0400 Received: from [59.151.112.132] (port=14942 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wvfvg-0000i1-Cr for qemu-devel@nongnu.org; Sat, 14 Jun 2014 00:51:00 -0400 X-IronPort-AV: E=Sophos;i="5.00,707,1396972800"; d="scan'208";a="31897844" Received: from localhost (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 14 Jun 2014 12:48:19 +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 s5E4ouHc014766; Sat, 14 Jun 2014 12:50:56 +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; Sat, 14 Jun 2014 12:51:04 +0800 From: Hu Tao To: Date: Sat, 14 Jun 2014 12:48:57 +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: Yasunori Goto , Paolo Bonzini , Igor Mammedov , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH RFC 2/4] check if we have space left for hotplugged 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 If pc-dimm is specified on qemu command line, but only with -m size (aka not -m size,maxmem,slots) then qemu will core dump. This patch fixes the problem. Signed-off-by: Hu Tao --- hw/mem/pc-dimm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 8c26568..6e8bf43 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -107,7 +107,12 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, uint64_t new_addr, ret = 0; uint64_t address_space_end = address_space_start + address_space_size; - assert(address_space_end > address_space_size); + if (address_space_size == 0) { + error_setg(errp, "can't add memory beyond 0x%" PRIx64, + address_space_end); + goto out; + } + object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list); if (hint) {