From: Ian Campbell Subject: Re: [PATCH 27/29] [VERY RFC] tools/libxl: Support restoring legacy streams Date: Thu, 11 Sep 2014 13:36:57 +0100 Message-ID: <1410439017.25388.11.camel@kazak.uk.xensource.com> References: <1410369067-1330-1-git-send-email-andrew.cooper3@citrix.com> <1410369067-1330-28-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1410369067-1330-28-git-send-email-andrew.cooper3@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: Andrew Cooper Cc: Ian Jackson , Xen-devel List-Id: xen-devel@lists.xenproject.org On Wed, 2014-09-10 at 18:11 +0100, Andrew Cooper wrote: > This WorksForMe in the success case, but the error handling is certainly lacking. > > Specifically, the conversion scripts output fd can't be closed until the v2 > read loop has exited (cleanly or otherwise), without risking a close()/open() > race silently replacing the fd behind the loops back. > > However, it can't be closed when the read loop exits, as the conversion script > child might still be alive, and would prefer terminating cleaning than failing > with a bad FD. > > Obviously, having one error handler block for the success/failure of the other > side is a no-go, and would still involve a preselecting which was expected to > exit first. > > Does anyone have any clever ideas of how to asynchronously collect the events > "the conversion script has exited", "the save helper has exited" and "the v2 > read loop has finished" given the available infrastructure, to kick of a > combined cleanup of all 3? > > (I also need to fix the conversion script info/error logging, but that is a > distinctly more minor problem.) This is probably one for Ian when he gets back, but a state machine which is cranked in response to the callbacks from the various completion events might be one way to approach this.