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
This commit is contained in:
Johannes Schlatow 2021-11-03 12:21:46 +01:00 committed by Christian Helmuth
parent c774272366
commit c0c2ed2bf5
2 changed files with 23 additions and 18 deletions

View File

@ -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 "
}

View File

@ -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 {