All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@vates.tech>
To: Amneesh Singh <a-singh21@ti.com>
Cc: xen-devel@lists.xenproject.org
Subject: Re: [PATCH] tools/helpers/init-dom0less: fix vcpu availability
Date: Wed, 14 Aug 2024 09:18:56 +0000	[thread overview]
Message-ID: <Zrx2f7Y2EXBKYThf@l14> (raw)
In-Reply-To: <20240802075823.116920-1-a-singh21@ti.com>

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


      parent reply	other threads:[~2024-08-14  9:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-02  7:58 [PATCH] tools/helpers/init-dom0less: fix vcpu availability Amneesh Singh
2024-08-06 10:49 ` Amneesh Singh
2024-08-14  9:18 ` Anthony PERARD [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zrx2f7Y2EXBKYThf@l14 \
    --to=anthony.perard@vates.tech \
    --cc=a-singh21@ti.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.