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

Re: [PATCH] tools/helpers/init-dom0less: fix vcpu availability



Hi Amneesh,

On Fri, Aug 02, 2024 at 01:28:25PM +0530, Amneesh Singh wrote:
> diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c
> index fee9345..a8cdc6d 100644
> --- a/tools/helpers/init-dom0less.c
> +++ b/tools/helpers/init-dom0less.c
> @@ -300,7 +301,7 @@ int main(int argc, char **argv)
>  {
>      libxl_dominfo *info = NULL;
>      libxl_ctx *ctx;
> -    int nb_vm = 0, rc = 0, i;
> +    int nb_vm = 0, nb_vcpu = 0, nr_cpus = 0, rc = 0, i;
>      struct xs_handle *xsh = NULL;
>      struct xc_interface_core *xch = NULL;
>      xenforeignmemory_handle *xfh = NULL;
> @@ -330,14 +331,17 @@ int main(int argc, char **argv)
>  
>      for (i = 0; i < nb_vm; i++) {
>          domid_t domid = info[i].domid;
> +        libxl_vcpuinfo *vcpuinfo;
>  
>          /* Don't need to check for Dom0 */
>          if (!domid)
>              continue;
>  
> +        vcpuinfo = libxl_list_vcpu(ctx, domid, &nb_vcpu, &nr_cpus);

You should check that libxl_list_vcpu() didn't return an error. If it
did, `vcpuinfo` would be NULL, and `nb_vcpu` would be an outdated value.


>          printf("Checking domid: %u\n", domid);
>          if (!domain_exists(xsh, domid)) {
> -            rc = init_domain(xsh, xch, xfh, &info[i]);
> +            rc = init_domain(xsh, xch, xfh, &info[i], vcpuinfo);
>              if (rc < 0) {
>                  fprintf(stderr, "init_domain failed.\n");
>                  goto out;
> @@ -345,6 +349,8 @@ int main(int argc, char **argv)
>          } else {
>              printf("Domain %u has already been initialized\n", domid);
>          }
> +
> +        libxl_vcpuinfo_list_free(vcpuinfo, nb_vcpu);
>      }
>  out:
>      libxl_dominfo_list_free(info, nb_vm);


The rest of the patch looks fine.

Thanks,

-- 

Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



 


Rackspace

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