Beispiel #1
0
 def pinned_cpus(self):
     """
     :return: A dictionary in which key is vCPU ID and value is a frozenset
       with IDs of pCPUs the vCPU is pinned to. If a vCPU is not pinned to
       any pCPU it is not listed in the dictionary. Empty dictionary is
       returned if none of the vCPUs has a pinning defined.
     """
     cputune = vmxml.find_first(self._dom, 'cputune', None)
     if cputune is None:
         return {}
     pinning = dict()
     for vcpupin in vmxml.find_all(cputune, 'vcpupin'):
         cpuset = vcpupin.get('cpuset', None)
         vcpu = vcpupin.get('vcpu', None)
         if vcpu is not None and cpuset is not None:
             cpus = taskset.cpulist_parse(cpuset)
             if len(cpus) > 0:
                 pinning[int(vcpu)] = cpus
     return pinning
Beispiel #2
0
 def _qga_call_get_vcpus(self, vm):
     try:
         self.log.debug('Requesting guest CPU info for vm=%s', vm.id)
         with vm.qga_context(_COMMAND_TIMEOUT):
             vcpus = QemuGuestAgentDomain(vm).guestVcpus()
     except (exception.NonResponsiveGuestAgent, libvirt.libvirtError) as e:
         self.log.info('Failed to get guest CPU info for vm=%s, error: %s',
                       vm.id, e)
         self.set_failure(vm.id)
         return {}
     except virdomain.NotConnectedError:
         self.log.debug(
             'Not querying QEMU-GA for guest CPU info because domain'
             'is not running for vm-id=%s', vm.id)
         return {}
     if 'online' in vcpus:
         count = len(taskset.cpulist_parse(vcpus['online']))
     else:
         count = -1
     return {'guestCPUCount': count}
Beispiel #3
0
def _expand_list(cpuset):
    cpulist = sorted(taskset.cpulist_parse(cpuset))
    return [str(cpu) for cpu in cpulist]