[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] libxl: introduce libxl_vcpuinfo_list_free



On Fri, 2012-05-25 at 10:44 +0100, Dario Faggioli wrote:
> And fix a leak due to it being missing.
> 
> Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>

Applied, thanks.

> 
> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -797,6 +797,7 @@ libxl_cputopology *libxl_get_cpu_topolog
>  void libxl_cputopology_list_free(libxl_cputopology *, int nr);
>  libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
>                                         int *nb_vcpu, int *nrcpus);
> +void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr);
>  int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
>                             libxl_cpumap *cpumap);
>  int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid,
> diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
> --- a/tools/libxl/libxl_utils.c
> +++ b/tools/libxl/libxl_utils.c
> @@ -558,6 +558,14 @@ void libxl_cputopology_list_free(libxl_c
>      free(list);
>  }
>  
> +void libxl_vcpuinfo_list_free(libxl_vcpuinfo *list, int nr)
> +{
> +    int i;
> +    for (i = 0; i < nr; i++)
> +        libxl_vcpuinfo_dispose(&list[i]);
> +    free(list);
> +}
> +
>  int libxl__sendmsg_fds(libxl__gc *gc, int carrier,
>                         const void *data, size_t datalen,
>                         int nfds, const int fds[], const char *what) {
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -3972,10 +3972,9 @@ static void print_domain_vcpuinfo(uint32
>  
>      for (i = 0; i < nb_vcpu; i++) {
>          print_vcpuinfo(domid, &vcpuinfo[i], nr_cpus);
> -        libxl_vcpuinfo_dispose(&vcpuinfo[i]);
> -    }
> -
> -    free(vcpuinfo);
> +    }
> +
> +    libxl_vcpuinfo_list_free(vcpuinfo, nb_vcpu);
>  }
>  
>  static void vcpulist(int argc, char **argv)
> @@ -4063,11 +4062,14 @@ static void vcpupin(const char *d, const
>              fprintf(stderr, "libxl_list_vcpu failed.\n");
>              goto vcpupin_out1;
>          }
> -        for (; nb_vcpu > 0; --nb_vcpu, ++vcpuinfo) {
> -            if (libxl_set_vcpuaffinity(ctx, domid, vcpuinfo->vcpuid, 
> &cpumap) == -1) {
> -                fprintf(stderr, "libxl_set_vcpuaffinity failed on vcpu 
> `%u'.\n", vcpuinfo->vcpuid);
> +        for (i = 0; i < nb_vcpu; i++) {
> +            if (libxl_set_vcpuaffinity(ctx, domid, vcpuinfo[i].vcpuid,
> +                                       &cpumap) == -1) {
> +                fprintf(stderr, "libxl_set_vcpuaffinity failed"
> +                                " on vcpu `%u'.\n", vcpuinfo[i].vcpuid);
>              }
>          }
> +        libxl_vcpuinfo_list_free(vcpuinfo, nb_vcpu);
>      }
>    vcpupin_out1:
>      libxl_cpumap_dispose(&cpumap);



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.