qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, armbru@redhat.com,
	nikunj@linux.vnet.ibm.com, thuth@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH v2] Introduce machine specific default memory size
Date: Wed,  4 Mar 2015 16:48:05 +0530	[thread overview]
Message-ID: <1425467885-26712-1-git-send-email-nikunj@linux.vnet.ibm.com> (raw)

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 <nikunj@linux.vnet.ibm.com>
---
 hw/ppc/spapr.c         | 1 +
 include/hw/boards.h    | 1 +
 include/hw/ppc/spapr.h | 3 +++
 vl.c                   | 9 +++++++++
 4 files changed, 14 insertions(+)

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..447b993 100644
--- a/vl.c
+++ b/vl.c
@@ -2649,6 +2649,7 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)
     const ram_addr_t default_ram_size = (ram_addr_t)DEFAULT_RAM_SIZE *
                                         1024 * 1024;
     QemuOpts *opts = qemu_find_opts_singleton("memory");
+    MachineClass *machine_class;
 
     sz = 0;
     mem_str = qemu_opt_get(opts, "size");
@@ -2684,6 +2685,14 @@ static void set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size)
         exit(EXIT_FAILURE);
     }
 
+    machine_class = find_default_machine();
+    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;
+    }
+
     /* store value for the future use */
     qemu_opt_set_number(opts, "size", ram_size, &error_abort);
     *maxram_size = ram_size;
-- 
1.8.3.1

             reply	other threads:[~2015-03-04 11:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 11:18 Nikunj A Dadhania [this message]
2015-03-04 12:21 ` [Qemu-devel] [PATCH v2] Introduce machine specific default memory size Igor Mammedov
2015-03-04 12:32   ` Marcel Apfelbaum
2015-03-04 15:39     ` Igor Mammedov
2015-03-04 12:21 ` [Qemu-devel] [Qemu-ppc] " Alexander Graf
2015-03-04 12:34   ` Marcel Apfelbaum
2015-03-04 12:26 ` [Qemu-devel] " Marcel Apfelbaum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425467885-26712-1-git-send-email-nikunj@linux.vnet.ibm.com \
    --to=nikunj@linux.vnet.ibm.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).