From c0c2ed2bf56a94419796130665f7c946b999f9d2 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Wed, 3 Nov 2021 12:21:46 +0100 Subject: [PATCH] tool/run: make qemu RAM sanity check more robust First, the former implementation has only considered the pure numerical variant of the -m argument. Yet, qemu also allows specifying the amount of memory by `-m 1G`, `-m size=1G` and more. Second, the default amount of memory for BOARD=pc was 512M (800M in case of okl4). Since the depot_autopilot.run also required at least 768M on all platforms it seems reasonable to take 800M as a default value for BOARD=pc and thereby remove the special treatment of okl4. genodelabs/genode#4311 --- repos/gems/run/depot_autopilot.run | 2 +- tool/run/power_on/qemu | 39 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/repos/gems/run/depot_autopilot.run b/repos/gems/run/depot_autopilot.run index 060a31fe4e..bbc8c0cac3 100644 --- a/repos/gems/run/depot_autopilot.run +++ b/repos/gems/run/depot_autopilot.run @@ -456,7 +456,7 @@ proc prepare_to_run_genode { } { set serial_id -1 set timeout 40 - append qemu_args "-m 800 -nographic " + append qemu_args " -nographic " } diff --git a/tool/run/power_on/qemu b/tool/run/power_on/qemu index 39bc704c0b..48cd20f0e2 100644 --- a/tool/run/power_on/qemu +++ b/tool/run/power_on/qemu @@ -124,28 +124,33 @@ proc run_power_on { } { # on x86, we support booting via pxe or iso/disk image if {[have_board pc]} { - if {[have_spec okl4]} { - # okl4 system integration specifies RAM from 32 to 800 MiB - set qemu_ram 800 - } else { - set qemu_ram 512 - } - if {[regexp -- {-m} $qemu_args dummy]} { - set qemu_ram [regexp -inline {\-m.[0-9]+} $qemu_args] - set qemu_ram [regexp -inline {[0-9]+} $qemu_ram] - } - - if {[have_spec okl4]} { - if {$qemu_ram < 800} { - puts "Configured memory ($qemu_ram) for OKL4 on Qemu must be at least 800M\n" + if {[regexp -- {-m\s+} $qemu_args dummy]} { + # can be -m 1024 or -m 1024G or -m size=1024G + set qemu_ram [regexp -inline {\-m\s+\S+} $qemu_args] + if {![regexp {([0-9]+)([MG]?)} $qemu_ram dummy qemu_ram ram_unit]} { + puts "Cannot parse memory argument ($qemu_ram)\n" exit 1 } + + if { $ram_unit == "G" } { + set qemu_ram [expr {$qemu_ram*1024}] } + + if {[have_spec okl4]} { + if {$qemu_ram < 800} { + puts "Configured memory ($qemu_ram) for OKL4 on Qemu must be at least 800M\n" + exit 1 + } + } + } else { + ## + # append memory argument if not present, 800M is a sane default because: + # - 800M is minimum for OKL4 + # - 768M is required for certain test cases (#3387) + # + append qemu_args " -m 800 " } - append qemu_args " -m $qemu_ram " - - if {[have_include "load/tftp"]} { append qemu_args " -boot n -tftp [run_dir] -bootp boot/pulsar -no-reboot -no-shutdown " } else {