From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: xen-devel@lists.xenproject.org,
Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH v4 12/32] libxl: Design of an async API to issue QMP commands to QEMUç
Date: Thu, 2 Aug 2018 11:01:43 +0200 [thread overview]
Message-ID: <20180802090143.2xkbjpxanvoseble@mac> (raw)
In-Reply-To: <20180727140614.13256-13-anthony.perard@citrix.com>
On Fri, Jul 27, 2018 at 03:05:54PM +0100, Anthony PERARD wrote:
> 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>
> ---
> tools/libxl/libxl_internal.h | 76 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 74 insertions(+), 2 deletions(-)
>
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 5b71a23d23..c453ac10a5 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,76 @@ struct libxl__ev_child {
> LIBXL_LIST_ENTRY(struct libxl__ev_child) entry;
> };
>
> +/*
> + * QMP asynchronous calls
> + */
Place the title in the same comment block?
> +/*
> + * This facility allows a command to be sent to QEMU, and the response to be
> + * handed to a callback function. Each libxl__ev_qmp handles zero or one
Do you really mean 'zero or one' or 'zero or more'?
> + * outstanding command.
> + *
> + * Commands can be chained, with a same connection. (e.g. "add-fd" will need to
^ the
> + * be chained to the next command). A libxl__ev_qmp can be reused when the
^ after
> + * callback is been called in order to use the same connection.
^ has
> + *
> + * Only one connection at a time can be made to one QEMU, so avoid keeping a
^ to
> + * libxl__ev_qmp Connected for to long and call libxl__ev_qmp_dispose as soon
^ unneeded cap ^ remove 'and'
> + * 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_*
> + * functions.
^ function
> + * The struct does not contain references to any allocated private resources
> + * so can be thrown away.
I would add '... can be thrown away without any teardown.'
> + * 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.
> + * When an error occured, it is called with response == NULL and the error
^ If
> + * 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 */
^ no need for 'all'
> + uint32_t domid;
Strictly speaking domid is an uint16_t.
> + 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_* */
> +
Extra newline?
> + int id;
> +};
> +
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-08-02 9:01 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-27 14:05 [PATCH v4 00/32] libxl: Enable save/restore/migration of a restricted QEMU + libxl__ev_qmp_* Anthony PERARD
2018-07-27 14:05 ` [PATCH v4 01/32] libxl_event: Fix DEBUG prints Anthony PERARD
2018-07-27 14:05 ` [PATCH v4 02/32] libxl_qmp: Documentation of the logic of the QMP client Anthony PERARD
2018-07-27 14:05 ` [PATCH v4 03/32] libxl_qmp: Fix use of DEBUG_RECEIVED Anthony PERARD
2018-07-27 14:05 ` [PATCH v4 04/32] libxl_json: fix build with DEBUG_ANSWER Anthony PERARD
2018-07-27 14:05 ` [PATCH v4 05/32] libxl_qmp: Move the buffer realloc to the same scope level as read Anthony PERARD
2018-07-27 14:05 ` [PATCH v4 06/32] libxl_qmp: Add a warning to not trust QEMU Anthony PERARD
2018-07-27 14:05 ` [PATCH v4 07/32] libxl_qmp: Move struct sockaddr_un variable to qmp_open() Anthony PERARD
2018-08-02 8:26 ` Roger Pau Monné
2018-08-20 14:52 ` Wei Liu
2018-07-27 14:05 ` [PATCH v4 08/32] libxl: Add libxl__prepare_sockaddr_un() helper Anthony PERARD
2018-08-02 8:36 ` Roger Pau Monné
2018-08-20 14:56 ` Wei Liu
2018-07-27 14:05 ` [PATCH v4 09/32] libxl_qmp: Remove unused yajl_ctx from handler Anthony PERARD
2018-08-20 14:56 ` Wei Liu
2018-07-27 14:05 ` [PATCH v4 10/32] libxl_json: constify libxl__json_object_to_yajl_gen arguments Anthony PERARD
2018-07-27 14:05 ` [PATCH v4 11/32] libxl_dm: Add libxl__qemu_qmp_path() Anthony PERARD
2018-08-02 8:41 ` Roger Pau Monné
2018-08-20 14:57 ` Wei Liu
2018-07-27 14:05 ` [PATCH v4 12/32] libxl: Design of an async API to issue QMP commands to QEMU Anthony PERARD
2018-08-02 9:01 ` Roger Pau Monné [this message]
2018-08-03 11:18 ` [PATCH v4 12/32] libxl: Design of an async API to issue QMP commands to QEMUç Anthony PERARD
2018-08-03 13:55 ` Roger Pau Monné
2018-08-03 14:45 ` Anthony PERARD
2018-08-03 15:30 ` Roger Pau Monné
2018-07-27 14:05 ` [PATCH v4 13/32] libxl_qmp: Connect to QMP socket Anthony PERARD
2018-08-02 9:35 ` Roger Pau Monné
2018-08-03 13:54 ` Anthony PERARD
2018-08-03 14:03 ` Roger Pau Monné
2018-08-21 8:22 ` Wei Liu
2018-07-27 14:05 ` [PATCH v4 14/32] libxl_qmp: Implement fd callback and read data Anthony PERARD
2018-08-02 9:56 ` Roger Pau Monné
2018-08-03 14:32 ` Anthony PERARD
2018-08-03 15:24 ` Roger Pau Monné
2018-08-06 15:01 ` Anthony PERARD
2018-07-27 14:05 ` [PATCH v4 15/32] libxl_json: Enable yajl_allow_trailing_garbage Anthony PERARD
2018-08-02 10:01 ` Roger Pau Monné
2018-08-21 8:26 ` Wei Liu
2018-07-27 14:05 ` [PATCH v4 16/32] libxl_json: libxl__json_object_to_json Anthony PERARD
2018-08-02 10:10 ` Roger Pau Monné
2018-08-21 8:26 ` Wei Liu
2018-07-27 14:05 ` [PATCH v4 17/32] libxl_qmp: Parse JSON input from QMP Anthony PERARD
2018-08-02 10:25 ` Roger Pau Monné
2018-08-03 15:33 ` Anthony PERARD
2018-08-06 11:17 ` Roger Pau Monné
2018-07-27 14:06 ` [PATCH v4 18/32] libxl_qmp: Separate QMP message generation from qmp_send_prepare Anthony PERARD
2018-08-02 10:34 ` Roger Pau Monné
2018-08-03 15:43 ` Anthony PERARD
2018-07-27 14:06 ` [PATCH v4 19/32] libxl_qmp: Prepare the command to be sent Anthony PERARD
2018-08-02 10:41 ` Roger Pau Monné
2018-08-03 16:35 ` Anthony PERARD
2018-07-27 14:06 ` [PATCH v4 20/32] libxl_qmp: Handle write to QMP socket Anthony PERARD
2018-08-02 11:02 ` Roger Pau Monné
2018-08-03 16:50 ` Anthony PERARD
2018-07-27 14:06 ` [PATCH v4 21/32] libxl_qmp: Simplify qmp_response_type() prototype Anthony PERARD
2018-08-02 11:03 ` Roger Pau Monné
2018-08-21 8:53 ` Wei Liu
2018-07-27 14:06 ` [PATCH v4 22/32] libxl_qmp: Handle messages from QEMU Anthony PERARD
2018-08-02 11:17 ` Roger Pau Monné
2018-08-03 17:25 ` Anthony PERARD
2018-08-06 11:25 ` Roger Pau Monné
2018-08-06 13:14 ` Anthony PERARD
2018-08-06 15:03 ` Roger Pau Monné
2018-08-21 8:58 ` Wei Liu
2018-08-21 12:50 ` Anthony PERARD
2018-08-21 14:56 ` Ian Jackson
2018-07-27 14:06 ` [PATCH v4 23/32] libxl_qmp: Respond to QMP greeting Anthony PERARD
2018-08-02 11:26 ` Roger Pau Monné
2018-08-06 17:41 ` Anthony PERARD
2018-08-21 9:00 ` Wei Liu
2018-08-21 10:51 ` Anthony PERARD
2018-07-27 14:06 ` [PATCH v4 24/32] libxl_qmp: Disable beautify for QMP generated cmd Anthony PERARD
2018-08-21 9:00 ` Wei Liu
2018-07-27 14:06 ` [PATCH v4 25/32] libxl_exec: Add libxl__spawn_initiate_failure Anthony PERARD
2018-08-02 11:34 ` Roger Pau Monné
2018-08-06 15:58 ` Anthony PERARD
2018-07-27 14:06 ` [PATCH v4 26/32] libxl_dm: Pre-open QMP socket for QEMU Anthony PERARD
2018-08-02 15:00 ` Roger Pau Monné
2018-07-27 14:06 ` [PATCH v4 27/32] libxl: QEMU startup sync based on QMP Anthony PERARD
2018-08-02 15:06 ` Roger Pau Monné
2018-07-27 14:06 ` [PATCH v4 28/32] libxl_qmp: Store advertised QEMU version in libxl__ev_qmp Anthony PERARD
2018-08-02 15:08 ` Roger Pau Monné
2018-08-06 16:52 ` Anthony PERARD
2018-07-27 14:06 ` [PATCH v4 29/32] libxl: Change libxl__domain_suspend_device_model() to be async Anthony PERARD
2018-08-02 15:15 ` Roger Pau Monné
2018-07-27 14:06 ` [PATCH v4 30/32] libxl: Re-implement domain_suspend_device_model using libxl__ev_qmp Anthony PERARD
2018-08-02 15:38 ` Roger Pau Monné
2018-08-06 17:07 ` Anthony PERARD
2018-07-27 14:06 ` [PATCH v4 31/32] libxl_disk: Cut libxl_cdrom_insert into step Anthony PERARD
2018-08-02 15:50 ` Roger Pau Monné
2018-08-06 17:20 ` Anthony PERARD
2018-08-07 14:18 ` Roger Pau Monné
2018-08-07 14:40 ` Anthony PERARD
2018-08-21 9:08 ` Wei Liu
2018-08-21 12:58 ` Anthony PERARD
2018-07-27 14:06 ` [PATCH v4 32/32] libxl_disk: Have libxl_cdrom_insert use libxl__ev_qmp 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=20180802090143.2xkbjpxanvoseble@mac \
--to=roger.pau@citrix.com \
--cc=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).