From: Ian Jackson Subject: Re: [PATCH RFC 4/9] libxl: use explicit error codes in libxl_ctx_alloc Date: Wed, 24 Jun 2015 16:18:44 +0100 Message-ID: <21898.51796.252901.920727@mariner.uk.xensource.com> References: <1435153656-19485-1-git-send-email-rob.hoes@citrix.com> <1435153656-19485-5-git-send-email-rob.hoes@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z7mRu-00069Q-8f for xen-devel@lists.xenproject.org; Wed, 24 Jun 2015 15:18:50 +0000 In-Reply-To: <1435153656-19485-5-git-send-email-rob.hoes@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: Rob Hoes Cc: xen-devel@lists.xenproject.org, euan.harris@citrix.com List-Id: xen-devel@lists.xenproject.org Rob Hoes writes ("[PATCH RFC 4/9] libxl: use explicit error codes in libxl_ctx_alloc"): > Signed-off-by: Rob Hoes > --- > tools/libxl/libxl.c | 6 +++--- > tools/libxl/libxl_event.c | 2 +- > tools/libxl/libxl_types.idl | 3 +++ > 3 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > index a6eb2df..f622981 100644 > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -89,7 +89,7 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, > LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Failed to initialize mutex"); > free(ctx); > ctx = 0; > - rc = ERROR_FAIL; > + rc = ERROR_LOCK_FAIL; I commented about ERROR_LOCK_FAIL earlier. I think really if the mutex initialisation failed everything is doomed. You probably want to introduce ERROR_LIBXL_PROCESS_SEEMS_TOTALLY_BUST > ctx->xch = xc_interface_open(lg,lg,0); > if (!ctx->xch) { > LOGEV(ERROR, errno, "cannot open libxc handle"); > - rc = ERROR_FAIL; goto out; > + rc = ERROR_XC_CONNECT; goto out; ... > @@ -115,7 +115,7 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, > ctx->xsh = xs_domain_open(); > if (!ctx->xsh) { > LOGEV(ERROR, errno, "cannot connect to xenstore"); > - rc = ERROR_FAIL; goto out; > + rc = ERROR_XS_CONNECT; goto out; Good. > @@ -740,7 +740,7 @@ int libxl__ctx_evtchn_init(libxl__gc *gc) { > xce = xc_evtchn_open(CTX->lg, 0); > if (!xce) { > LOGE(ERROR,"cannot open libxc evtchn handle"); > - rc = ERROR_FAIL; > + rc = ERROR_XC_CONNECT; If you're going to distinguish XS from XC, you probably want to distinguish xce too. It's a different /dev node. If we're categorising errors these are "installation or permissions problem". Ian.