From patchwork Mon Mar 28 13:44:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 88604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 93212B6F8B for ; Tue, 29 Mar 2011 00:49:31 +1100 (EST) Received: from localhost ([127.0.0.1]:47365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4CnD-0002Zo-9t for incoming@patchwork.ozlabs.org; Mon, 28 Mar 2011 09:47:39 -0400 Received: from [140.186.70.92] (port=54006 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4CkI-0001mO-Jj for qemu-devel@nongnu.org; Mon, 28 Mar 2011 09:44:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4CkF-00050z-Om for qemu-devel@nongnu.org; Mon, 28 Mar 2011 09:44:37 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:45547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4CkF-0004zJ-GA for qemu-devel@nongnu.org; Mon, 28 Mar 2011 09:44:35 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1Q4Ck2-0005zP-IY; Mon, 28 Mar 2011 14:44:22 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 28 Mar 2011 14:44:18 +0100 Message-Id: <1301319862-22998-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1301319862-22998-1-git-send-email-peter.maydell@linaro.org> References: <1301319862-22998-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: Blue Swirl , patches@linaro.org Subject: [Qemu-devel] [PATCH v2 1/5] Allow boards to specify maximum RAM size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Allow boards to specify their maximum RAM size in the QEMUMachine struct. This allows us to provide a useful diagnostic if the user tries to specify a RAM size that the board cannot support. Signed-off-by: Peter Maydell --- hw/boards.h | 1 + vl.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/hw/boards.h b/hw/boards.h index 6f0f0d7..5f41fce 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -19,6 +19,7 @@ typedef struct QEMUMachine { QEMUMachineInitFunc *init; int use_scsi; int max_cpus; + target_phys_addr_t max_ram; unsigned int no_serial:1, no_parallel:1, use_virtcon:1, diff --git a/vl.c b/vl.c index 192a240..69cb29b 100644 --- a/vl.c +++ b/vl.c @@ -166,6 +166,9 @@ int main(int argc, char **argv) //#define DEBUG_NET //#define DEBUG_SLIRP +/* Note that this default RAM size is capped to any maximum + * RAM size specified in the board's QEMUMachine struct. + */ #define DEFAULT_RAM_SIZE 128 #define MAX_VIRTIO_CONSOLES 1 @@ -3046,8 +3049,19 @@ int main(int argc, char **argv, char **envp) exit(1); /* init the memory */ - if (ram_size == 0) + if (ram_size == 0) { ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; + if (machine->max_ram) { + ram_size = MIN(ram_size, machine->max_ram); + } + } else if (machine->max_ram && ram_size > machine->max_ram) { + /* Since you can only specify ram_size on the command line in MB it's + * OK to round down when printing the machine's maximum. + */ + fprintf(stderr, "qemu: maximum permitted RAM size for '%s' is %ldM\n", + machine->name, (ram_addr_t)(machine->max_ram / (1024 * 1024))); + exit(1); + } /* init the dynamic translator */ cpu_exec_init_all(tb_size * 1024 * 1024);