@@ -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,
@@ -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);
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 <peter.maydell@linaro.org> --- hw/boards.h | 1 + vl.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletions(-)