[libvirt] [PATCH 4/6] qemu: setvcpus: Fix maxvcpus check
Daniel P. Berrange
berrange at redhat.com
Tue Nov 23 11:30:24 UTC 2010
On Mon, Nov 22, 2010 at 04:35:32PM -0500, Cole Robinson wrote:
> 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.
>
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
> src/qemu/qemu_driver.c | 3 +--
> src/test/test_driver.c | 5 +++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 18b3f16..058a8f0 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -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;
> }
>
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index 5e737e8..d32568f 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -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)",
> --
ACK
Daniel
More information about the libvir-list
mailing list