From patchwork Wed Mar 4 08:30:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikunj A Dadhania X-Patchwork-Id: 446143 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 D264C14016B for ; Wed, 4 Mar 2015 19:31:01 +1100 (AEDT) Received: from localhost ([::1]:42662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YT4hn-0003yj-P8 for incoming@patchwork.ozlabs.org; Wed, 04 Mar 2015 03:30:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YT4hT-0003W0-7l for qemu-devel@nongnu.org; Wed, 04 Mar 2015 03:30:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YT4hO-00022o-T1 for qemu-devel@nongnu.org; Wed, 04 Mar 2015 03:30:39 -0500 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:42975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YT4hO-00021s-2b for qemu-devel@nongnu.org; Wed, 04 Mar 2015 03:30:34 -0500 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Mar 2015 14:00:27 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Mar 2015 14:00:25 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 0DDDEE005E; Wed, 4 Mar 2015 14:02:16 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay01.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t248UI7l54132942; Wed, 4 Mar 2015 14:00:19 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t248UIlf000980; Wed, 4 Mar 2015 14:00:18 +0530 Received: from abhimanyu.vnet.linux.ibm.com (abhimanyu.in.ibm.com [9.124.35.254] (may be forged)) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t248UHqo000884 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Wed, 4 Mar 2015 14:00:17 +0530 From: Nikunj A Dadhania To: Markus Armbruster In-Reply-To: <87zj7t2pit.fsf@blackfin.pond.sub.org> References: <1425387274-11133-1-git-send-email-nikunj@linux.vnet.ibm.com> <87zj7t2pit.fsf@blackfin.pond.sub.org> User-Agent: Notmuch/0.17+27~gae47d61 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-redhat-linux-gnu) Date: Wed, 04 Mar 2015 14:00:17 +0530 Message-ID: <87vbih6u7a.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15030408-0025-0000-0000-000003A02204 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 122.248.162.7 Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH] Introduce machine specific default memory size 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 Markus Armbruster writes: > Nikunj A Dadhania writes: > >> diff --git a/vl.c b/vl.c >> index eb89d62..dd56754 100644 >> --- a/vl.c >> +++ b/vl.c >> @@ -4053,6 +4053,18 @@ int main(int argc, char **argv, char **envp) >> exit(1); >> } >> >> + if (machine_class->default_ram_size && ram_size < machine_class->default_ram_size) { >> + fprintf(stderr, "qemu: %s guest ram size defaulting to %ld MB\n", >> + machine_class->name, >> + machine_class->default_ram_size / (1024 * 1024)); > > If the user explicitly asks for something, we either provide it > silently, or we error out. This does neither. Why? In case the user has provided memory not enough to boot the machine, I could error out. My idea was to have a sane default which is provided by the machine. Initially, I had just "ram_size == default_ram_size", but then it was allowing "-m 128M" to go through. And the VM would not boot. This can as well be converted to an error report and fail here to boot the VM. > >> + ram_size = machine_class->default_ram_size; >> + >> + /* if maxram size is not provided in options use machine default */ >> + if (maxram_size == default_ram_size) { >> + maxram_size = machine_class->default_ram_size; >> + } >> + } >> + >> /* store value for the future use */ >> qemu_opt_set_number(qemu_find_opts_singleton("memory"), "size", ram_size); > > Does not apply to master, please name your prerequisite patches or > rebase. Rebased patch: Introduce machine specific default memory size Qemu default memory of 128MB is not enough to boot sPAPR guest. Introduce a member in the machine class to override the default memory size enforced by qemu. Signed-off-by: Nikunj A Dadhania diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 23cde20..f6b1137 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1738,6 +1738,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus = MAX_CPUS; mc->no_parallel = 1; mc->default_boot_order = NULL; + mc->default_ram_size = SPAPR_DEFAULT_RAM_SIZE; mc->kvm_type = spapr_kvm_type; mc->has_dynamic_sysbus = true; diff --git a/include/hw/boards.h b/include/hw/boards.h index 3ddc449..b2b4698 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -108,6 +108,7 @@ struct MachineClass { const char *default_display; GlobalProperty *compat_props; const char *hw_version; + ram_addr_t default_ram_size; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 716bff4..d401dd0 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -444,6 +444,9 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr, #define SPAPR_VIO_BASE_LIOBN 0x00000000 #define SPAPR_PCI_BASE_LIOBN 0x80000000 +/* Default to 1GB guest ram_size */ +#define SPAPR_DEFAULT_RAM_SIZE (1ULL << 30) + #define RTAS_ERROR_LOG_MAX 2048 typedef struct sPAPRTCETable sPAPRTCETable; diff --git a/vl.c b/vl.c index 801d487..4519ccc 100644 --- a/vl.c +++ b/vl.c @@ -2684,6 +2684,18 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size) exit(EXIT_FAILURE); } + if (machine_class->default_ram_size && ram_size < machine_class->default_ram_size) { + fprintf(stderr, "qemu: %s guest ram size defaulting to %ld MB\n", + machine_class->name, + machine_class->default_ram_size / (1024 * 1024)); + ram_size = machine_class->default_ram_size; + + /* if maxram size is not provided in options use machine default */ + if (maxram_size == default_ram_size) { + maxram_size = machine_class->default_ram_size; + } + } + /* store value for the future use */ qemu_opt_set_number(opts, "size", ram_size, &error_abort); *maxram_size = ram_size;