From a99da363a4e1a68b3a9327a4302f75b39b12fa23 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 20 Mar 2014 13:48:49 -0400 Subject: capabilities: Handle arch=none for CPU lookup --- virtinst/capabilities.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/virtinst/capabilities.py b/virtinst/capabilities.py index 029bfdbf..f5c28afb 100644 --- a/virtinst/capabilities.py +++ b/virtinst/capabilities.py @@ -75,7 +75,7 @@ class CPUValuesArch(object): raise ValueError(_("Unknown CPU model '%s'") % model) -class CPUValues(object): +class _CPUAPIValues(object): """ Lists valid values for cpu models obtained trough libvirt's getCPUModelNames """ @@ -97,13 +97,13 @@ class CPUValues(object): return [] -class CPUMapFileValues(CPUValues): +class _CPUMapFileValues(_CPUAPIValues): """ Fallback method to lists cpu models, parsed directly from libvirt's local cpu_map.xml """ def __init__(self): - CPUValues.__init__(self) + _CPUAPIValues.__init__(self) self.archmap = {} cpu_filename = "/usr/share/libvirt/cpu_map.xml" xml = file(cpu_filename).read() @@ -123,8 +123,6 @@ class CPUMapFileValues(CPUValues): def get_cpus(self, arch, conn): ignore = conn - if not arch: - return None if re.match(r'i[4-9]86', arch): arch = "x86" elif arch == "x86_64": @@ -619,14 +617,16 @@ class Capabilities(object): child = child.next def get_cpu_values(self, conn, arch): + if not arch: + return [] if self._cpu_values: return self._cpu_values.get_cpus(arch, conn) # Iterate over the available methods until a set of CPU models is found - for mode in (CPUValues, CPUMapFileValues): + for mode in (_CPUAPIValues, _CPUMapFileValues): cpu_values = mode() cpus = cpu_values.get_cpus(arch, conn) - if cpus and len(cpus) > 0: + if len(cpus) > 0: self._cpu_values = cpu_values return cpus -- cgit v1.2.1