From: Anthony PERARD <anthony.perard@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH v5 01/15] libxl: Design of an async API to issue QMP commands to QEMU
Date: Fri, 7 Sep 2018 16:10:50 +0100 [thread overview]
Message-ID: <20180907151104.32306-2-anthony.perard@citrix.com> (raw)
In-Reply-To: <20180907151104.32306-1-anthony.perard@citrix.com>
All the functions will be implemented in later patches.
This patch includes the API that libxl can use to send QMP commands to
QEMU.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
Notes:
v5:
some changes in the comment
tools/libxl/libxl_internal.h | 72 +++++++++++++++++++++++++++++++++++-
1 file changed, 70 insertions(+), 2 deletions(-)
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 802382c704..979a9947f0 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -202,6 +202,8 @@ typedef struct libxl__ao libxl__ao;
typedef struct libxl__aop_occurred libxl__aop_occurred;
typedef struct libxl__osevent_hook_nexus libxl__osevent_hook_nexus;
typedef struct libxl__osevent_hook_nexi libxl__osevent_hook_nexi;
+typedef struct libxl__json_object libxl__json_object;
+typedef struct libxl__carefd libxl__carefd;
typedef struct libxl__domain_create_state libxl__domain_create_state;
typedef void libxl__domain_create_cb(struct libxl__egc *egc,
@@ -357,6 +359,72 @@ struct libxl__ev_child {
LIBXL_LIST_ENTRY(struct libxl__ev_child) entry;
};
+/*
+ * QMP asynchronous calls
+ *
+ * This facility allows a command to be sent to QEMU, and the response to be
+ * handed to a callback function.
+ *
+ * Commands can be chained, with a same connection. (e.g. "add-fd" will need to
+ * be chained to the next command). A libxl__ev_qmp can be reused when the
+ * callback is been called in order to use the same connection.
+ *
+ * Only one connection at a time can be made to one QEMU, so avoid keeping a
+ * libxl__ev_qmp Connected for to long and call libxl__ev_qmp_dispose as soon
+ * as it is not needed anymore.
+ *
+ * Possible states of a libxl__ev_qmp:
+ * Undefined
+ * Might contain anything.
+ * Idle
+ * Struct contents are defined enough to pass to any libxl__ev_qmp_*
+ * function.
+ * The struct does not contain references to any allocated private resources
+ * so can be thrown away.
+ * Active
+ * Currently waiting for the callback to be called.
+ * _dispose must be called to reclaim resources.
+ * Connected
+ * Struct contain allocated ressources.
+ * Calling _send() with this same ev will use the same QMP connection.
+ * _dispose() must be called to reclaim resources.
+ *
+ * libxl__ev_qmp_init: Undefined/Idle -> Idle
+ *
+ * libxl__ev_qmp_send: Idle/Connected -> Active (on error: Idle)
+ * Sends a command to QEMU.
+ * callback will be called when a response is received or when an error
+ * as occured.
+ *
+ * libxl__ev_qmp_dispose: Connected/Active/Idle -> Idle
+ *
+ * callback: When called: Active -> Connected
+ * When called, ev is Connected and can be reused or disposed of.
+ * If an error occured, it is called with response == NULL and the error
+ * code in rc.
+ * The callback is only called once.
+ */
+typedef struct libxl__ev_qmp libxl__ev_qmp;
+typedef void libxl__ev_qmp_callback(libxl__egc *egc, libxl__ev_qmp *ev,
+ const libxl__json_object *response,
+ int rc);
+
+_hidden void libxl__ev_qmp_init(libxl__ev_qmp *ev);
+_hidden int libxl__ev_qmp_send(libxl__gc *gc, libxl__ev_qmp *ev,
+ const char *cmd, libxl__json_object *args);
+_hidden void libxl__ev_qmp_dispose(libxl__gc *gc, libxl__ev_qmp *ev);
+
+struct libxl__ev_qmp {
+ /* caller should include this in their own struct */
+ /* caller must fill these in, and they must all remain valid */
+ uint32_t domid;
+ libxl__ev_qmp_callback *callback;
+ libxl__carefd *cfd; /* set to send a fd with the command, NULL otherwise */
+
+ /* remaining fields are private to libxl_ev_qmp_* */
+ int id;
+};
+
/*
* evgen structures, which are the state we use for generating
@@ -1902,7 +1970,7 @@ typedef enum {
JSON_ANY = 255 /* this is a mask of all values above, adjust as needed */
} libxl__json_node_type;
-typedef struct libxl__json_object {
+struct libxl__json_object {
libxl__json_node_type type;
union {
bool b;
@@ -1915,7 +1983,7 @@ typedef struct libxl__json_object {
flexarray_t *map;
} u;
struct libxl__json_object *parent;
-} libxl__json_object;
+};
typedef int (*libxl__json_parse_callback)(libxl__gc *gc,
libxl__json_object *o,
--
Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-09-07 15:11 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20181015151630.3887-1-ian.jackson@eu.citrix.com>
2018-09-07 15:10 ` [PATCH v5 00/15] libxl: Enable save/restore/migration of a restricted QEMU + libxl__ev_qmp_* Anthony PERARD
2018-09-07 15:10 ` Anthony PERARD [this message]
2018-10-10 15:18 ` [PATCH v5 01/15] libxl: Design of an async API to issue QMP commands to QEMU Ian Jackson
2018-10-11 11:17 ` Anthony PERARD
2018-10-11 11:21 ` Ian Jackson
2018-10-10 23:49 ` Marek Marczykowski-Górecki
2018-10-11 14:29 ` Anthony PERARD
2018-09-07 15:10 ` [PATCH v5 02/15] libxl_qmp: Connect to QMP socket Anthony PERARD
2018-10-10 15:29 ` Ian Jackson
2018-10-11 11:27 ` Anthony PERARD
2018-09-07 15:10 ` [PATCH v5 03/15] libxl_qmp: Implement fd callback and read data Anthony PERARD
2018-10-10 15:47 ` Ian Jackson
2018-10-11 14:06 ` Anthony PERARD
2018-10-15 14:04 ` Ian Jackson
2018-10-15 16:35 ` [PATCH v5 03/15] libxl_qmp: Implement fd callback and read data [and 1 more messages] Ian Jackson
2018-10-29 15:52 ` Anthony PERARD
2018-10-29 17:31 ` Ian Jackson
2018-10-30 18:03 ` Anthony PERARD
2018-10-30 18:25 ` Ian Jackson
2018-09-07 15:10 ` [PATCH v5 04/15] libxl_qmp: Parse JSON input from QMP Anthony PERARD
2018-09-07 15:10 ` [PATCH v5 05/15] libxl_qmp: Separate QMP message generation from qmp_send_prepare Anthony PERARD
2018-09-07 15:10 ` [PATCH v5 06/15] libxl_qmp: Prepare the command to be sent Anthony PERARD
2018-09-07 15:10 ` [PATCH v5 07/15] libxl_qmp: Handle write to QMP socket Anthony PERARD
2018-09-07 15:10 ` [PATCH v5 08/15] libxl_qmp: Handle messages from QEMU Anthony PERARD
2018-09-07 15:10 ` [PATCH v5 09/15] libxl_qmp: Respond to QMP greeting Anthony PERARD
2018-09-07 15:10 ` [PATCH v5 10/15] libxl_exec: Add libxl__spawn_initiate_failure Anthony PERARD
2018-10-16 14:02 ` Ian Jackson
2018-11-09 12:26 ` Anthony PERARD
2018-09-07 15:11 ` [PATCH v5 11/15] libxl_dm: Pre-open QMP socket for QEMU Anthony PERARD
2018-10-16 14:11 ` Ian Jackson
2018-11-12 14:52 ` Anthony PERARD
2018-11-12 15:14 ` Ian Jackson
2018-11-12 15:22 ` Anthony PERARD
2018-11-12 15:54 ` Ian Jackson
2018-09-07 15:11 ` [PATCH v5 12/15] libxl: QEMU startup sync based on QMP Anthony PERARD
2018-10-16 14:23 ` Ian Jackson
2018-11-12 15:00 ` Anthony PERARD
2018-11-12 15:17 ` Ian Jackson
2018-09-07 15:11 ` [PATCH v5 13/15] libxl_qmp: Store advertised QEMU version in libxl__ev_qmp Anthony PERARD
2018-10-16 14:25 ` Ian Jackson
2018-09-07 15:11 ` [PATCH v5 14/15] libxl: Change libxl__domain_suspend_device_model() to be async Anthony PERARD
2018-10-16 15:14 ` Ian Jackson
2018-09-07 15:11 ` [PATCH v5 15/15] libxl: Re-implement domain_suspend_device_model using libxl__ev_qmp Anthony PERARD
2018-10-16 15:28 ` Ian Jackson
2018-11-09 16:59 ` Anthony PERARD
2018-11-09 17:11 ` Ian Jackson
2018-11-09 17:30 ` 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=20180907151104.32306-2-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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).