OSSTest: get host free memory size
v3 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 | 11 +++++++++++ ts-debian-hvm-install | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.10.4
PATCH v3 1/2 TestSupport.pm: introduce host_get_free_memory
... which returns the size of free memory in MB.
--- Osstest/TestSupport.pm | 11 +++++++++++ 1 file changed, 11 insertions(+)
Osstest/TestSupport.pm +11 -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,16 @@ 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+)\s*$/m; + @matched or die "fail to get host free memory"; + return $matched[0]; +} + sub target_reboot ($) { my ($ho) = @_; target_cmd_root($ho, "init 6");
Signature · 1 line
1.7.10.4
PATCH v3 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; 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 V3 2/2] ts-debian-hvm-install: fix guest memory size
Wei Liu writes ("[PATCH V3 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.
Re: [PATCH V3 1/2] TestSupport.pm: introduce host_get_free_memory
In reply to Wei LiuWei Liu writes ("[PATCH V3 1/2] TestSupport.pm: introduce host_get_free_memory"):
Quoted 1 line
... which returns the size of free memory in MB.
Thanks.
...
Osstest/TestSupport.pm sub host_reboot ($) { · line 925
Quoted 7 lines
Osstest/TestSupport.pm +7
-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+)\s*$/m; + @matched or die "fail to get host free memory";
I have one tiny quibble: the error message (which helpfully includes a descriptive string unlike much of the rest of osstest) fails to include the contents of $info. In general it is a good idea in osstest to include the complete text which has failed a regexp match. That greatly assists debugging.
(When you do that you need to make sure that the $info doesn't appear right at the end of the message, because if the message ends in a newline it suppresses perl's addition of the script line number. Adding " ?" or "'" or something is sufficient.)
Can you change that, and then send me a git pull request style email with a reference to a git branch ? I'll then send it into the osstest push gate as soon as it's free.
Thanks,
Ian.
Re: [PATCH V3 1/2] TestSupport.pm: introduce host_get_free_memory
Quoted 20 lines · Ian Jackson
Wei Liu writes ("[PATCH V3 1/2] TestSupport.pm: introduce
host_get_free_memory"):Quoted 1 line
... which returns the size of free memory in MB.
Thanks.
...
Osstest/TestSupport.pm sub host_reboot ($) { · line 925
Quoted 7 lines
Osstest/TestSupport.pm +7
-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+)\s*$/m; + @matched or die "fail to get host free memory";I have one tiny quibble: the error message (which helpfully includes a descriptive string unlike much of the rest of osstest) fails to include the contents of $info. In general it is a good idea in osstest to include the complete text which has failed a regexp match. That greatly assists debugging.
Quoted 8 lines
(When you do that you need to make sure that the $info doesn't appear right at the end of the message, because if the message ends in a newline it suppresses perl's addition of the script line number. Adding " ?" or "'" or something is sufficient.)
Can you change that, and then send me a git pull request style email with a reference to a git branch ? I'll then send it into the osstest push gate as soon as it's free.
Please pull from
git://xenbits.xen.org/people/liuw/osstest.git get-host-free-memory
Wei.
Re: [PATCH V3 1/2] TestSupport.pm: introduce host_get_free_memory
Wei Liu writes ("Re: [PATCH V3 1/2] TestSupport.pm: introduce host_get_free_memory"):
Quoted 8 lines · Ian Jackson
Quoted 3 lines
Can you change that, and then send me a git pull request style email with a reference to a git branch ? I'll then send it into the osstest push gate as soon as it's free.
Please pull from
git://xenbits.xen.org/people/liuw/osstest.gitget-host-free-memory
Thanks. I'll ack the modified 1/2 and push it at an appropriate moment.
Thanks,
Ian.