mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-23 20:02:21 +00:00
qemu, lxc: Change host CPU number detection logic.
The drivers for QEMU and LXC use virNodeGetInfo only to determine the number of host CPUs. On Linux hosts nodeGetCPUCount has less overhead.
This commit is contained in:
parent
689b64d666
commit
a2b3d7cff8
@ -492,17 +492,15 @@ static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
|
|||||||
static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
|
static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
|
||||||
{
|
{
|
||||||
int hostcpus, maxcpu = CPU_SETSIZE;
|
int hostcpus, maxcpu = CPU_SETSIZE;
|
||||||
virNodeInfo nodeinfo;
|
|
||||||
virBitmapPtr cpumap, cpumapToSet;
|
virBitmapPtr cpumap, cpumapToSet;
|
||||||
|
|
||||||
VIR_DEBUG("Setting CPU affinity");
|
VIR_DEBUG("Setting CPU affinity");
|
||||||
|
|
||||||
if (nodeGetInfo(NULL, &nodeinfo) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* setaffinity fails if you set bits for CPUs which
|
/* setaffinity fails if you set bits for CPUs which
|
||||||
* aren't present, so we have to limit ourselves */
|
* aren't present, so we have to limit ourselves */
|
||||||
hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
|
if ((hostcpus = nodeGetCPUCount()) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (maxcpu > hostcpus)
|
if (maxcpu > hostcpus)
|
||||||
maxcpu = hostcpus;
|
maxcpu = hostcpus;
|
||||||
|
|
||||||
|
@ -4170,7 +4170,6 @@ qemudDomainGetVcpuPinInfo(virDomainPtr dom,
|
|||||||
|
|
||||||
struct qemud_driver *driver = dom->conn->privateData;
|
struct qemud_driver *driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
virNodeInfo nodeinfo;
|
|
||||||
virDomainDefPtr targetDef = NULL;
|
virDomainDefPtr targetDef = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int maxcpu, hostcpus, vcpu, pcpu;
|
int maxcpu, hostcpus, vcpu, pcpu;
|
||||||
@ -4206,9 +4205,9 @@ qemudDomainGetVcpuPinInfo(virDomainPtr dom,
|
|||||||
/* Coverity didn't realize that targetDef must be set if we got here. */
|
/* Coverity didn't realize that targetDef must be set if we got here. */
|
||||||
sa_assert(targetDef);
|
sa_assert(targetDef);
|
||||||
|
|
||||||
if (nodeGetInfo(dom->conn, &nodeinfo) < 0)
|
if ((hostcpus = nodeGetCPUCount()) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
|
|
||||||
maxcpu = maplen * 8;
|
maxcpu = maplen * 8;
|
||||||
if (maxcpu > hostcpus)
|
if (maxcpu > hostcpus)
|
||||||
maxcpu = hostcpus;
|
maxcpu = hostcpus;
|
||||||
@ -4421,7 +4420,6 @@ qemudDomainGetEmulatorPinInfo(virDomainPtr dom,
|
|||||||
{
|
{
|
||||||
struct qemud_driver *driver = dom->conn->privateData;
|
struct qemud_driver *driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm = NULL;
|
virDomainObjPtr vm = NULL;
|
||||||
virNodeInfo nodeinfo;
|
|
||||||
virDomainDefPtr targetDef = NULL;
|
virDomainDefPtr targetDef = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int maxcpu, hostcpus, pcpu;
|
int maxcpu, hostcpus, pcpu;
|
||||||
@ -4453,9 +4451,9 @@ qemudDomainGetEmulatorPinInfo(virDomainPtr dom,
|
|||||||
/* Coverity didn't realize that targetDef must be set if we got here. */
|
/* Coverity didn't realize that targetDef must be set if we got here. */
|
||||||
sa_assert(targetDef);
|
sa_assert(targetDef);
|
||||||
|
|
||||||
if (nodeGetInfo(dom->conn, &nodeinfo) < 0)
|
if ((hostcpus = nodeGetCPUCount()) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
|
|
||||||
maxcpu = maplen * 8;
|
maxcpu = maplen * 8;
|
||||||
if (maxcpu > hostcpus)
|
if (maxcpu > hostcpus)
|
||||||
maxcpu = hostcpus;
|
maxcpu = hostcpus;
|
||||||
@ -4498,7 +4496,6 @@ qemudDomainGetVcpus(virDomainPtr dom,
|
|||||||
int maplen) {
|
int maplen) {
|
||||||
struct qemud_driver *driver = dom->conn->privateData;
|
struct qemud_driver *driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
virNodeInfo nodeinfo;
|
|
||||||
int i, v, maxcpu, hostcpus;
|
int i, v, maxcpu, hostcpus;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
qemuDomainObjPrivatePtr priv;
|
qemuDomainObjPrivatePtr priv;
|
||||||
@ -4524,10 +4521,9 @@ qemudDomainGetVcpus(virDomainPtr dom,
|
|||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
|
|
||||||
if (nodeGetInfo(dom->conn, &nodeinfo) < 0)
|
if ((hostcpus = nodeGetCPUCount()) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
|
|
||||||
maxcpu = maplen * 8;
|
maxcpu = maplen * 8;
|
||||||
if (maxcpu > hostcpus)
|
if (maxcpu > hostcpus)
|
||||||
maxcpu = hostcpus;
|
maxcpu = hostcpus;
|
||||||
|
@ -1902,15 +1902,13 @@ qemuPrepareCpumap(struct qemud_driver *driver,
|
|||||||
virBitmapPtr nodemask)
|
virBitmapPtr nodemask)
|
||||||
{
|
{
|
||||||
int i, hostcpus, maxcpu = QEMUD_CPUMASK_LEN;
|
int i, hostcpus, maxcpu = QEMUD_CPUMASK_LEN;
|
||||||
virNodeInfo nodeinfo;
|
|
||||||
virBitmapPtr cpumap = NULL;
|
virBitmapPtr cpumap = NULL;
|
||||||
|
|
||||||
if (nodeGetInfo(NULL, &nodeinfo) < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* setaffinity fails if you set bits for CPUs which
|
/* setaffinity fails if you set bits for CPUs which
|
||||||
* aren't present, so we have to limit ourselves */
|
* aren't present, so we have to limit ourselves */
|
||||||
hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
|
if ((hostcpus = nodeGetCPUCount()) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (maxcpu > hostcpus)
|
if (maxcpu > hostcpus)
|
||||||
maxcpu = hostcpus;
|
maxcpu = hostcpus;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user