From: Wei Liu Subject: Re: [PATCH v2 2/4] libxl_wait_for_memory_target: wait as long as dom0 is making progress Date: Mon, 9 Mar 2015 11:17:19 +0000 Message-ID: <20150309111719.GN18491@zion.uk.xensource.com> References: <1425662357-9951-2-git-send-email-stefano.stabellini@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1425662357-9951-2-git-send-email-stefano.stabellini@eu.citrix.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: Stefano Stabellini Cc: Ian.Jackson@eu.citrix.com, xen-devel@lists.xensource.com, wei.liu2@citrix.com, Ian.Campbell@citrix.com, mlatimer@suse.com List-Id: xen-devel@lists.xenproject.org On Fri, Mar 06, 2015 at 05:19:15PM +0000, Stefano Stabellini wrote: [...] > int libxl_wait_for_free_memory(libxl_ctx *ctx, uint32_t domid, uint32_t memory_kb, int wait_secs); > -/* wait for the memory target of a domain to be reached */ > +/* > + * Wait for the memory target of a domain to be reached. Does not > + * decrement wait_secs if the domain is making progress toward reaching > + * the target. If the domain is not making progress, wait_secs is > + * decremented. If the timeout expires before the target is reached, the > + * function returns ERROR_FAIL. > + * > + * Older versions of this function (Xen 4.5 and older), decremented > + * wait_secs even if the domain was making progress, resulting in far > + * lower overall wait times. To make sure that your calling routine > + * works with new and old implementations of the function, pass enough > + * time for the guest to reach its target as an argument. > + */ Need to have a #define LIBXL_HAVE_$FOO to mark the change in behaviour, so that client can cope with this change. Wei. > int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t domid, int wait_secs); > > int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass); > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index f4c4122..2dc7574 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -2226,8 +2226,8 @@ static int freemem(uint32_t domid, libxl_domain_build_info *b_info) > else if (rc != ERROR_NOMEM) > return rc; > > - /* the memory target has been reached but the free memory is still > - * not enough: loop over again */ > + /* wait until dom0 reaches its target, as long as we are making > + * progress */ > rc = libxl_wait_for_memory_target(ctx, 0, 1); > if (rc < 0) > return rc; > -- > 1.7.10.4