From: Peter Krempa Date: Tue, 7 Apr 2015 18:44:15 +0000 (+0200) Subject: qemu: Fix condition for checking vcpu when pinning vcpus X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=64985217bc57510cb9549200182be3691640e04b;p=libvirt.git qemu: Fix condition for checking vcpu when pinning vcpus Previously we checked that the vcpu we are trying to set is in range of the number of threads presented by qemu. The problem is that if the VM is offline the count is 0. Since the condition subtracted 1 from the count the number would overflow and the check would never trigger. Change the condition for more sensible ones with specific error messages. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1208434 --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cbb6e1b6c1..addd03dab9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5150,10 +5150,17 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, priv = vm->privateData; - if (vcpu > (priv->nvcpupids-1)) { + if ((flags & VIR_DOMAIN_AFFECT_LIVE) && vcpu >= vm->def->vcpus) { virReportError(VIR_ERR_INVALID_ARG, - _("vcpu number out of range %d > %d"), - vcpu, priv->nvcpupids - 1); + _("vcpu %d is out of range of live cpu count %d"), + vcpu, vm->def->vcpus); + goto endjob; + } + + if ((flags & VIR_DOMAIN_AFFECT_CONFIG) && vcpu >= persistentDef->vcpus) { + virReportError(VIR_ERR_INVALID_ARG, + _("vcpu %d is out of range of persistent cpu count %d"), + vcpu, persistentDef->vcpus); goto endjob; }