From 16cb60ce661f00f9a91c8ad02c381d2f9c504580 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Thu, 29 Nov 2012 18:03:02 +0100 Subject: 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 --- nova/virt/libvirt/driver.py | 12 ++++-------- 1 file 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): -- cgit