[libvirt] [PATCHv2 1/3] qemu, lxc: Change host CPU detection logic.
eblake at redhat.com
Thu Nov 1 03:00:06 UTC 2012
On 10/31/2012 11:20 AM, Viktor Mihajlovski wrote:
> The drivers for QEMU and LXC use virNodeGetInfo to determine the
> number of host CPUs. This approach can lead to a wrong (too small)
> number if one or more CPUs are offline.
> It is better to use nodeGetCPUCount on Linux hosts.
> V2 Changes:
> Use nodeGetCPUCount as suggested by Eric, nodeGetCPUMap is too
Hmm, while reading this patch series, I realized that my initial RPC
implementation always requests the number of online processors over the
wire, even though you've now proven that calling virNodeGetCPUMap(conn,
NULL, NULL, 0) is useful. I'll see about getting in a followup patch to
optimize the on-the-wire call to avoid wasted effort of collecting a
bitmap just to determine the number of online CPUs when we really only
care about the max cpu number.
Meanwhile, on to this patch:
> @@ -492,17 +492,15 @@ static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
> static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
> int hostcpus, maxcpu = CPU_SETSIZE;
> - virNodeInfo nodeinfo;
> virBitmapPtr cpumap, cpumapToSet;
> VIR_DEBUG("Setting CPU affinity");
> - if (nodeGetInfo(NULL, &nodeinfo) < 0)
> - return -1;
> /* setaffinity fails if you set bits for CPUs which
> * aren't present, so we have to limit ourselves */
Question - does setaffinity fail if you request setting a CPU that is
present but offline? In that case, we would need the CPU map instead of
just the count of max cpus. But in the meantime, I'm okay with your patch.
ACK, and will push shortly.
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 617 bytes
Desc: OpenPGP digital signature
More information about the libvir-list