解决 CPU topology doesn't match maximum vcpu count

来源:互联网 发布:js获取今天年月日 编辑:程序博客网 时间:2024/06/06 06:58


[root@nova08 6447f1bf-db9a-4a97-b281-22c329836018]# virsh define xml
error: Failed to define domain from xml
error: unsupported configuration: CPU topology doesn't match maximum vcpu count


提示CPU topology doesn't match maximum vcpu count , 很奇怪啊,为什么会报这种错,于是去翻代码,根本没有段代码,很奇怪了.

于是google了下, 发现如下代码:



> > +    /* qemu as of 2.5.0 rejects SMP topologies that don't match the cpu count */> > +    if (def->cpu && def->cpu->sockets) {> > +        topologycpus = def->cpu->sockets * def->cpu->cores * def->cpu->threads;> > +        if (topologycpus != virDomainDefGetVcpusMax(def)) {> > +            /* presence of query-hotpluggable-cpus should be a good enough witness */> > +            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS)) {> > +                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",> > +                               _("CPU topology doesn't match maximum vcpu count"));> > +                goto cleanup;> > +            }


从代码可以看出来是topologycpus = def->cpu->sockets * def->cpu->cores * def->cpu->threads;       总的cpu不等于 max cpu。

于是通过代码文件,找到我当前 qemu2.0.0的代码,发现我的代码是这样的:

if (def->cpu->sockets &&            virDomainDefGetVcpusMax(def) >            def->cpu->sockets * def->cpu->cores * def->cpu->threads) {            virReportError(VIR_ERR_XML_DETAIL, "%s",                           _("Maximum CPUs greater than topology limit"));            goto error;        }


这两个代码一样,但是报错的日志不一样。


于是马上 virsh version 查看版本:

[root@nova08 6447f1bf-db9a-4a97-b281-22c329836018]# virsh versionCompiled against library: libvirt 2.0.0Using library: libvirt 2.0.0Using API: QEMU 2.0.0Running hypervisor: QEMU 2.6.0


libvirt是2.0.0的版本。  


这就郁闷了,我本地代码库的tag也是 2.0.0啊。  奇怪了,哪位知道求告诉下原因。


从以上代码可以看出,如果要使用maxcpu就不能有 cpu-sockets的配置,就是不能有:

<cpu>    <topology sockets='2' cores='1' threads='1'/>      不能有这一行  </cpu>


于是去掉 topology sockets,这一行,及解决问题。





阅读全文
0 0