From: Ian Campbell Subject: Re: [PATCH 08/19] libxl: wait for qemu to acknowledge logdirty command Date: Tue, 19 Jun 2012 14:33:29 +0100 Message-ID: <1340112809.24176.9.camel@zakaz.uk.xensource.com> References: <1339176870-32652-1-git-send-email-ian.jackson@eu.citrix.com> <1339176870-32652-9-git-send-email-ian.jackson@eu.citrix.com> <1339591954.24104.200.camel@zakaz.uk.xensource.com> <20442.1961.665575.42873@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20442.1961.665575.42873@mariner.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: Ian Jackson Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Thu, 2012-06-14 at 16:47 +0100, Ian Jackson wrote: > Ian Campbell writes ("Re: [Xen-devel] [PATCH 08/19] libxl: wait for qemu to acknowledge logdirty command"): > > On Fri, 2012-06-08 at 18:34 +0100, Ian Jackson wrote: > > > The current migration code in libxl instructs qemu to start or stop > > > logdirty, but it does not wait for an acknowledgement from qemu before > > > continuing. This might lead to memory corruption (!) > ... > > > +static void logdirty_init(libxl__logdirty_switch *lds) > > > +{ > > > + lds->cmd_path = 0; > > > + libxl__ev_xswatch_init(&lds->watch); > > > + libxl__ev_time_init(&lds->timeout); > > > > I meant to mention this once before when reviewing some patch or other > > but I'm not sure I actually did, so at the risk of repeating myself: > > > > This watch with timeout pattern seems to be reasonably common (in fact, > > I'm not sure we have any watches without a timeout). It might be a > > candidate for a specific helper routine in the future? > > Perhaps. We should think about this. Yes, I should have said the phrase "4.3" in there somewhere. > I'm not sure it's necessary > now. The benefit might be relatively small, as the callback function > would more complicated. Could still have two callbacks, and just helpers for the setup & teardown phases? > Perhaps we should integrate the single xs read which most of these callers also have. You mean pass in the value of the watched key? That's also a possibility. > > > > +static void switch_logdirty_xswatch(libxl__egc *egc, libxl__ev_xswatch *watch, > > > + const char *watch_path, const char *event_path) > > > +{ > ... > > > + out: > > > + /* rc < 0: error > > > + * rc == 0: ok, we are done > > > + * rc == +1: need to keep waiting > > > + */ > > > + libxl__xs_transaction_abort(gc, &t); > > > + > > > + if (!rc) { > > > + switch_logdirty_done(egc,dss,1); > > > + } else if (rc < 0) { > > > + LOG(ERROR,"logdirty switch: response read failed (rc=%d)",rc); > > > > Is it only "response read failed" which can cause us to end up here, > > looks like the read, rm etc could do it? > > Oh yes. I should fix that message. (All of these paths have already > logged something already, but another message probably doesn't hurt.) > > Thanks, > Ian.