From patchwork Mon Jun 16 10:05:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 360032 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 9EC5514007D for ; Mon, 16 Jun 2014 20:19:44 +1000 (EST) Received: from localhost ([::1]:42757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwU0s-0005Lf-Gw for incoming@patchwork.ozlabs.org; Mon, 16 Jun 2014 06:19:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwTpN-00048e-Oh for qemu-devel@nongnu.org; Mon, 16 Jun 2014 06:07:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwTpI-0006U7-QV for qemu-devel@nongnu.org; Mon, 16 Jun 2014 06:07:49 -0400 Received: from [59.151.112.132] (port=26438 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwTpI-0006Pj-Fs for qemu-devel@nongnu.org; Mon, 16 Jun 2014 06:07:44 -0400 X-IronPort-AV: E=Sophos;i="5.00,716,1396972800"; d="scan'208";a="31965695" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Jun 2014 18:05:04 +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 s5GA7fLF007334; Mon, 16 Jun 2014 18:07:41 +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; Mon, 16 Jun 2014 18:07:43 +0800 From: Hu Tao To: Date: Mon, 16 Jun 2014 18:05:42 +0800 Message-ID: <74c6e9c8f1b968bab55148a45862f19a3fc7c27b.1402912665.git.hutao@cn.fujitsu.com> 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 v2 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, 7 insertions(+) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 8c26568..a57b9a3 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -107,6 +107,13 @@ 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; + if (address_space_size == 0) { + error_setg(errp, "no space left for hotplugged memory. did you forget " + "maxmem and slots on " + "-m(aka -m size,maxmem=maxmem,slots=slots)?"); + goto out; + } + assert(address_space_end > address_space_size); object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list);