From: Ian Jackson Subject: Re: [PATCH 2/2] ts-debian-hvm-install: fix guest memory size Date: Mon, 14 Apr 2014 15:59:12 +0100 Message-ID: <21323.63424.809108.357028@mariner.uk.xensource.com> References: <1397474223-24387-1-git-send-email-wei.liu2@citrix.com> <1397474223-24387-3-git-send-email-wei.liu2@citrix.com> <21323.62612.597934.567330@mariner.uk.xensource.com> <20140414145442.GB3635@zion.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20140414145442.GB3635@zion.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: ian.campbell@citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Wei Liu writes ("Re: [PATCH 2/2] ts-debian-hvm-install: fix guest memory size"): > That's because there's a "slack" required when building a domain. > Hmm... > > I can check for 5010 then set guest memory to 5000. What do you think? Yes. Perhaps the slop you allow ought to be a bit bigger. > > Also I don't like the separation of the two values for $ram_mb. The > > manifest constant at the top of the script is misleading given that > > the code might override it. I think you probably want to bury the > > magic constant(s) in with the setting code. > > Do you mean > if ($host_freemem_mb > 5000){ > $ram_mb = 5000; > } else { > $ram_mb = 768; > } Yes, something like that. Perhaps: my $ram_minslop = 100; my $ram_lots = 5000; if ($host_freemem_mb > $ram_lots + $ram_minslop) { $ram_mb = $ram_lots; } else { $ram_mb = 768; } because it avoids writing 5000 twice. Ian.