From: Peter Krempa Date: Thu, 22 Oct 2015 09:05:36 +0000 (+0200) Subject: conf: Move vcpu count check into helper X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=80a8ac3c1ef1a4e1bb751d321cac52e4157fa1f1;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git conf: Move vcpu count check into helper --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 181820f02..45347e14b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1315,6 +1315,13 @@ int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus) { + if (vcpus > def->maxvcpus) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("maxvcpus must not be less than current vcpus (%u < %u)"), + vcpus, def->maxvcpus); + return -1; + } + def->vcpus = vcpus; return 0; @@ -14441,13 +14448,6 @@ virDomainVcpuParse(virDomainDefPtr def, if (virDomainDefSetVcpus(def, vcpus) < 0) goto cleanup; - if (maxvcpus < def->vcpus) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("maxvcpus must not be less than current vcpus " - "(%u < %u)"), maxvcpus, def->vcpus); - goto cleanup; - } - tmp = virXPathString("string(./vcpu[1]/@placement)", ctxt); if (tmp) { if ((def->placement_mode =