All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: ncmike@us.ibm.com
Cc: xen-devel@lists.xensource.com
Subject: Re: [PATCH] add count-only option to DOM0_GETDOMAININFOLIST hypercall
Date: Wed, 22 Mar 2006 19:19:49 -0600	[thread overview]
Message-ID: <4421F7B5.9090403@us.ibm.com> (raw)
In-Reply-To: <200603230048.k2N0mlxx017489@mdday.raleigh.ibm.com>

There's a race condition here.  There's no way of knowing that domains 
haven't been destroyed (or created) in between these calls.

Unfortunately, the only way to avoid this is grab them one at a time.

Regards,

Anthony Liguori

Mike D. Day wrote:
> signed-off-by: Mike D. Day <ncmike@us.ibm.com>
>
> When retreiving a list of domain info structs it would be helpful
> to know the current domain count prior to making the hcall. This 
> would make it simpler to allocate a return buffer of the 
> appropriate size. 
>
> Adding the six lines to the case for the GETDOMAININFOLIST dom0 op
> allows the caller to retrieve only the count of the domains. The 
> use model is as follows: 
>
>     int number_domains;
>     struct dom0_op info;
>     info.cmd = DOM0_GETDOMAININFOLIST;
>     info.u.getdomaininfolist.max_domains = 0;
>
>     HYPERCALL_dom0_op(&info);
>
>     number_domains = info.u.getdomaininfolist.max_domains;
>
> Having the number of domains, the caller can now allocate
> a buffer of the correct size to get the actual domain 
> information.    
>
> # HG changeset patch
> # User mdday@dual.silverwood.home
> # Node ID cd6869742400411fdaf295cc4e0167361e967619
> # Parent  5d3c2cb42ec41984cb1e586d3e47a8692eb8b132
> modify domain infolist hypercall to optionally return only a count of domains
>
> diff -r 5d3c2cb42ec4 -r cd6869742400 xen/common/dom0_ops.c
> --- a/xen/common/dom0_ops.c	Wed Mar 22 19:05:50 2006 +0100
> +++ b/xen/common/dom0_ops.c	Wed Mar 22 19:30:28 2006 -0500
> @@ -416,6 +416,12 @@ long do_dom0_op(GUEST_HANDLE(dom0_op_t) 
>  
>          for_each_domain ( d )
>          {
> +            if (op->u.getdomaininfolist.max_domains == 0) 
> +            {
> +                num_domains++;
> +                continue;
> +            }
> +                
>              if ( d->domain_id < op->u.getdomaininfolist.first_domain )
>                  continue;
>              if ( num_domains == op->u.getdomaininfolist.max_domains )
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
>   

  reply	other threads:[~2006-03-23  1:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-23  0:48 [PATCH] add count-only option to DOM0_GETDOMAININFOLIST hypercall Mike D. Day
2006-03-23  1:19 ` Anthony Liguori [this message]
2006-03-23 10:21   ` Mike D. Day

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=4421F7B5.9090403@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=ncmike@us.ibm.com \
    --cc=xen-devel@lists.xensource.com \
    /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.