From: Anthony PERARD <anthony.perard@citrix.com>
To: QEMU-devel <qemu-devel@nongnu.org>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Xen Devel <xen-devel@lists.xensource.com>
Subject: [Qemu-devel] [PATCH V3 05/13] libxl_qmp: Introduce an opaque argument to the callbacks.
Date: Tue, 1 Nov 2011 16:07:18 +0000 [thread overview]
Message-ID: <1320163646-24291-6-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1320163646-24291-1-git-send-email-anthony.perard@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
tools/libxl/libxl_qmp.c | 30 +++++++++++++++++++-----------
1 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index f61a87a..ddc0a4d 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -43,11 +43,13 @@
#define QMP_RECEIVE_BUFFER_SIZE 4096
typedef int (*qmp_callback_t)(libxl__qmp_handler *qmp,
- const libxl__json_object *tree);
+ const libxl__json_object *tree,
+ void *opaque);
typedef struct callback_id_pair {
int id;
qmp_callback_t callback;
+ void *opaque;
SIMPLEQ_ENTRY(callback_id_pair) next;
} callback_id_pair;
@@ -70,7 +72,8 @@ struct libxl__qmp_handler {
};
static int qmp_send(libxl__qmp_handler *qmp,
- const char *cmd, qmp_callback_t callback);
+ const char *cmd,
+ qmp_callback_t callback, void *opaque);
static const int QMP_SOCKET_CONNECT_TIMEOUT = 5;
@@ -100,7 +103,8 @@ static int store_serial_port_info(libxl__qmp_handler *qmp,
}
static int register_serials_chardev_callback(libxl__qmp_handler *qmp,
- const libxl__json_object *o)
+ const libxl__json_object *o,
+ void *unused)
{
const libxl__json_object *obj = NULL;
const libxl__json_object *label = NULL;
@@ -144,7 +148,7 @@ static int register_serials_chardev_callback(libxl__qmp_handler *qmp,
}
static int qmp_capabilities_callback(libxl__qmp_handler *qmp,
- const libxl__json_object *o)
+ const libxl__json_object *o, void *unused)
{
qmp->connected = true;
@@ -157,7 +161,7 @@ static int qmp_capabilities_callback(libxl__qmp_handler *qmp,
static int enable_qmp_capabilities(libxl__qmp_handler *qmp)
{
- return qmp_send(qmp, "qmp_capabilities", qmp_capabilities_callback);
+ return qmp_send(qmp, "qmp_capabilities", qmp_capabilities_callback, NULL);
}
/*
@@ -208,7 +212,7 @@ static void qmp_handle_error_response(libxl__qmp_handler *qmp,
resp = libxl__json_map_get("desc", resp, JSON_STRING);
if (pp) {
- pp->callback(qmp, NULL);
+ pp->callback(qmp, NULL, pp->opaque);
if (pp->id == qmp->wait_for_id) {
/* tell that the id have been processed */
qmp->wait_for_id = 0;
@@ -241,7 +245,8 @@ static int qmp_handle_response(libxl__qmp_handler *qmp,
if (pp) {
pp->callback(qmp,
- libxl__json_map_get("return", resp, JSON_ANY));
+ libxl__json_map_get("return", resp, JSON_ANY),
+ pp->opaque);
if (pp->id == qmp->wait_for_id) {
/* tell that the id have been processed */
qmp->wait_for_id = 0;
@@ -424,7 +429,8 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp)
}
static int qmp_send(libxl__qmp_handler *qmp,
- const char *cmd, qmp_callback_t callback)
+ const char *cmd,
+ qmp_callback_t callback, void *opaque)
{
yajl_gen_config conf = { 0, NULL };
const unsigned char *buf;
@@ -462,6 +468,7 @@ static int qmp_send(libxl__qmp_handler *qmp,
}
elm->id = qmp->last_id_used;
elm->callback = callback;
+ elm->opaque = opaque;
SIMPLEQ_INSERT_TAIL(&qmp->callback_list, elm, next);
}
@@ -484,13 +491,14 @@ error:
}
static int qmp_synchronous_send(libxl__qmp_handler *qmp, const char *cmd,
- qmp_callback_t callback, int ask_timeout)
+ qmp_callback_t callback, void *opaque,
+ int ask_timeout)
{
int id = 0;
int ret = 0;
libxl__gc gc = LIBXL_INIT_GC(qmp->ctx);
- id = qmp_send(qmp, cmd, callback);
+ id = qmp_send(qmp, cmd, callback, opaque);
if (id <= 0) {
return -1;
}
@@ -580,7 +588,7 @@ int libxl__qmp_query_serial(libxl__qmp_handler *qmp)
{
return qmp_synchronous_send(qmp, "query-chardev",
register_serials_chardev_callback,
- qmp->timeout);
+ NULL, qmp->timeout);
}
int libxl__qmp_initializations(libxl_ctx *ctx, uint32_t domid)
--
Anthony PERARD
next prev parent reply other threads:[~2011-11-01 16:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-01 16:07 [Qemu-devel] [PATCH V3 00/13] libxl: QMP client improvement + pci passthrougth insert through QMP Anthony PERARD
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 01/13] libxl_qmp: Fix return check of fcntl Anthony PERARD
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 02/13] libxl_json: Check the parser status before to call parse_complete Anthony PERARD
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 03/13] libxl_qmp: Better error message after a parse error Anthony PERARD
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 04/13] libxl: Introduce dm-version xenstore key Anthony PERARD
2011-11-01 16:07 ` Anthony PERARD [this message]
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 06/13] libxl_qmp: Introduce list of arguments to qmp_send Anthony PERARD
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 07/13] libxl_qmp: Always insert a command id in the callback_list Anthony PERARD
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 08/13] libxl_qmp: Introduce qmp_request_context Anthony PERARD
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 09/13] libxl_json: Handle number abrove LONG_MAX Anthony PERARD
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 10/13] libxl_qmp: Introduce libxl__qmp_pci_add Anthony PERARD
2011-11-04 12:44 ` [Qemu-devel] [Xen-devel] [PATCH V3 10/13] libxl: " Ian Jackson
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 11/13] libxl: Use QMP to insert a passthrough device when using upstream QEMU Anthony PERARD
2011-11-04 14:51 ` [Qemu-devel] [Xen-devel] " Ian Jackson
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 12/13] libxl_qmp: Introduce libxl__qmp_pci_del Anthony PERARD
2011-11-01 16:07 ` [Qemu-devel] [PATCH V3 13/13] libxl: Remove a passthrough device through QMP Anthony PERARD
2011-11-01 16:26 ` [Qemu-devel] [PATCH V3 00/13] libxl: QMP client improvement + pci passthrougth insert " Anthony PERARD
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=1320163646-24291-6-git-send-email-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/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).