def _compare_cpu(self, cpu_info):
    'Checks the host cpu is compatible to a cpu given by xml.\n        "xml" must be a part of libvirt.openAuth(...).getCapabilities().\n        return values follows by virCPUCompareResult.\n        if 0 > return value, do live migration.\n        \'http://libvirt.org/html/libvirt-libvirt.html#virCPUCompareResult\'\n\n        :param cpu_info: json string of cpu feature from _get_cpu_info()\n        :returns:\n            None. if given cpu info is not compatible to this server,\n            raise exception.\n        '
    if (CONF.libvirt.virt_type == 'xen'):
        return 1
    info = jsonutils.loads(cpu_info)
    LOG.info(_LI('Instance launched has CPU info: %s'), cpu_info)
    cpu = vconfig.LibvirtConfigCPU()
    cpu.arch = info['arch']
    cpu.model = info['model']
    cpu.vendor = info['vendor']
    cpu.sockets = info['topology']['sockets']
    cpu.cores = info['topology']['cores']
    cpu.threads = info['topology']['threads']
    for f in info['features']:
        cpu.add_feature(vconfig.LibvirtConfigCPUFeature(f))
    u = 'http://libvirt.org/html/libvirt-libvirt.html#virCPUCompareResult'
    m = _("CPU doesn't have compatibility.\n\n%(ret)s\n\nRefer to %(u)s")
    try:
        ret = self._conn.compareCPU(cpu.to_xml(), 0)
    except libvirt.libvirtError as e:
        with excutils.save_and_reraise_exception():
            ret = unicode(e)
            LOG.error(m, {'ret': ret, 'u': u})
    if (ret <= 0):
        LOG.error(m, {'ret': ret, 'u': u})
        raise exception.InvalidCPUInfo(reason=(m % {'ret': ret, 'u': u}))
Checks the host cpu is compatible to a cpu given by xml.
"xml" must be a part of libvirt.openAuth(...).getCapabilities().
return values follows by virCPUCompareResult.
if 0 > return value, do live migration.
'http://libvirt.org/html/libvirt-libvirt.html#virCPUCompareResult'

:param cpu_info: json string of cpu feature from _get_cpu_info()
:returns:
    None. if given cpu info is not compatible to this server,
    raise exception.
def _compare_cpu(self, cpu_info):
    'Checks the host cpu is compatible to a cpu given by xml.\n        "xml" must be a part of libvirt.openAuth(...).getCapabilities().\n        return values follows by virCPUCompareResult.\n        if 0 > return value, do live migration.\n        \'http://libvirt.org/html/libvirt-libvirt.html#virCPUCompareResult\'\n\n        :param cpu_info: json string of cpu feature from _get_cpu_info()\n        :returns:\n            None. if given cpu info is not compatible to this server,\n            raise exception.\n        '
    if (CONF.libvirt.virt_type == 'xen'):
        return 1
    info = jsonutils.loads(cpu_info)
    LOG.info(_LI('Instance launched has CPU info: %s'), cpu_info)
    cpu = vconfig.LibvirtConfigCPU()
    cpu.arch = info['arch']
    cpu.model = info['model']
    cpu.vendor = info['vendor']
    cpu.sockets = info['topology']['sockets']
    cpu.cores = info['topology']['cores']
    cpu.threads = info['topology']['threads']
    for f in info['features']:
        cpu.add_feature(vconfig.LibvirtConfigCPUFeature(f))
    u = 'http://libvirt.org/html/libvirt-libvirt.html#virCPUCompareResult'
    m = _("CPU doesn't have compatibility.\n\n%(ret)s\n\nRefer to %(u)s")
    try:
        ret = self._conn.compareCPU(cpu.to_xml(), 0)
    except libvirt.libvirtError as e:
        with excutils.save_and_reraise_exception():
            ret = unicode(e)
            LOG.error(m, {'ret': ret, 'u': u})
    if (ret <= 0):
        LOG.error(m, {'ret': ret, 'u': u})
        raise exception.InvalidCPUInfo(reason=(m % {'ret': ret, 'u': u}))