summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Berendt <berendt@b1-systems.de>2012-11-29 18:03:02 +0100
committerChristian Berendt <berendt@b1-systems.de>2012-11-29 18:30:08 +0100
commit16cb60ce661f00f9a91c8ad02c381d2f9c504580 (patch)
tree885db6116682bce9c2a722386dc0b4b32ea0daca
parenta89c2ababda2ebdc115c171605a2989fc80bf101 (diff)
downloadnova-16cb60ce661f00f9a91c8ad02c381d2f9c504580.tar.gz
nova-16cb60ce661f00f9a91c8ad02c381d2f9c504580.tar.xz
nova-16cb60ce661f00f9a91c8ad02c381d2f9c504580.zip
use libvirt getInfo() to receive number of physical CPUs
multiprocessing.cpu_count() reports the wrong number of physical CPUs on a Xen dom0 system. Because we're inside the libvirt virtualization driver the corresponding libvirt method (getInfo()) should be used instead. fixes bug 1084611 Change-Id: Ida4be889ce98c7a6f58564a8bc295b360ff65965
-rw-r--r--nova/virt/libvirt/driver.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index b2063c88b..b1c2acf85 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -43,7 +43,6 @@ import errno
import functools
import glob
import hashlib
-import multiprocessing
import os
import shutil
import sys
@@ -1995,21 +1994,18 @@ class LibvirtDriver(driver.ComputeDriver):
return interfaces
- @staticmethod
- def get_vcpu_total():
+ def get_vcpu_total(self):
"""Get vcpu number of physical computer.
:returns: the number of cpu core.
"""
- # On certain platforms, this will raise a NotImplementedError.
try:
- return multiprocessing.cpu_count()
- except NotImplementedError:
+ return self._conn.getInfo()[2]
+ except libvirt.libvirtError:
LOG.warn(_("Cannot get the number of cpu, because this "
- "function is not implemented for this platform. "
- "This error can be safely ignored for now."))
+ "function is not implemented for this platform. "))
return 0
def get_memory_mb_total(self):