
On 10/31/2012 08:58 PM, Hu Tao wrote:
On Wed, Oct 31, 2012 at 06:20:58PM +0100, Viktor Mihajlovski wrote:
Modified the places where virNodeGetInfo was used for the purpose of obtaining the maximum node CPU number. Transparently falling back to virNodeGetInfo in case of failure. Wrote utility function vshNodeGetCPUCount to compute node CPU number.
+static int +vshNodeGetCPUCount(virConnectPtr conn) +{ + int ret; + virNodeInfo nodeinfo; + + if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0)) < 0) { + /* fall back to nodeinfo */ + if (virNodeGetInfo(conn, &nodeinfo) == 0) { + ret = VIR_NODEINFO_MAXCPUS(nodeinfo); + }
Isn't VIR_NODEINFO_MAXCPUS buggy? Either don't fall back to nodeinfo or fix it.
Hmm, and I just realized another issue - on the RHEL 5 box I tested, there is no /sys/devices/system/cpu/possible, so virNodeGetCPUCount() currently fails, even though virNodeGetInfo() succeeded. I'm going to hold off pushing this series until after 1.0.0, to avoid any chance of a last-minute unintentional regression. You were asking about VIR_NODEINFO_MAXCPUS: #define VIR_NODEINFO_MAXCPUS(nodeinfo) ((nodeinfo).nodes*(nodeinfo).sockets*(nodeinfo).cores*(nodeinfo).threads) I can confirm that virNodeGetInfo misbehaves if enough trailing cpus are offline, and therefore agree that we need to fix that API: # virsh nodeinfo CPU model: x86_64 CPU(s): 2 CPU frequency: 2801 MHz CPU socket(s): 1 Core(s) per socket: 2 Thread(s) per core: 1 NUMA cell(s): 1 Memory size: 3941792 KiB # echo 0 > /sys/devices/system/cpu/cpu1/online # virsh nodeinfo CPU model: x86_64 CPU(s): 1 CPU frequency: 2801 MHz CPU socket(s): 1 Core(s) per socket: 1 Thread(s) per core: 1 NUMA cell(s): 1 Memory size: 3941792 KiB That just changed things from 2 to 1. No fun. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org