← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1322702] Re: libvirt get_host_capabilities() duplicates features

 

** Changed in: nova
       Status: Fix Committed => Fix Released

** Changed in: nova
    Milestone: None => juno-1

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1322702

Title:
  libvirt get_host_capabilities() duplicates features

Status in OpenStack Compute (Nova):
  Fix Released

Bug description:
  get_host_capabilities() in libvirt driver seems to have a bug that
  will result in duplicated features.

  def get_host_capabilities(self):
          """Returns an instance of config.LibvirtConfigCaps representing
             the capabilities of the host.
          """
          if not self._caps:
              xmlstr = self._conn.getCapabilities()
              self._caps = vconfig.LibvirtConfigCaps()
              self._caps.parse_str(xmlstr)
              if hasattr(libvirt, 'VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES'):
                  try:
                      features = self._conn.baselineCPU(
                          [self._caps.host.cpu.to_xml()],
                          libvirt.VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES)
                      # FIXME(wangpan): the return value of baselineCPU should be
                      #                 None or xml string, but libvirt has a bug
                      #                 of it from 1.1.2 which is fixed in 1.2.0,
                      #                 this -1 checking should be removed later.
                      if features and features != -1:
                          self._caps.host.cpu.parse_str(features)
                  except libvirt.libvirtError as ex:
                      error_code = ex.get_error_code()
                      if error_code == libvirt.VIR_ERR_NO_SUPPORT:
                          LOG.warn(_LW("URI %(uri)s does not support full set"
                                       " of host capabilities: " "%(error)s"),
                                       {'uri': self.uri(), 'error': ex})
                      else:
                          raise
          return self._caps

  
  The _caps.parse_str() is called in sequence for both capabilites and expand features. Since capabilities will have certain features in a VM, and these will be repeated again in the expand features, the _caps.host.cpu.features will end up with duplicated features. This will cause cpu compare to fail later.

  
  (nova)root@overcloud-novacompute0-un6ckrnp5tzl:~# python
  Python 2.7.6 (default, Mar 22 2014, 22:59:38) 
  [GCC 4.8.2] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import libvirt
  >>> conn = libvirt.open("qemu:///system")
  >>> from nova.virt.libvirt import config as vconfig
  >>> caps = vconfig.LibvirtConfigCaps()
  >>> xmlstr = conn.getCapabilities()
  >>> caps.parse_str(xmlstr)
  >>> features = conn.baselineCPU([caps.host.cpu.to_xml()], libvirt.VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES)
  >>> caps.host.cpu.parse_str(features)
  >>> for f in caps.host.cpu.features:
  ...     print f.name
  ... 
  hypervisor
  popcnt
  hypervisor
  popcnt
  pni
  sse2
  sse
  fxsr
  mmx
  pat
  cmov
  pge
  sep
  apic
  cx8
  mce
  pae
  msr
  tsc
  pse
  de
  fpu
  >>>

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1322702/+subscriptions


References