def _validation(self): shouldStopLibvirt = self._startLibvirt() try: compatible = machinetype.compatible_cpu_models() self.logger.debug( 'Compatible CPU models are: %s', compatible, ) supported = ( set([entry['model'] for entry in self.CPU_FAMILIES]) & set(compatible) ) # All-in-one want the best cpu between compatible. # The preference is defined by the order of # CPU_FAMILIES # We need to save the corresponding CPU name for cluster # creation. for entry in self.CPU_FAMILIES: if entry['model'] in supported: self.environment[ oliveconst.CoreEnv.VDSM_CPU ] = entry['name'] break finally: if shouldStopLibvirt: self.services.state( name=self.LIBVIRTD_SERVICE_NAME, state=False, )
def test_libvirt_exception(self): machinetype.compatible_cpu_models.invalidate() with MonkeyPatchScope([ (machinetype.libvirtconnection, 'get', lambda: FailingConnection()), ]): result = machinetype.compatible_cpu_models() self.assertEqual(result, [])
def test_cpu_models(self, arch, expected_models): machinetype.compatible_cpu_models.invalidate() with MonkeyPatchScope([ (machinetype.cpuarch, 'real', lambda: arch), (machinetype.libvirtconnection, 'get', lambda: FakeConnection(arch)), ]): result = machinetype.compatible_cpu_models() result = set(result) expected = set(['model_' + m for m in expected_models]) self.assertEqual(result, expected)
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()
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
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['containers'] = containersconnection.is_supported() caps['hostedEngineDeployed'] = _isHostedEngineDeployed() caps['hugepages'] = hugepages.supported() caps['kernelFeatures'] = osinfo.kernel_features() 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['kernelArgs'] = osinfo.kernel_args() 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.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()) # 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