qemu: setvcpus: Fix maxvcpus check

Doing 'virsh setvcpus $vm --config 10' doesn't check the value against the
domains maxvcpus value. A larger value for example will prevent the guest
from starting.

Also make a similar change to the test driver.
This commit is contained in:
Cole Robinson 2010-11-22 13:55:58 -05:00
parent 81e6f68d0e
commit d75202915e
2 changed files with 4 additions and 4 deletions

View File

@ -6322,8 +6322,7 @@ qemudDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
goto endjob;
}
if ((flags & (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_LIVE)) ==
VIR_DOMAIN_VCPU_LIVE && vm->def->maxvcpus < max) {
if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && vm->def->maxvcpus < max) {
max = vm->def->maxvcpus;
}

View File

@ -2134,9 +2134,10 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
/* We allow more cpus in guest than host, but not more than the
* domain's starting limit. */
if ((flags & (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_LIVE)) ==
VIR_DOMAIN_VCPU_LIVE && privdom->def->maxvcpus < maxvcpus)
if (!(flags & (VIR_DOMAIN_VCPU_MAXIMUM)) &&
privdom->def->maxvcpus < maxvcpus)
maxvcpus = privdom->def->maxvcpus;
if (nrCpus > maxvcpus) {
testError(VIR_ERR_INVALID_ARG,
"requested cpu amount exceeds maximum (%d > %d)",