OSSTest: get host free memory size
v2 cover OSSTest: get host free memory size
Originally ts-debian-hvm-install deliberately asks for large amount of guest memory, but the host may not have enough free memory to create the guest.
This patch series makes ts-debian-hvm-install start with a conservative value and only increase guest memory size if it can be satisfied.
Wei.
Wei Liu (2):
TestSupport.pm: introduce host_get_free_memory
ts-debian-hvm-install: fix guest memory size
Osstest/TestSupport.pm | 10 ++++++++++ ts-debian-hvm-install | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.10.4
PATCH v2 1/2 TestSupport.pm: introduce host_get_free_memory
... which returns the size of free memory in MB.
--- Osstest/TestSupport.pm | 10 ++++++++++ 1 file changed, 10 insertions(+)
Osstest/TestSupport.pm +10 -0
@@ -79,6 +79,7 @@ BEGIN { remote_perl_script_open remote_perl_script_done host_reboot target_reboot target_reboot_hard target_choose_vg target_umount_lv target_await_down + host_get_free_memory target_ping_check_down target_ping_check_up target_kernkind_check target_kernkind_console_inittab
@@ -915,6 +916,15 @@ sub host_reboot ($) { }); } +sub host_get_free_memory($$) { + my ($ho,$toolstack) = @_; + # The line is as followed: + # free_memory : XXXX + my $info = target_cmd_output_root($ho, "$toolstack info", 10); + my @matched = $info =~ /free_memory\s*:\s*(\d+)/; + return $matched[0]; +} + sub target_reboot ($) { my ($ho) = @_; target_cmd_root($ho, "init 6");
Signature · 1 line
1.7.10.4
Re: [PATCH V2 1/2] TestSupport.pm: introduce host_get_free_memory
Wei Liu writes ("[PATCH V2 1/2] TestSupport.pm: introduce host_get_free_memory"):
Quoted 1 line
... which returns the size of free memory in MB.
...
Thanks, this is much better.
Osstest/TestSupport.pm sub host_reboot ($) { · line 924
Quoted 6 lines
Osstest/TestSupport.pm +6
-0+sub host_get_free_memory($$) { + my ($ho,$toolstack) = @_; + # The line is as followed: + # free_memory : XXXX + my $info = target_cmd_output_root($ho, "$toolstack info", 10); + my @matched = $info =~ /free_memory\s*:\s*(\d+)/;
But maybe you wanted
/^free_memory\s*:\s*(\d+)\s*$/m;
Also, you should die if the regexp doesn't match, rather than returning undef.
Ian.
PATCH v2 2/2 ts-debian-hvm-install: fix guest memory size
In reply to Wei LiuIf the host has more than 5G free memory, change guest memory size to 5G to catch any error that triggers by crossing 4G boundary. Otherwise guest memory size is set to 768 MB (taken from ts-redhat-install) which should be a safe value to run this testcase on every host.
--- ts-debian-hvm-install | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
ts-debian-hvm-install +14 -1
@@ -32,7 +32,8 @@ $gn ||= 'ovmf'; our $ho= selecthost($whhost); -our $ram_mb= 6000; +# guest memory size will be set based on host free memory, see below +our $ram_mb= 0; our $disk_mb= 10000; our $guesthost= "$gn.guest.osstest";
@@ -166,6 +167,18 @@ sub prep () { }); } +# If host has >5G free memory, create a guest with 5G memory to catch any error +# that triggers cross 4G boundary +my $host_freemem_mb = host_get_free_memory($ho, $toolstack); +my $ram_minslop = 100; +my $ram_lots = 5000; +if ($host_freemem_mb > $ram_lots + $ram_minslop) { + $ram_mb = $ram_lots; +} else { + $ram_mb = 768; +} +logm("Host has $host_freemem_mb MB free memory, setting guest memory size to $ram_mb MB"); + if (!$stage) { prep(); guest_create($gho,$toolstack);
Signature · 1 line
1.7.10.4
Re: [PATCH V2 2/2] ts-debian-hvm-install: fix guest memory size
Wei Liu writes ("[PATCH V2 2/2] ts-debian-hvm-install: fix guest memory size"):
Quoted 4 lines
If the host has more than 5G free memory, change guest memory size to 5G to catch any error that triggers by crossing 4G boundary. Otherwise guest memory size is set to 768 MB (taken from ts-redhat-install) which should be a safe value to run this testcase on every host.
Thanks. I just have nits to complain about in this one.
ts-debian-hvm-install $gn ||= 'ovmf'; · line 36
Quoted 3 lines
ts-debian-hvm-install +2
-1-our $ram_mb= 6000; +# guest memory size will be set based on host free memory, see below +our $ram_mb= 0;
Why do you initialise this to 0 ?
Quoted 1 line
+# If host has >5G free memory, create a guest with 5G memory to catch any er
ror
Quoted 1 line
+# that triggers cross 4G boundary
This comment could do with wrapping to 70ish rather than exactly 80, so that it is readable even with the "+" in front and when quoted.
Thanks,
Ian.