Yes, I have run both of them on same machine. And 
am running libvirt 1.1.0. So, I guess it's not  a problem 
of older version.
 
Thanks
~Peeyush Gupta

From: Daniel P. Berrange <berrange@redhat.com>
To: Peeyush Gupta <gpeeyush@ymail.com>
Cc: "libvirt-users@redhat.com" <libvirt-users@redhat.com>
Sent: Tuesday, 17 September 2013 3:19 PM
Subject: Re: [libvirt-users] Finding out CPU topology.

On Tue, Sep 17, 2013 at 05:41:12PM +0800, Peeyush Gupta wrote:
> Hi all,
>
> I have been trying to find out cpu topology using libvirt. When
> I do 'virsh capabilites', I find this inside <topology> tag:
>
>
> <topology>
>       <cells num='1'>
>         <cell id='0'>
>           <memory unit='KiB'>3908488</memory>
>           <cpus num='4'>
>             <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
>             <cpu id='1' socket_id='0' core_id='0' siblings='1'/>
>             <cpu id='2' socket_id='0' core_id='1' siblings='2'/>
>             <cpu id='3' socket_id='0' core_id='1' siblings='3'/>
>           </cpus>
>         </cell>
>       </cells>
> </topology>
>
> But when I use the 'getCapbilities()' function of the python binding,
> the result is:
> <topology>    
>   <cells num='1'>   
>      <cell id='0'>         
>      <cpus num='4'>   
>        <cpu id='0'/>
>        <cpu id='1'/>
>        <cpu id='2'/>
>        <cpu id='3'/>         
>      </cpus>        
>    </cell>      
>  </cells>  
> </topology>\n
>
> As you can see this doesnt give any information about socket/core/thread etc.
> What I an interested to know is that is it a limitation of python binding or libvirt
> C API itself? How can I get the whole topology without just parsing the output
> of virsh capabilities?

Did you really run these two examples on the same machine, with the same
libvirt URI ? Both virsh and the python binding call the same libvirt API
'virConnectGetCapabilities' so will return the same data if run against
the same libvirt. The socket_id, core_id and siblings data is a relatively
new feature we added, so older libvirt won't show it.

Daniel
--
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-            http://virt-manager.org :|
|: http://autobuild.org      -o-        http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org      -o-      http://live.gnome.org/gtk-vnc :|