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

Re: [PATCH 2/2] tools/libs/light: don't touch nr_vcpus_out if listing vcpus and returning NULL


  • To: Dario Faggioli <dfaggioli@xxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Thu, 13 Jan 2022 12:38:41 +0000
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, James Fehlig <jfehlig@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Thu, 13 Jan 2022 12:39:07 +0000
  • Ironport-data: A9a23:v+PBeqzZrCFoEcOPFB56t+fHwSrEfRIJ4+MujC+fZmUNrF6WrkVWz GQcDTzSPquNNGTzKtojbom/8B9Svp6AmIUwSAM+riAxQypGp/SeCIXCJC8cHc8zwu4v7q5Dx 59DAjUVBJlsFhcwnvopW1TYhSEUOZugH9IQM8aZfHAhLeNYYH1500g7wrdi2tQAbeWRWGthh /uj+6UzB3f9s9JEGjp8B3Wr8U4HUFza4Vv0j3RmDRx5lAa2e0o9VfrzEZqZPXrgKrS4K8bhL wr1IBNVyUuCl/slIovNfr8W6STmSJaKVeSFoiI+t6RPHnGuD8H9u0o2HKN0VKtZt9mGt9Eg7 otctMOMdUQoG6bDvcMdFBRCUAgraMWq+JefSZS+mcmazkmAeHrw2fR+SkoxOOX0+M4uXzsIr 6ZBbmlQMFbT3Ipaw5riIgVors0lMMnsOpJZonx6xCvVJf0nXYrCU+PB4towMDIY2JkeRq2HP JJxhTxHd0WYOhBkY0orA9EvmteB33X7UBl2twfAzUYwyzeKl1EguFT3C/LKfvSaSMMTmVyXz krE8H7+GQoyL8GExHyO9XfEru3BkCP/WY06D6Cj+7hhh1j77mAdARIZVFy/oNGil1WzHdlYL iQ86ico6KQ/6kGvZt38RAGj5m6JuAYGXNhdGPF87xuCopc4+C7AWDJCFGQYLo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9zJ8+6U 4JSdkGNDSaNzhHZKjBjjWFLw==
  • Ironport-sdr: im32WwA8wqy95LTe8LxrOVydWg/fOhlJGH0ZDQmpfo2UO03uqfxNWtgulUJdE4h3oY99ecIoW4 pLys2WJ5ozAWZvQmtlzmmqNz8MgOlsCMq3psJHz/Mi7rDJcF4Lb+dfkud8Mkw0Ct1bXundRcpT h8s+rHe9tJw0enU+fclUXQEvF8VaIY9FXNHjPUXdpAKuG8e1ubt7Zf9LrtWA4erH2gcvZTUeS5 UPPZ2KuoaBVZDsS4nCQxn5vHDB/5sw1MhB9bkLcsyACRpvhJsdLf1KhKTqYaxSFaWRybtMPu3g A1N3PmOETwVjUoPKTF7powke
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Jan 12, 2022 at 05:41:42PM +0100, Dario Faggioli wrote:
> If we are in libvxl_list_vcpu() and we are returning NULL, let's avoid

extra 'v'         ^ here.

> touching the output parameter *nr_vcpus_out (which should contain the
> number of vcpus in the list). Ideally, the caller initialized it to 0,
> which is therefore consistent with us returning NULL (or, as an alternative,
> we can explicitly set it to 0 if we're returning null... But just not
> touching it seems the best behavior).
> 
> In fact, the current behavior is especially problematic if, for
> instance, a domain is destroyed after we have done some steps of the
> for() loop. In which case, calls like xc_vcpu_getinfo() or
> xc_vcpu_getaffinity() will start to fail, and we return back to the
> caller inconsistent information, such as a NULL list of vcpus, but a
> modified and not 0 any longer, number of vcpus in the list.
> 
> Signed-off-by: Dario Faggioli <dfaggioli@xxxxxxxx>
> Tested-by: James Fehlig <jfehlig@xxxxxxxx>
> ---
> diff --git a/tools/libs/light/libxl_domain.c b/tools/libs/light/libxl_domain.c
> index 544a9bf59d..aabc264e16 100644
> --- a/tools/libs/light/libxl_domain.c
> +++ b/tools/libs/light/libxl_domain.c
> @@ -1705,6 +1706,7 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, 
> uint32_t domid,
>          ptr->vcpu_time = vcpuinfo.cpu_time;
>      }
>      GC_FREE;
> +    *nr_vcpus_out = nr_vcpus;

Can you swap those two lines, to keep GC_FREE just before return?

>      return ret;
>  
>  err:
> diff --git a/tools/libs/light/libxl_numa.c b/tools/libs/light/libxl_numa.c
> index 3679028c79..b04e3917a0 100644
> --- a/tools/libs/light/libxl_numa.c
> +++ b/tools/libs/light/libxl_numa.c
> @@ -219,8 +219,10 @@ static int nr_vcpus_on_nodes(libxl__gc *gc, 
> libxl_cputopology *tinfo,
>              goto next;
>  
>          vinfo = libxl_list_vcpu(CTX, dinfo[i].domid, &nr_dom_vcpus, 
> &nr_cpus);
> -        if (vinfo == NULL)
> +        if (vinfo == NULL) {
> +            assert(nr_dom_vcpus == 0);

I don't think this assert is necessary.

>              goto next;
> +        }

Otherwise, this patch looks fine.

Thanks,

-- 
Anthony PERARD



 


Rackspace

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