From: Ian Campbell Subject: Re: [PATCH v1 01/10] libxl: libxl-json format and internal functions to get / set it Date: Wed, 16 Jul 2014 17:11:22 +0100 Message-ID: <1405527082.1087.54.camel@kazak.uk.xensource.com> References: <1405002745-5034-1-git-send-email-wei.liu2@citrix.com> <1405002745-5034-2-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1405002745-5034-2-git-send-email-wei.liu2@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: Wei Liu Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, 2014-07-10 at 15:32 +0100, Wei Liu wrote: > diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c > index 81f8985..dc47177 100644 > --- a/tools/libxl/libxl_internal.c > +++ b/tools/libxl/libxl_internal.c > @@ -381,6 +381,62 @@ out: > return rc; > } > > +int libxl__get_domain_configuration(libxl__gc *gc, uint32_t domid, > + libxl_domain_config *d_config) > +{ > + uint8_t *data = NULL; > + int rc, len; > + > + rc = libxl_userdata_retrieve(CTX, domid, "libxl-json", &data, &len); > + if (rc) { > + LOGEV(ERROR, rc, > + "failed to retrieve domain configuration for domain %d", domid); > + rc = ERROR_FAIL; rc here is already a valid libxl ERROR_* here, isn't it? No need to override in that case. You have this several times in this series.. > + goto out; > + } > + > + if (len == 0) { > + LOGE(ERROR, "configuration data stream empty for domain %d", domid); > + rc = ERROR_FAIL; This one on the other hand does need setting explicitly. How could this happen though? Ian J is in favour of adding more error codes instead of constantly reusing ERROR_FAIL. Here it would seem that depending on whether/how this is supposed to happen either a ERROR_INTERNAL_MELTDOWN (i.e. everythig has gone wrong) ish thing or ERROR_NO_DOMAIN_CONFIG would be appropriate. Ian.