示例#1
0
 def test_libvirt_exception_cpu_features(self):
     machinetype.cpu_features.invalidate()
     with MonkeyPatchScope([
         (machinetype.libvirtconnection, 'get',
          lambda: FailingConnection()),
     ]):
         result = machinetype.cpu_features()
         self.assertEqual(result, [])
示例#2
0
 def test_cpu_features(self, arch, expected_features):
     machinetype.cpu_features.invalidate()
     conn = FakeConnection(arch)
     with MonkeyPatchScope([
             (machinetype.cpuarch, 'real', lambda: arch),
             (machinetype.libvirtconnection, 'get', lambda: conn), ]):
         result = machinetype.cpu_features()
         self.assertEqual(result, expected_features)
示例#3
0
 def test_cpu_features_no_ibrs(self):
     machinetype.cpu_features.invalidate()
     conn = FakeConnection(cpuarch.X86_64,
                           file_name='domcaps_libvirt_x86_64_noibrs.out')
     with MonkeyPatchScope([
         (machinetype.cpuarch, 'real', lambda: cpuarch.X86_64),
         (machinetype.libvirtconnection, 'get', lambda: conn),
     ]):
         result = machinetype.cpu_features()
         self.assertEqual(result, _EXPECTED_CPU_FEATURES_X86_64)
示例#4
0
def _getFlagsAndFeatures():
    """
    Read CPU flags from cpuinfo and CPU features from domcapabilities,
    and combine them into a single list.
    """
    # We need to use both flags (cpuinfo.flags()) and domcapabilites
    # (machinetype.cpu_features) because they return different sets
    # of flags (domcapabilities also return the content of
    # arch_capabilities). The sets overlap, so we convert
    # list -> set -> list to remove duplicates.
    flags_and_features = list(set(cpuinfo.flags() +
                                  machinetype.cpu_features()))
    return flags_and_features + machinetype.compatible_cpu_models()
示例#5
0
def _getFlagsAndFeatures():
    """
    Read CPU flags from cpuinfo and CPU features from domcapabilities,
    and combine them into a single list.
    """
    # We need to use both flags (cpuinfo.flags()) and domcapabilites
    # (machinetype.cpu_features) because they return different sets
    # of flags (domcapabilities also return the content of
    # arch_capabilities). The sets overlap, so we convert
    # list -> set -> list to remove duplicates.
    flags_and_features = list(set(cpuinfo.flags() +
                                  machinetype.cpu_features()))
    cpu_models = machinetype.compatible_cpu_models()
    # Easier to add here than in Engine:
    # If -IBRS suffix is present in any of the compatible CPU models,
    # we can assume spec_ctrl feature.
    for model in cpu_models:
        if model.endswith('-IBRS'):
            spec_ctrl = 'spec_ctrl'
            if spec_ctrl not in flags_and_features:
                flags_and_features.append(spec_ctrl)
            break
    return flags_and_features + cpu_models