xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: Ian Jackson <ian.jackson@citrix.com>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH v3 14/31] libxl_qmp_ev: Introduce libxl__ev_qmp_start() to connect to QMP
Date: Thu, 28 Jun 2018 12:28:06 +0100	[thread overview]
Message-ID: <20180628112806.GG2052@perard.uk.xensource.com> (raw)
In-Reply-To: <23347.43080.956159.713378@mariner.uk.xensource.com>

On Wed, Jun 27, 2018 at 04:07:52PM +0100, Ian Jackson wrote:
> Anthony PERARD writes ("[PATCH v3 14/31] libxl_qmp_ev: Introduce libxl__ev_qmp_start() to connect to QMP"):
> > This is a first patch to implement libxl__ev_qmp, it only connect to the
> > QMP socket of QEMU and register a callback that does nothing.
> ...
> > @@ -503,6 +504,9 @@ struct libxl__ctx {
> >      LIBXL_LIST_ENTRY(libxl_ctx) sigchld_users_entry;
> >  
> >      libxl_version_info version_info;
> > +
> > +    // FIXME: May need a list, with on state for each domid
> > +    libxl__ev_qmp_state *qmp_ev;
> 
> My thought is that the lifetime of this thing should probably be in
> each relevant ao.

That sound plausible, I can try to move this state to libxl__ao. I just
need to find out what's happen on connect(3) when something else is
allready connected to QEMU.

> Is it too inconvenient to reconnect to qmp for every libxl operation ?
> If it is then this needs to be a cache, a bit like libxl__poller but
> different.  But that can be handled inside what you are calling
> _ev_qmp_start.
> 
> Also, I think if you are going to have a libxl__ev_qmp it needs to be
> just like all the other libxl__ev_ things.  It's not clear to me that
> QMP is similar enough.
> 
> Do you actually need an explicit "start" or "connect" operation ?
> I think in any case the "send a qmp command" operations should
> probably connect automatically.

That is what I have done. The libxl__ev_qmp_start() should be static, it
is only use from within libxl_qmp.c. But I've put it in libxl_interal.h
just to allow this patch to build.

The _stop is normally not needed, to be called. It is automatically
called as soon as there is no more QMP command in flight (all command
have receveid a response).

> So something like this:
> 
>    /* libxl__qmp_state has the following states:
>     *   Undefined
>     *   Disconnected
>     *   Connected
>     */
> 
>    void libxl__qmp_init(ibxl__qmp_state *qmp); /* U -> D */
> 
>    int libxl__qmp_connect(libxl__gc *gc, uint32_t domid,
>                           libxl__qmp_state *qmp_upd); /* [UC] -> C */
> 
>    int libxl__qmp_dispose(libxl__qmp_state *qmp_upd); /* [DC] -> D */
> 
>    int libxl__qmp_command( lots of parameters incl callback ); /* [DC] */

So what the interface looks like at the end of the series is:

void libxl__ev_qmp_init(libxl__ev_qmp *ev);
int libxl__ev_qmp_register(libxl__gc *gc, libxl__ev_qmp *ev,
                           libxl__ev_qmp_callback *,
                           uint32_t domid,
                           const char *cmd, libxl__json_object *args);
void libxl__ev_qmp_deregister(libxl__gc *gc, libxl__ev_qmp *ev);
int libxl__ev_qmp_isregistered(const libxl__ev_qmp *ev);

The libxl__qmp_state is not exposed. The _register() will attempt to
find the current _state and use it, or create a new one (connect).

The libxl__ev_qmp_stop() call in libxl_ctx_free() is only there in case
something went wrong, it should not be needed.


I'll try to write better documentation about the possible states of both
libxl__ev_qmp_state and libxl__ev_qmp, and how they relate to each
other.

BTW, I think qmp is kind of similair to libxl__ev_xswatch, which would
_ev_fd_register(xenstore_fd) on the first path to watch, and _deregister
once there is no more watches. The one more thing that qmp need to do is
open the socket and close it.

-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-06-28 11:28 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-01 14:36 [PATCH v3 00/31] libxl: Enable save/restore/migration of a restricted QEMU + libxl__ev_qmp_* Anthony PERARD
2018-06-01 14:36 ` [PATCH v3 01/31] libxl_event: Fix DEBUG prints Anthony PERARD
2018-06-27 14:19   ` Ian Jackson
2018-06-01 14:36 ` [PATCH v3 02/31] libxl_qmp: Documentation of the logic of the QMP client Anthony PERARD
2018-06-27 14:20   ` Ian Jackson
2018-06-01 14:36 ` [PATCH v3 03/31] libxl_qmp: Fix use of DEBUG_RECEIVED Anthony PERARD
2018-06-27 14:20   ` Ian Jackson
2018-06-01 14:36 ` [PATCH v3 04/31] libxl_json: fix build with DEBUG_ANSWER Anthony PERARD
2018-06-27 14:22   ` Ian Jackson
2018-07-17 14:35     ` Anthony PERARD
2018-06-01 14:36 ` [PATCH v3 05/31] libxl_qmp: Move the buffer realloc to the same scope level as read Anthony PERARD
2018-06-27 14:25   ` Ian Jackson
2018-06-01 14:36 ` [PATCH v3 06/31] libxl_qmp: Add a warning to not trust QEMU Anthony PERARD
2018-06-27 14:25   ` Ian Jackson
2018-06-01 14:36 ` [PATCH v3 07/31] libxl_qmp: Learned to send FD through QMP to QEMU Anthony PERARD
2018-06-27 14:26   ` Ian Jackson
2018-06-27 16:50     ` Anthony PERARD
2018-06-28  9:56       ` Ian Jackson
2018-06-01 14:36 ` [PATCH v3 08/31] libxl_qmp: Have QEMU save its state to a file descriptor Anthony PERARD
2018-06-27 14:29   ` Ian Jackson
2018-06-01 14:36 ` [PATCH v3 09/31] libxl_qmp: Move struct sockaddr_un variable to qmp_open() Anthony PERARD
2018-06-27 14:31   ` Ian Jackson
2018-06-27 16:54     ` Anthony PERARD
2018-06-01 14:36 ` [PATCH v3 10/31] libxl_qmp: Move buffers to the stack of qmp_next Anthony PERARD
2018-06-27 14:32   ` Ian Jackson
2018-06-27 16:58     ` Anthony PERARD
2018-06-28  9:57       ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 11/31] libxl_qmp: Remove unused yajl_ctx form handler Anthony PERARD
2018-06-27 14:32   ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 12/31] libxl_json: constify libxl__json_object_to_yajl_gen arguments Anthony PERARD
2018-06-27 14:32   ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 13/31] libxl_qmp: Separate QMP message generation from qmp_send_prepare Anthony PERARD
2018-06-27 14:45   ` Ian Jackson
2018-06-27 17:12     ` Anthony PERARD
2018-06-01 14:37 ` [PATCH v3 14/31] libxl_qmp_ev: Introduce libxl__ev_qmp_start() to connect to QMP Anthony PERARD
2018-06-27 15:07   ` Ian Jackson
2018-06-28 11:28     ` Anthony PERARD [this message]
2018-06-28 11:44       ` Ian Jackson
2018-06-28 13:01         ` Anthony PERARD
2018-06-01 14:37 ` [PATCH v3 15/31] libxl_qmp_ev: Implement fd callback and read data Anthony PERARD
2018-06-27 15:10   ` Ian Jackson
2018-06-28 11:33     ` Anthony PERARD
2018-06-28 11:37       ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 16/31] libxl_json: Allow partial parsing Anthony PERARD
2018-06-01 14:37 ` [PATCH v3 17/31] libxl_json: Enable yajl_allow_trailing_garbage Anthony PERARD
2018-06-01 14:37 ` [PATCH v3 18/31] libxl_json: libxl__json_object_to_json Anthony PERARD
2018-06-27 15:51   ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 19/31] libxl_qmp_ev: Parse JSON input from QMP Anthony PERARD
2018-06-01 14:37 ` [PATCH v3 20/31] libxl_qmp: Introduce libxl__ev_qmp functions Anthony PERARD
2018-06-01 14:37 ` [PATCH v3 21/31] libxl_qmp_ev: Handle write to socket Anthony PERARD
2018-06-01 14:37 ` [PATCH v3 22/31] libxl_qmp: Simplify qmp_response_type() prototype Anthony PERARD
2018-06-27 16:03   ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 23/31] libxl_qmp_ev: Handle messages from QEMU Anthony PERARD
2018-06-01 14:37 ` [PATCH v3 24/31] libxl_qmp_ev: Respond to QMP greeting Anthony PERARD
2018-06-27 16:07   ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 25/31] libxl_qmp_ev: Disconnect QMP when no more events Anthony PERARD
2018-06-01 14:37 ` [PATCH v3 26/31] libxl_qmp: Disable beautify for QMP generated cmd Anthony PERARD
2018-06-27 16:07   ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 27/31] libxl_qmp: Implement libxl__qmp_insert_cdrom_ev Anthony PERARD
2018-06-27 16:10   ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 28/31] libxl_disk: Cut libxl_cdrom_insert into step Anthony PERARD
2018-06-01 14:37 ` [PATCH v3 29/31] libxl_disk: Have libxl_cdrom_insert use libxl__ev_qmp Anthony PERARD
2018-06-27 16:12   ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 30/31] libxl_dm: Pre-open QMP socket for QEMU Anthony PERARD
2018-06-27 16:14   ` Ian Jackson
2018-06-01 14:37 ` [PATCH v3 31/31] libxl: QEMU startup sync based on QMP Anthony PERARD
2018-06-27 16:16   ` Ian Jackson
2018-07-26 14:59     ` Anthony PERARD
2018-06-01 14:47 ` [PATCH v3 00/31] libxl: Enable save/restore/migration of a restricted QEMU + libxl__ev_qmp_* Anthony PERARD
2018-07-03  9:47 ` [PATCH v3.1] libxl: Design of an async API to issue QMP commands to QEMU Anthony PERARD
2018-07-03 14:48   ` Ian Jackson
2018-07-04 11:11     ` Anthony PERARD
2018-07-12 16:36       ` Ian Jackson
2018-07-16 15:27         ` Anthony PERARD
2018-07-16 15:28           ` [PATCH v3.2] " Anthony PERARD
2018-07-16 16:33             ` Anthony PERARD
2018-07-16 17:04               ` [PATCH v3.2] libxl: Design of an async API to issue QMP commands to QEMU [and 1 more messages] Ian Jackson
2018-07-18 10: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=20180628112806.GG2052@perard.uk.xensource.com \
    --to=anthony.perard@citrix.com \
    --cc=ian.jackson@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).