def _fake_caps_arch(caps, arch): ''' Mutate 'caps' to act as an architecture set by fake_kvm_architecture configuration option. Arguments: caps The host capabilities as returned by hooking.read_json. ''' arch = arch caps['kvmEnabled'] = True if cpuarch.is_x86(arch): caps['emulatedMachines'] = _X86_64_MACHINES caps['cpuModel'] = 'Intel(Fake) CPU' flag_list = ['vmx', 'sse2', 'nx'] if cpuarch.real() == cpuarch.X86_64: flag_list += cpuinfo.flags() flags = set(flag_list) caps['cpuFlags'] = ','.join(flags) + ',model_486,model_pentium,' \ 'model_pentium2,model_pentium3,model_pentiumpro,' \ 'model_qemu32,model_coreduo,model_core2duo,model_n270,' \ 'model_Conroe,model_Penryn,model_Nehalem,model_Opteron_G1' elif cpuarch.is_ppc(arch): caps['emulatedMachines'] = _PPC64LE_MACHINES caps['cpuModel'] = 'POWER 8(fake)' caps['cpuFlags'] = 'powernv,model_POWER8' else: raise cpuarch.UnsupportedArchitecture(arch)
def test_cpuinfo_POWER8E_ppc64le(self): self.assertEqual(cpuinfo.flags(), ['powernv']) self.assertEqual(cpuinfo.frequency(), '3690.000000') self.assertEqual(cpuinfo.model(), 'POWER8E (raw), altivec supported') self.assertEqual(cpuinfo.platform(), 'PowerNV') self.assertEqual(cpuinfo.machine(), 'PowerNV 8247-22L')
def test_cpuinfo_s390x_z196(self): self.assertEqual(cpuinfo.flags(), ['esan3', 'zarch', 'stfle', 'msa', 'ldisp', 'eimm', 'dfp', 'etf3eh', 'highgprs']) self.assertEqual(cpuinfo.frequency(), 'unavailable') self.assertEqual(cpuinfo.model(), '2817')
def test_cpuinfo_s390x_z14(self): self.assertEqual(cpuinfo.flags(), ['esan3', 'zarch', 'stfle', 'msa', 'ldisp', 'eimm', 'dfp', 'edat', 'etf3eh', 'highgprs', 'te', 'vx', 'vxd', 'vxe', 'sie']) self.assertEqual(cpuinfo.frequency(), '5208') self.assertEqual(cpuinfo.model(), '3906')
def _is_hugetlbfs_1g_mounted(mtab_path='/etc/mtab'): if cpuarch.is_ppc(cpuarch.real()) or 'pdpe1gb' not in cpuinfo.flags(): return True with open(mtab_path, 'r') as f: for line in f: if '/dev/hugepages1G' in line: return True return False
def test_cpuinfo_E5649_x86_64(self): self.assertEqual( set(cpuinfo.flags()), set(('pebs', 'ssse3', 'pge', 'vmx', 'clflush', 'syscall', 'vme', 'dtes64', 'tsc', 'est', 'xtopology', 'xtpr', 'cmov', 'nx', 'constant_tsc', 'pat', 'bts', 'tpr_shadow', 'smx', 'lm', 'msr', 'fpu', 'fxsr', 'tm', 'pae', 'arch_perfmon', 'acpi', 'popcnt', 'mmx', 'arat', 'flexpriority', 'cx8', 'nonstop_tsc', 'mce', 'de', 'sse4_1', 'pclmulqdq', 'mca', 'pse', 'pni', 'rep_good', 'pdcm', 'ht', 'pdpe1gb', 'apic', 'sse', 'sse4_2', 'dca', 'aperfmperf', 'monitor', 'lahf_lm', 'rdtscp', 'aes', 'vnmi', 'sse2', 'ss', 'ept', 'ds_cpl', 'vpid', 'pbe', 'cx16', 'pse36', 'mtrr', 'dts', 'tm2', 'epb'))) self.assertEqual(cpuinfo.frequency(), '2533.402') self.assertEqual(cpuinfo.model(), 'Intel(R) Xeon(R) CPU E5649 @ 2.53GHz')
def x86_64_test(): caps = {'cpuModel': None, 'cpuFlags': None, 'emulatedMachines': None, 'kvmEnabled': False} expected_caps = {'cpuModel': 'Intel(Fake) CPU', 'cpuFlags': ',model_486,model_pentium,model_pentium2,' 'model_pentium3,model_pentiumpro,model_qemu32,' 'model_coreduo,model_core2duo,model_n270,model_Conroe,' 'model_Penryn,model_Nehalem,model_Opteron_G1', 'emulatedMachines': ['pc-i440fx-rhel7.1.0', 'rhel6.3.0', 'pc-q35-rhel7.2.0', 'pc-i440fx-rhel7.0.0', 'rhel6.1.0', 'rhel6.6.0', 'rhel6.2.0', 'pc', 'pc-q35-rhel7.0.0', 'pc-q35-rhel7.1.0', 'q35', 'pc-i440fx-rhel7.2.0', 'rhel6.4.0', 'rhel6.0.0', 'rhel6.5.0'], 'kvmEnabled': True} # This is duplicate of the real functionality and is required because we do # not know which flags are added unless we query the host cpu. flag_list = ['vmx', 'sse2', 'nx'] if cpuarch.real() == cpuarch.X86_64: flag_list += cpuinfo.flags() expected_caps['cpuFlags'] = (','.join(set(flag_list)) + expected_caps['cpuFlags']) _fake_caps_arch(caps, cpuarch.X86_64) return caps == expected_caps
def test_cpuinfo_aarch64(self): self.assertEqual(cpuinfo.flags(), ['fp', 'asimd', 'evtstrm']) self.assertEqual(cpuinfo.frequency(), '100.00') self.assertEqual(cpuinfo.model(), '0x000')
def get(): caps = {} cpu_topology = numa.cpu_topology() caps['kvmEnabled'] = str(os.path.exists('/dev/kvm')).lower() if config.getboolean('vars', 'report_host_threads_as_cores'): caps['cpuCores'] = str(cpu_topology.threads) else: caps['cpuCores'] = str(cpu_topology.cores) caps['cpuThreads'] = str(cpu_topology.threads) caps['cpuSockets'] = str(cpu_topology.sockets) caps['onlineCpus'] = ','.join(cpu_topology.online_cpus) caps['cpuSpeed'] = cpuinfo.frequency() caps['cpuModel'] = cpuinfo.model() caps['cpuFlags'] = ','.join(cpuinfo.flags() + machinetype.compatible_cpu_models()) caps.update(_getVersionInfo()) # TODO: Version requests by engine to ease handling of compatibility. netinfo_data = netinfo_cache.get(compatibility=30600) caps.update(netinfo_data) super_caps_networks = supervdsm.getProxy().caps_networks() caps.update(super_caps_networks) try: caps['hooks'] = hooks.installed() except: logging.debug('not reporting hooks', exc_info=True) caps['operatingSystem'] = osinfo.version() caps['uuid'] = host.uuid() caps['packages2'] = osinfo.package_versions() caps['emulatedMachines'] = machinetype.emulated_machines( cpuarch.effective()) caps['ISCSIInitiatorName'] = _getIscsiIniName() caps['HBAInventory'] = storage.hba.HBAInventory() caps['vmTypes'] = ['kvm'] caps['memSize'] = str(utils.readMemInfo()['MemTotal'] / 1024) caps['reservedMem'] = str(config.getint('vars', 'host_mem_reserve') + config.getint('vars', 'extra_mem_reserve')) caps['guestOverhead'] = config.get('vars', 'guest_ram_overhead') # Verify that our libvirt supports virtio RNG (since 10.0.2-31) requiredVer = LooseVersion('0.10.2-31') if 'libvirt' not in caps['packages2']: libvirtVer = None else: libvirtVer = LooseVersion( '-'.join((caps['packages2']['libvirt']['version'], caps['packages2']['libvirt']['release']))) if libvirtVer is None: logging.debug('VirtioRNG DISABLED: unknown libvirt version') elif libvirtVer < requiredVer: logging.debug('VirtioRNG DISABLED: libvirt version %s required >= %s', libvirtVer, requiredVer) else: caps['rngSources'] = vmdevices.core.Rng.available_sources() caps['numaNodes'] = dict(numa.topology()) caps['numaNodeDistance'] = dict(numa.distances()) caps['autoNumaBalancing'] = numa.autonuma_status() caps['selinux'] = osinfo.selinux_status() liveSnapSupported = _getLiveSnapshotSupport(cpuarch.effective()) if liveSnapSupported is not None: caps['liveSnapshot'] = str(liveSnapSupported).lower() caps['liveMerge'] = str(getLiveMergeSupport()).lower() caps['kdumpStatus'] = osinfo.kdump_status() caps['hostdevPassthrough'] = str(hostdev.is_supported()).lower() caps['additionalFeatures'] = [] if osinfo.glusterEnabled: from gluster.api import glusterAdditionalFeatures caps['additionalFeatures'].extend(glusterAdditionalFeatures()) return caps
def get(): caps = {} cpu_topology = numa.cpu_topology() caps['kvmEnabled'] = str(os.path.exists('/dev/kvm')).lower() if config.getboolean('vars', 'report_host_threads_as_cores'): caps['cpuCores'] = str(cpu_topology.threads) else: caps['cpuCores'] = str(cpu_topology.cores) caps['cpuThreads'] = str(cpu_topology.threads) caps['cpuSockets'] = str(cpu_topology.sockets) caps['onlineCpus'] = ','.join(cpu_topology.online_cpus) caps['cpuSpeed'] = cpuinfo.frequency() caps['cpuModel'] = cpuinfo.model() caps['cpuFlags'] = ','.join(cpuinfo.flags() + machinetype.compatible_cpu_models()) caps.update(_getVersionInfo()) net_caps = supervdsm.getProxy().network_caps() caps.update(net_caps) try: caps['hooks'] = hooks.installed() except: logging.debug('not reporting hooks', exc_info=True) caps['operatingSystem'] = osinfo.version() caps['uuid'] = host.uuid() caps['packages2'] = osinfo.package_versions() caps['realtimeKernel'] = osinfo.runtime_kernel_flags().realtime caps['kernelArgs'] = osinfo.kernel_args() caps['nestedVirtualization'] = osinfo.nested_virtualization().enabled caps['emulatedMachines'] = machinetype.emulated_machines( cpuarch.effective()) caps['ISCSIInitiatorName'] = _getIscsiIniName() caps['HBAInventory'] = hba.HBAInventory() caps['vmTypes'] = ['kvm'] caps['memSize'] = str(utils.readMemInfo()['MemTotal'] / 1024) caps['reservedMem'] = str(config.getint('vars', 'host_mem_reserve') + config.getint('vars', 'extra_mem_reserve')) caps['guestOverhead'] = config.get('vars', 'guest_ram_overhead') caps['rngSources'] = rngsources.list_available() caps['numaNodes'] = dict(numa.topology()) caps['numaNodeDistance'] = dict(numa.distances()) caps['autoNumaBalancing'] = numa.autonuma_status() caps['selinux'] = osinfo.selinux_status() liveSnapSupported = _getLiveSnapshotSupport(cpuarch.effective()) if liveSnapSupported is not None: caps['liveSnapshot'] = str(liveSnapSupported).lower() caps['liveMerge'] = str(getLiveMergeSupport()).lower() caps['kdumpStatus'] = osinfo.kdump_status() caps['hostdevPassthrough'] = str(hostdev.is_supported()).lower() caps['additionalFeatures'] = [] if osinfo.glusterEnabled: from vdsm.gluster.api import glusterAdditionalFeatures caps['additionalFeatures'].extend(glusterAdditionalFeatures()) caps['containers'] = containersconnection.is_supported() caps['hostedEngineDeployed'] = _isHostedEngineDeployed() return caps
def get(): caps = {} cpu_topology = numa.cpu_topology() caps['kvmEnabled'] = str(os.path.exists('/dev/kvm')).lower() if config.getboolean('vars', 'report_host_threads_as_cores'): caps['cpuCores'] = str(cpu_topology.threads) else: caps['cpuCores'] = str(cpu_topology.cores) caps['cpuThreads'] = str(cpu_topology.threads) caps['cpuSockets'] = str(cpu_topology.sockets) caps['onlineCpus'] = ','.join(cpu_topology.online_cpus) caps['cpuSpeed'] = cpuinfo.frequency() caps['cpuModel'] = cpuinfo.model() caps['cpuFlags'] = ','.join(cpuinfo.flags() + machinetype.compatible_cpu_models()) caps.update(_getVersionInfo()) net_caps = supervdsm.getProxy().network_caps() caps.update(net_caps) try: caps['hooks'] = hooks.installed() except: logging.debug('not reporting hooks', exc_info=True) caps['operatingSystem'] = osinfo.version() caps['uuid'] = host.uuid() caps['packages2'] = osinfo.package_versions() caps['realtimeKernel'] = osinfo.runtime_kernel_flags().realtime caps['kernelArgs'] = osinfo.kernel_args() caps['nestedVirtualization'] = osinfo.nested_virtualization().enabled caps['emulatedMachines'] = machinetype.emulated_machines( cpuarch.effective()) caps['ISCSIInitiatorName'] = _getIscsiIniName() caps['HBAInventory'] = hba.HBAInventory() caps['vmTypes'] = ['kvm'] caps['memSize'] = str(utils.readMemInfo()['MemTotal'] // 1024) caps['reservedMem'] = str(config.getint('vars', 'host_mem_reserve') + config.getint('vars', 'extra_mem_reserve')) caps['guestOverhead'] = config.get('vars', 'guest_ram_overhead') caps['rngSources'] = rngsources.list_available() caps['numaNodes'] = dict(numa.topology()) caps['numaNodeDistance'] = dict(numa.distances()) caps['autoNumaBalancing'] = numa.autonuma_status() caps['selinux'] = osinfo.selinux_status() caps['liveSnapshot'] = 'true' caps['liveMerge'] = 'true' caps['kdumpStatus'] = osinfo.kdump_status() caps['hostdevPassthrough'] = str(hostdev.is_supported()).lower() # TODO This needs to be removed after adding engine side support # and adding gdeploy support to enable libgfapi on RHHI by default caps['additionalFeatures'] = ['libgfapi_supported'] if osinfo.glusterEnabled: from vdsm.gluster.api import glusterAdditionalFeatures caps['additionalFeatures'].extend(glusterAdditionalFeatures()) caps['hostedEngineDeployed'] = _isHostedEngineDeployed() caps['hugepages'] = hugepages.supported() caps['kernelFeatures'] = osinfo.kernel_features() caps['vncEncrypted'] = _isVncEncrypted() caps['backupEnabled'] = False try: caps["connector_info"] = managedvolume.connector_info() except se.ManagedVolumeNotSupported as e: logging.info("managedvolume not supported: %s", e) except se.ManagedVolumeHelperFailed as e: logging.exception("Error getting managedvolume connector info: %s", e) return caps
def test_cpuinfo_POWER8E_ppc64le(self): self.assertEqual(cpuinfo.flags(), ['powernv']) self.assertEqual(cpuinfo.frequency(), '3690.000000') self.assertEqual(cpuinfo.model(), 'POWER8E (raw), altivec supported')