[PATCH 5/5] qemu: Fix condition for checking vcpu when pinning vcpus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
---
 src/qemu/qemu_driver.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6132674..9c6b905 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5084,10 +5084,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;
     }

-- 
2.2.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]