[libvirt] [RFC PATCH] Behaviour of topology, vcpus and maxcpus

Nikunj Dadhania nikunj.lkml at gmail.com
Tue Mar 25 06:00:48 UTC 2014


I have observed the following with libvirt xml:

<vcpu>6</vcpu>
<cpu>
  <topology sockets='1' cores='4' threads='2'/>
</cpu>

So according to the topology maximum supported is 8 vcpus, while the
libvirt sets that to 6 - specified in <vcpu> tag. Shouldn't libvirt
error this out as the mismatch between the topology definition and the
vcpu count?

There is an upper bound check already in place where if we have maxcpu >
topology-supported cpus, that errors out. For eg.

<vcpu>12</vcpu>
<cpu>
  <topology sockets='1' cores='4' threads='2'/>
</cpu>

The below patch make sures that libvirt does the lower bound check as
well.

Regards
Nikunj


diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f96110b..aa25940 100644
[ 0001-Behaviour-of-topology-vcpus-and-maxcpus.patch: inline patch (as
text/x-diff) ]
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12933,6 +12933,14 @@ virDomainDefParseXML(xmlDocPtr xml,
     goto error;
 }

+        if (def->cpu->sockets &&
+            def->maxvcpus <
+            def->cpu->sockets * def->cpu->cores * def->cpu->threads) {
+            virReportError(VIR_ERR_XML_DETAIL, "%s",
+                           _("CPUs provided is less than topology"));
+            goto error;
+        }
+
 if (def->cpu->cells_cpus > def->maxvcpus) {
     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
    _("Number of CPUs in <numa> exceeds the"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140325/36536e58/attachment-0001.htm>


More information about the libvir-list mailing list