From: Rob Hoes Subject: [PATCH RFC 5/9] libxl: introduce specific JSON error codes Date: Wed, 24 Jun 2015 14:47:32 +0100 Message-ID: <1435153656-19485-6-git-send-email-rob.hoes@citrix.com> References: <1435153656-19485-1-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.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z7l27-0005Ou-Ih for xen-devel@lists.xenproject.org; Wed, 24 Jun 2015 13:48:07 +0000 In-Reply-To: <1435153656-19485-1-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: xen-devel@lists.xenproject.org Cc: euan.harris@citrix.com, Ian.Jackson@eu.citrix.com, Rob Hoes List-Id: xen-devel@lists.xenproject.org Signed-off-by: Rob Hoes --- tools/libxl/libxl_dom.c | 6 +++--- tools/libxl/libxl_internal.c | 4 +--- tools/libxl/libxl_json.c | 4 ++-- tools/libxl/libxl_types.idl | 5 +++++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index a0c9850..efdb570 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -2323,7 +2323,7 @@ int libxl__userdata_store(libxl__gc *gc, uint32_t domid, goto out; } - rc = ERROR_FAIL; + rc = ERROR_JSON_SET_CONFIG; fd = open(newfilename, O_RDWR | O_CREAT | O_TRUNC, 0600); if (fd < 0) @@ -2400,13 +2400,13 @@ int libxl__userdata_retrieve(libxl__gc *gc, uint32_t domid, e = libxl_read_file_contents(CTX, filename, data_r ? &data : 0, &datalen); if (e && errno != ENOENT) { - rc = ERROR_FAIL; + rc = ERROR_JSON_GET_CONFIG; goto out; } if (!e && !datalen) { LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "userdata file %s is empty", filename); if (data_r) assert(!*data_r); - rc = ERROR_FAIL; + rc = ERROR_JSON_GET_CONFIG; goto out; } diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index c2c67bd..4ac43f8 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -500,7 +500,6 @@ int libxl__get_domain_configuration(libxl__gc *gc, uint32_t domid, if (rc) { LOGEV(ERROR, rc, "failed to retrieve domain configuration for domain %d", domid); - rc = ERROR_FAIL; goto out; } @@ -527,7 +526,7 @@ int libxl__set_domain_configuration(libxl__gc *gc, uint32_t domid, LOGE(ERROR, "failed to convert domain configuration to JSON for domain %d", domid); - rc = ERROR_FAIL; + rc = ERROR_JSON_SET_CONFIG; goto out; } @@ -537,7 +536,6 @@ int libxl__set_domain_configuration(libxl__gc *gc, uint32_t domid, if (rc) { LOGEV(ERROR, rc, "failed to store domain configuration for domain %d", domid); - rc = ERROR_FAIL; goto out; } diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c index 346929a..973d535 100644 --- a/tools/libxl/libxl_json.c +++ b/tools/libxl/libxl_json.c @@ -1044,14 +1044,14 @@ int libxl__object_from_json(libxl_ctx *ctx, const char *type, LOG(ERROR, "unable to generate libxl__json_object from JSON representation of %s.", type); - rc = ERROR_FAIL; + rc = ERROR_JSON_PARSE_CONFIG; goto out; } rc = parse(gc, o, p); if (rc) { LOG(ERROR, "unable to convert libxl__json_object to %s. (rc=%d)", type, rc); - rc = ERROR_FAIL; + rc = ERROR_JSON_PARSE_CONFIG; goto out; } diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 52795e4..b905353 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -117,6 +117,11 @@ libxl_error = Enumeration("error", [ # libxc connection error (ENUM_PREV, "XC_CONNECT"), + + # JSON domain config errors + (ENUM_PREV, "JSON_GET_CONFIG"), + (ENUM_PREV, "JSON_SET_CONFIG"), + (ENUM_PREV, "JSON_PARSE_CONFIG"), ], value_namespace = "") libxl_domain_type = Enumeration("domain_type", [ -- 2.4.1