From: Alex Bligh <alex@alex.org.uk>
To: xen-devel <xen-devel@lists.xen.org>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>, Alex Bligh <alex@alex.org.uk>
Subject: [PATCH 01/11] libxl_json: Export json_object related function.
Date: Sat, 19 Jan 2013 17:57:58 +0000 [thread overview]
Message-ID: <1358618288-17109-2-git-send-email-alex@alex.org.uk> (raw)
In-Reply-To: <1358618288-17109-1-git-send-email-alex@alex.org.uk>
Export libxl__json_object_alloc and libxl__json_object_append_to to
use them in a later patch.
Backported from xen-unstable patch:
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693129 -3600
: Node ID c9b80c7f8db1a5d26906a2298c481bf7e87fda94
: Parent 93e3e6a33e0a1ec9f92fc575334caa35e6dbc757
Signed-off-by: Alex Bligh <alex@alex.org.uk>
---
tools/libxl/libxl_internal.h | 14 ++++++++++++--
tools/libxl/libxl_json.c | 32 ++++++++++++++++----------------
2 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index a135cd7..2959527 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1512,6 +1512,15 @@ static inline long long libxl__json_object_get_integer(const libxl__json_object
return -1;
}
+/*
+ * NOGC can be used with those json_object functions, but the
+ * libxl__json_object* will need to be freed with libxl__json_object_free.
+ */
+_hidden libxl__json_object *libxl__json_object_alloc(libxl__gc *gc_opt,
+ libxl__json_node_type type);
+_hidden int libxl__json_object_append_to(libxl__gc *gc_opt,
+ libxl__json_object *obj,
+ libxl__json_object *dst);
_hidden libxl__json_object *libxl__json_array_get(const libxl__json_object *o,
int i);
_hidden
@@ -1520,9 +1529,10 @@ libxl__json_map_node *libxl__json_map_node_get(const libxl__json_object *o,
_hidden const libxl__json_object *libxl__json_map_get(const char *key,
const libxl__json_object *o,
libxl__json_node_type expected_type);
-_hidden void libxl__json_object_free(libxl__gc *gc, libxl__json_object *obj);
+_hidden void libxl__json_object_free(libxl__gc *gc_opt,
+ libxl__json_object *obj);
-_hidden libxl__json_object *libxl__json_parse(libxl__gc *gc, const char *s);
+_hidden libxl__json_object *libxl__json_parse(libxl__gc *gc_opt, const char *s);
/* Based on /local/domain/$domid/dm-version xenstore key
* default is qemu xen traditional */
diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c
index caa8312..0b0cf2f 100644
--- a/tools/libxl/libxl_json.c
+++ b/tools/libxl/libxl_json.c
@@ -205,7 +205,7 @@ yajl_gen_status libxl__string_gen_json(yajl_gen hand,
* libxl__json_object helper functions
*/
-static libxl__json_object *json_object_alloc(libxl__gc *gc,
+libxl__json_object *libxl__json_object_alloc(libxl__gc *gc,
libxl__json_node_type type)
{
libxl__json_object *obj;
@@ -236,7 +236,7 @@ static libxl__json_object *json_object_alloc(libxl__gc *gc,
return obj;
}
-static int json_object_append_to(libxl__gc *gc,
+int libxl__json_object_append_to(libxl__gc *gc,
libxl__json_object *obj,
libxl__json_object *dst)
{
@@ -393,10 +393,10 @@ static int json_callback_null(void *opaque)
DEBUG_GEN(ctx, null);
- if ((obj = json_object_alloc(ctx->gc, JSON_NULL)) == NULL)
+ if ((obj = libxl__json_object_alloc(ctx->gc, JSON_NULL)) == NULL)
return 0;
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
libxl__json_object_free(ctx->gc, obj);
return 0;
}
@@ -411,11 +411,11 @@ static int json_callback_boolean(void *opaque, int boolean)
DEBUG_GEN_VALUE(ctx, bool, boolean);
- if ((obj = json_object_alloc(ctx->gc,
+ if ((obj = libxl__json_object_alloc(ctx->gc,
boolean ? JSON_TRUE : JSON_FALSE)) == NULL)
return 0;
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
libxl__json_object_free(ctx->gc, obj);
return 0;
}
@@ -448,7 +448,7 @@ static int json_callback_number(void *opaque, const char *s, libxl_yajl_length l
goto error;
}
- if ((obj = json_object_alloc(ctx->gc, JSON_DOUBLE)) == NULL)
+ if ((obj = libxl__json_object_alloc(ctx->gc, JSON_DOUBLE)) == NULL)
return 0;
obj->u.d = d;
} else {
@@ -458,7 +458,7 @@ static int json_callback_number(void *opaque, const char *s, libxl_yajl_length l
goto error;
}
- if ((obj = json_object_alloc(ctx->gc, JSON_INTEGER)) == NULL)
+ if ((obj = libxl__json_object_alloc(ctx->gc, JSON_INTEGER)) == NULL)
return 0;
obj->u.i = i;
}
@@ -466,7 +466,7 @@ static int json_callback_number(void *opaque, const char *s, libxl_yajl_length l
error:
/* If the conversion fail, we just store the original string. */
- if ((obj = json_object_alloc(ctx->gc, JSON_NUMBER)) == NULL)
+ if ((obj = libxl__json_object_alloc(ctx->gc, JSON_NUMBER)) == NULL)
return 0;
t = malloc(len + 1);
@@ -481,7 +481,7 @@ error:
obj->u.string = t;
out:
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
libxl__json_object_free(ctx->gc, obj);
return 0;
}
@@ -508,13 +508,13 @@ static int json_callback_string(void *opaque, const unsigned char *str,
strncpy(t, (const char *) str, len);
t[len] = 0;
- if ((obj = json_object_alloc(ctx->gc, JSON_STRING)) == NULL) {
+ if ((obj = libxl__json_object_alloc(ctx->gc, JSON_STRING)) == NULL) {
free(t);
return 0;
}
obj->u.string = t;
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
libxl__json_object_free(ctx->gc, obj);
return 0;
}
@@ -573,11 +573,11 @@ static int json_callback_start_map(void *opaque)
DEBUG_GEN(ctx, map_open);
- if ((obj = json_object_alloc(ctx->gc, JSON_MAP)) == NULL)
+ if ((obj = libxl__json_object_alloc(ctx->gc, JSON_MAP)) == NULL)
return 0;
if (ctx->current) {
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
libxl__json_object_free(ctx->gc, obj);
return 0;
}
@@ -615,11 +615,11 @@ static int json_callback_start_array(void *opaque)
DEBUG_GEN(ctx, array_open);
- if ((obj = json_object_alloc(ctx->gc, JSON_ARRAY)) == NULL)
+ if ((obj = libxl__json_object_alloc(ctx->gc, JSON_ARRAY)) == NULL)
return 0;
if (ctx->current) {
- if (json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
+ if (libxl__json_object_append_to(ctx->gc, obj, ctx->current) == -1) {
libxl__json_object_free(ctx->gc, obj);
return 0;
}
--
1.7.4.1
next prev parent reply other threads:[~2013-01-19 17:57 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-19 17:57 QEMU: Enabling live-migrate on HVM on qemu-xen device model in 4.2 Alex Bligh
2013-01-19 17:57 ` Alex Bligh [this message]
2013-02-12 15:43 ` [PATCH 01/11] libxl_json: Export json_object related function Ian Jackson
2013-01-19 17:57 ` [PATCH 02/11] libxl_json: Remove JSON_ERROR from enum Alex Bligh
2013-02-12 15:32 ` Ian Jackson
2013-02-12 15:37 ` Ian Campbell
2013-02-12 15:42 ` Ian Jackson
2013-02-13 9:13 ` Ian Campbell
2013-02-12 15:39 ` Ian Jackson
2013-01-19 17:58 ` [PATCH 03/11] libxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL Alex Bligh
2013-02-12 15:39 ` Ian Jackson
2013-01-19 17:58 ` [PATCH 04/11] libxl_json: Introduce libxl__json_object_to_yajl_gen Alex Bligh
2013-02-12 15:38 ` Ian Jackson
2013-01-19 17:58 ` [PATCH 05/11] libxl_qmp: Introduces helpers to create an argument list Alex Bligh
2013-02-12 15:43 ` Ian Jackson
2013-01-19 17:58 ` [PATCH 06/11] libxl_qmp: Use qmp_parameters_* functions for param list of a QMP command Alex Bligh
2013-02-12 15:40 ` Ian Jackson
2013-01-19 17:58 ` [PATCH 07/11] libxl_qmp: Simplify run of single QMP commands Alex Bligh
2013-02-12 15:41 ` Ian Jackson
2013-01-19 17:58 ` [PATCH 08/11] libxl_qmp: Introduce libxl__qmp_set_global_dirty_log Alex Bligh
2013-02-12 15:43 ` Ian Jackson
2013-01-19 17:58 ` [PATCH 09/11] libxl_dom: Call the right switch logdirty for the right DM Alex Bligh
2013-02-12 15:37 ` Ian Jackson
2013-01-19 17:58 ` [PATCH 10/11] libxl: Allow migration with qemu-xen Alex Bligh
2013-02-12 15:37 ` Ian Jackson
2013-02-12 15:44 ` Ian Jackson
2013-02-13 8:37 ` Alex Bligh
2013-02-13 12:25 ` Ian Jackson
2013-02-13 15:18 ` Alex Bligh
2013-01-19 17:58 ` [PATCH 11/11] libxl: libxl__qmp_save: Add filename as JSON parameter to xen-save-devices-state Alex Bligh
2013-02-12 15:36 ` Ian Jackson
2013-02-12 15:34 ` QEMU: Enabling live-migrate on HVM on qemu-xen device model in 4.2 Ian Jackson
-- strict thread matches above, loose matches on Subject: below --
2013-02-13 18:32 [v3] " Alex Bligh
2013-02-13 18:32 ` [PATCH 01/11] libxl_json: Export json_object related function Alex Bligh
2013-02-15 14:23 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358618288-17109-2-git-send-email-alex@alex.org.uk \
--to=alex@alex.org.uk \
--cc=Ian.Campbell@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).