From: Ian Campbell Subject: Re: [PATCH 07/11] libxl: do not blunder on if bootloader fails (again) Date: Thu, 2 Aug 2012 11:22:06 +0100 Message-ID: <1343902926.27221.122.camel@zakaz.uk.xensource.com> References: <1343838260-17725-1-git-send-email-ian.jackson@eu.citrix.com> <1343838260-17725-8-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: <1343838260-17725-8-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: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Wed, 2012-08-01 at 17:24 +0100, Ian Jackson wrote: > Do not lose the rc value passed to bootloader_callback. Do not lose > the rc value from the bl when the local disk detach succeeds. > > While we're here rationalise the use of bl->rc to make things clearer. > Set it to zero at the start and always update it conditionally; copy > it into bootloader_callback's argument each time. > > Signed-off-by: Ian Jackson Acked-by: Ian Campbell > --- > tools/libxl/libxl_bootloader.c | 11 +++++++++-- > 1 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c > index bfc1b56..e103ee9 100644 > --- a/tools/libxl/libxl_bootloader.c > +++ b/tools/libxl/libxl_bootloader.c > @@ -206,6 +206,7 @@ static int parse_bootloader_result(libxl__egc *egc, > void libxl__bootloader_init(libxl__bootloader_state *bl) > { > assert(bl->ao); > + bl->rc = 0; > bl->dls.diskpath = NULL; > bl->openpty.ao = bl->ao; > bl->dls.ao = bl->ao; > @@ -255,6 +256,9 @@ static void bootloader_local_detached_cb(libxl__egc *egc, > static void bootloader_callback(libxl__egc *egc, libxl__bootloader_state *bl, > int rc) > { > + if (!bl->rc) > + bl->rc = rc; > + > bootloader_cleanup(egc, bl); > > bl->dls.callback = bootloader_local_detached_cb; > @@ -270,9 +274,11 @@ static void bootloader_local_detached_cb(libxl__egc *egc, > > if (rc) { > LOG(ERROR, "unable to detach locally attached disk"); > + if (!bl->rc) > + bl->rc = rc; > } > > - bl->callback(egc, bl, rc); > + bl->callback(egc, bl, bl->rc); > } > > /* might be called at any time, provided it's init'd */ > @@ -289,7 +295,8 @@ static void bootloader_stop(libxl__egc *egc, > if (r) LOGE(WARN, "%sfailed to kill bootloader [%lu]", > rc ? "after failure, " : "", (unsigned long)bl->child.pid); > } > - bl->rc = rc; > + if (!bl->rc) > + bl->rc = rc; > } > > /*----- main flow of control -----*/