[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST Nested PATCH v10 5/9] Move the code for setting memory size into prep()



Move the code for setting memory size from outside into prep(),
where these $ram_mb operations are only used; And in next patch,
for L2 guest installation, $ram_mb will be overridden by a runvar value,
which needs $gho in scope.

This is pure code motion. No functional change.

Signed-off-by: longtao.pang <longtaox.pang@xxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 ts-debian-hvm-install |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/ts-debian-hvm-install b/ts-debian-hvm-install
index b37f0f9..d3413e1 100755
--- a/ts-debian-hvm-install
+++ b/ts-debian-hvm-install
@@ -156,6 +156,18 @@ sub prep () {
     target_putfilecontents_root_stash($ho, 10, preseed(),
                                       $preseed_file_path);
 
+    # If host has >8G free memory, create a guest with 4G memory to catch
+    # any error that triggers cross 4G boundary
+    my $host_freemem_mb = host_get_free_memory($ho);
+    my $ram_minslop = 100;
+    my $ram_lots = 5000;
+    if ($host_freemem_mb > $ram_lots * 2 + $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");
+
     more_prepareguest_hvm($ho,$gho, $ram_mb, $disk_mb,
                           OnReboot => 'preserve',
                           Bios => $r{bios},
@@ -173,18 +185,6 @@ sub prep () {
     });
 }
 
-# If host has >8G free memory, create a guest with 4G memory to catch
-# any error that triggers cross 4G boundary
-my $host_freemem_mb = host_get_free_memory($ho);
-my $ram_minslop = 100;
-my $ram_lots = 5000;
-if ($host_freemem_mb > $ram_lots * 2 + $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);
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.