From: Ian Campbell Subject: Re: [PATCH 16/19] libxl: suspend: Abolish usleeps in domain suspend wait Date: Thu, 13 Mar 2014 17:16:29 +0000 Message-ID: <1394730989.16364.29.camel@kazak.uk.xensource.com> References: <1393945016-1417-1-git-send-email-ian.jackson@eu.citrix.com> <1393945016-1417-17-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1393945016-1417-17-git-send-email-ian.jackson@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: Ian Jackson Cc: Shriram Rajagopalan , xen-devel@lists.xensource.com, Lai Jiangshan , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Tue, 2014-03-04 at 14:56 +0000, Ian Jackson wrote: > Replace the use of a loop with usleep(). > > Instead, use a xenstore watch and an event system timeout. xenstore > fires watches on @releaseDomain when a domain shuts down. > > The logic which checks for the state of the domain is unchanged, and > not ideal, but we will leave that for the next patch. > > There is not intended to be any semantic change, other than to make > the algorithm properly asynchronous and the consequential waiting on > xenstore, rather than polling. > > Signed-off-by: Ian Jackson > CC: Stefano Stabellini > CC: Ian Campbell > --- > tools/libxl/libxl_dom.c | 80 ++++++++++++++++++++++++++++++------------ > tools/libxl/libxl_internal.h | 2 ++ > 2 files changed, 60 insertions(+), 22 deletions(-) > > diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c > index dde7e33..6291115 100644 > --- a/tools/libxl/libxl_dom.c > +++ b/tools/libxl/libxl_dom.c > @@ -1028,8 +1028,14 @@ static void domain_suspend_common_wait_guest(libxl__egc *egc, > libxl__domain_suspend_state *dss); > static void domain_suspend_common_guest_suspended(libxl__egc *egc, > libxl__domain_suspend_state *dss); > + > static void domain_suspend_common_pvcontrol_suspending(libxl__egc *egc, > libxl__xswait_state *xswa, int rc, const char *state); > +static void suspend_common_wait_guest_watch(libxl__egc *egc, > + libxl__ev_xswatch *xsw, const char *watch_path, const char *event_path); > +static void suspend_common_wait_guest_timeout(libxl__egc *egc, > + libxl__ev_time *ev, const struct timeval *requested_abs); > + > static void domain_suspend_common_failed(libxl__egc *egc, > libxl__domain_suspend_state *dss); > static void domain_suspend_common_done(libxl__egc *egc, > @@ -1175,36 +1181,59 @@ static void domain_suspend_common_wait_guest(libxl__egc *egc, > libxl__domain_suspend_state *dss) > { > STATE_AO_GC(dss->ao); > + int rc; > + > + LOG(DEBUG, "wait for the guest to suspend"); > + > + rc = libxl__ev_xswatch_register(gc, &dss->guest_watch, > + suspend_common_wait_guest_watch, > + "@releaseDomain"); > + if (rc) goto err; > + > + rc = libxl__ev_time_register_rel(gc, &dss->guest_timeout, > + suspend_common_wait_guest_timeout, > + 60*1000); This smells a lot like the xswait stuff you introduced towards the beginning of the series. Is the difference just that you cannot read the "path" @releaseDomain? If so can we paper over that somehow in the helper? Ian.