|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v4 19/32] libxl_qmp: Prepare the command to be sent
On Fri, Jul 27, 2018 at 03:06:01PM +0100, Anthony PERARD wrote:
> The actual sent will be done in a separate patch.
>
> Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> ---
> tools/libxl/libxl_internal.h | 4 ++++
> tools/libxl/libxl_qmp.c | 37 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 41 insertions(+)
>
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 7f200e7a46..110b951bbe 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -438,6 +438,7 @@ struct libxl__ev_qmp {
> libxl__carefd *qmp_cfd;
> libxl__ev_fd qmp_efd;
> libxl__qmp_state qmp_state;
> + unsigned int last_id_used;
Now there are two last_id_used fields in different structures?
Shouldn't the previous one be removed when you introduce this new one?
>
> /* receive buffer, with:
> * buf_size: current allocated size,
> @@ -447,6 +448,9 @@ struct libxl__ev_qmp {
> size_t buf_size;
> size_t buf_used;
> size_t buf_consumed;
> +
> + char *tx_buf;
> + size_t tx_buf_len;
> };
>
>
> diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
> index 38a4395266..2792f35912 100644
> --- a/tools/libxl/libxl_qmp.c
> +++ b/tools/libxl/libxl_qmp.c
> @@ -1310,6 +1310,25 @@ int libxl__qmp_initializations(libxl__gc *gc, uint32_t
> domid,
>
> /* ------------ Implementation of libxl__ev_qmp ---------------- */
>
> +static int qmp_ev_prepare_cmd(libxl__gc *gc,
> + libxl__ev_qmp *ev,
> + const char *cmd,
> + const libxl__json_object *args)
> +{
> + char *buf = NULL;
> + size_t len;
> +
> + buf = qmp_prepare_qmp_cmd(gc, cmd, args, ++ev->last_id_used, &len);
> + if (!buf)
> + return ERROR_FAIL;
> +
> + ev->id = ev->last_id_used;
> + ev->tx_buf = buf;
> + ev->tx_buf_len = len;
> +
> + return 0;
> +}
> +
> /*
> * QMP FD callbacks
> */
> @@ -1424,6 +1443,9 @@ static void qmp_ev_callback_error(libxl__egc *egc,
> libxl__ev_qmp *ev)
>
> /* On error, deallocate all private ressources */
> libxl__ev_qmp_dispose(gc, ev);
> +
> + ev->id = -1;
> + ev->callback(egc, ev, NULL, ERROR_FAIL);
> }
>
> static void qmp_ev_fd_callback(libxl__egc *egc, libxl__ev_fd *ev_fd,
> @@ -1522,8 +1544,10 @@ void libxl__ev_qmp_init(libxl__ev_qmp *ev)
> ev->qmp_cfd = NULL;
> libxl__ev_fd_init(&ev->qmp_efd);
> ev->qmp_state = qmp_state_disconnected;
> + ev->last_id_used = 0;
>
> ev->rx_buf = NULL;
> + ev->tx_buf = NULL;
ev->tx_buf_len = 0;
I think.
> }
>
> int libxl__ev_qmp_send(libxl__gc *gc, libxl__ev_qmp *ev,
> @@ -1535,7 +1559,17 @@ int libxl__ev_qmp_send(libxl__gc *gc, libxl__ev_qmp
> *ev,
>
> /* Connect to QEMU if not already connected */
> rc = qmp_ev_connect(gc, ev);
> + if (rc)
> + goto out;
> +
> + rc = qmp_ev_prepare_cmd(gc, ev, cmd, args);
> + if (rc)
> + goto out;
> +
>
Double newline?
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |