From: Ian Campbell Subject: Re: [PATCH] libxl: use xc_topologyinfo to figure out how many CPUs we actually have Date: Wed, 9 May 2012 13:04:34 +0100 Message-ID: <1336565074.25514.104.camel@zakaz.uk.xensource.com> References: <420c8861a2d2a61a7e80.1336561430@Solace> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <420c8861a2d2a61a7e80.1336561430@Solace> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Darrio Faggioli Cc: George Dunlap , Ian Jackson , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Wed, 2012-05-09 at 12:03 +0100, Darrio Faggioli wrote: > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -2903,7 +2903,8 @@ libxl_cputopology *libxl_get_cpu_topolog > } > > for (i = 0; i < max_cpus; i++) { > -#define V(map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \ > +#define V(map, i) (i > tinfo.max_cpu_index || \ > + map[i] == INVALID_TOPOLOGY_ID) ? \ This ensures that cpus entries above max_cpu_index are INVALID_TOPOLOGY_ID but do you also want to size the return array using tinfo.max_cpu_index too? And also return that in *nr instead of? (I don't know the answer, either of max-possible- and max-online-cpus is a reasonable size for this array) > LIBXL_CPUTOPOLOGY_INVALID_ENTRY : map[i] > ret[i].core = V(coremap, i); > ret[i].socket = V(socketmap, i);