aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Bligh <alex@alex.org.uk>2013-02-19 15:25:14 +0000
committerAlex Bligh <alex@alex.org.uk>2013-02-19 15:25:14 +0000
commitc5c1c54fc8e21f2a83266a0ef32f51c55bcb8e2f (patch)
tree241e22da777956b88539a2dc16303a1dc9f142da
parent1c866ea32b0fd7981f396aa4600c0ef4d0eee65b (diff)
downloadxen-c5c1c54fc8e21f2a83266a0ef32f51c55bcb8e2f.tar.gz
xen-c5c1c54fc8e21f2a83266a0ef32f51c55bcb8e2f.tar.bz2
xen-c5c1c54fc8e21f2a83266a0ef32f51c55bcb8e2f.zip
libxl_qmp: Introduces helpers to create an argument list.
Those functions will be used to create a "list" of parameters that contain more than just strings. This list is converted by qmp_send to a string to be sent to QEMU. Those functions will be used in the next two patches, so right now there are not compiled. Backported from xen-unstable patch: : HG changeset patch : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693132 -3600 : Node ID 6f7847729f0f42614de516d15257ede7243f995f : Parent 74dee58cfc0d2d6594f388db3b4d2ce91d1bb204 Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
-rw-r--r--tools/libxl/libxl_qmp.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index 9e86c35cc5..827f1b74b1 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -624,6 +624,57 @@ static void qmp_free_handler(libxl__qmp_handler *qmp)
free(qmp);
}
+#if 0
+/*
+ * QMP Parameters Helpers
+ */
+static void qmp_parameters_common_add(libxl__gc *gc,
+ libxl__json_object **param,
+ const char *name,
+ libxl__json_object *obj)
+{
+ libxl__json_map_node *arg = NULL;
+
+ if (!*param) {
+ *param = libxl__json_object_alloc(gc, JSON_MAP);
+ }
+
+ arg = libxl__zalloc(gc, sizeof(*arg));
+
+ arg->map_key = libxl__strdup(gc, name);
+ arg->obj = obj;
+
+ flexarray_append((*param)->u.map, arg);
+}
+
+static void qmp_parameters_add_string(libxl__gc *gc,
+ libxl__json_object **param,
+ const char *name, const char *argument)
+{
+ libxl__json_object *obj;
+
+ obj = libxl__json_object_alloc(gc, JSON_STRING);
+ obj->u.string = libxl__strdup(gc, argument);
+
+ qmp_parameters_common_add(gc, param, name, obj);
+}
+
+static void qmp_parameters_add_bool(libxl__gc *gc,
+ libxl__json_object **param,
+ const char *name, bool b)
+{
+ libxl__json_object *obj;
+
+ obj = libxl__json_object_alloc(gc, JSON_BOOL);
+ obj->u.b = b;
+ qmp_parameters_common_add(gc, param, name, obj);
+}
+
+#define QMP_PARAMETERS_SPRINTF(args, name, format, ...) \
+ qmp_parameters_add_string(gc, args, name, \
+ libxl__sprintf(gc, format, __VA_ARGS__))
+#endif
+
/*
* API
*/