WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 4/7] libxl_qmp, Always insert a command id in the

To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 4/7] libxl_qmp, Always insert a command id in the callback_list.
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Fri, 7 Oct 2011 13:32:59 +0100
Cc: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Fri, 07 Oct 2011 05:33:31 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1317989418-25463-5-git-send-email-anthony.perard@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <1317989418-25463-1-git-send-email-anthony.perard@xxxxxxxxxx> <1317989418-25463-5-git-send-email-anthony.perard@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Fri, 2011-10-07 at 13:10 +0100, Anthony PERARD wrote:
> Because the function qmp_synchronous_send rely on the presence of the id
> in the callback_list.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

> ---
>  tools/libxl/libxl_qmp.c |   34 ++++++++++++++++++----------------
>  1 files changed, 18 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
> index 002fb13..1594a4f 100644
> --- a/tools/libxl/libxl_qmp.c
> +++ b/tools/libxl/libxl_qmp.c
> @@ -213,7 +213,9 @@ 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->opaque);
> +        if (pp->callback) {
> +            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;
> @@ -245,9 +247,11 @@ static int qmp_handle_response(libxl__qmp_handler *qmp,
>          callback_id_pair *pp = qmp_get_callback_from_id(qmp, resp);
>  
>          if (pp) {
> -            pp->callback(qmp,
> -                         libxl__json_map_get("return", resp, JSON_ANY),
> -                         pp->opaque);
> +            if (pp->callback) {
> +                pp->callback(qmp,
> +                             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;
> @@ -437,6 +441,7 @@ static int qmp_send(libxl__qmp_handler *qmp,
>      unsigned int len = 0;
>      yajl_gen_status s;
>      yajl_gen hand;
> +    callback_id_pair *elm = NULL;
>  
>      hand = yajl_gen_alloc(&conf, NULL);
>      if (!hand) {
> @@ -462,19 +467,16 @@ static int qmp_send(libxl__qmp_handler *qmp,
>          return -1;
>      }
>  
> -    if (callback) {
> -        callback_id_pair *elm = malloc(sizeof (callback_id_pair));
> -        if (elm == NULL) {
> -            LIBXL__LOG_ERRNO(qmp->ctx, LIBXL__LOG_ERROR,
> -                             "Failed to allocate a QMP callback");
> -            yajl_gen_free(hand);
> -            return -1;
> -        }
> -        elm->id = qmp->last_id_used;
> -        elm->callback = callback;
> -        elm->opaque = opaque;
> -        SIMPLEQ_INSERT_TAIL(&qmp->callback_list, elm, next);
> +    elm = malloc(sizeof (callback_id_pair));
> +    if (elm == NULL) {
> +        LIBXL__LOG_ERRNO(qmp->ctx, LIBXL__LOG_ERROR,
> +                         "Failed to allocate a QMP callback");
> +        goto error;
>      }
> +    elm->id = qmp->last_id_used;
> +    elm->callback = callback;
> +    elm->opaque = opaque;
> +    SIMPLEQ_INSERT_TAIL(&qmp->callback_list, elm, next);
>  
>      LIBXL__LOG(qmp->ctx, LIBXL__LOG_DEBUG, "next qmp command: '%s'", buf);
>  



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>