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

[libvirt] [PATCH] qemu: Fix emulator affinity



Commit ba63d8f7d843461f77a8206c1ef9da38388713e5 introduced a bug that
makes machines, that don't have either cpuset in <vcpu> or
<emulatorpin> specified, fail.  Because the function that sets
affinity is called without any check, the function must not fail
unless there is an error.
---
 src/qemu/qemu_process.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index e08ec67..b97aaef 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2029,22 +2029,24 @@ static int
 qemuProcessSetEmulatorAffinites(virConnectPtr conn,
                                 virDomainObjPtr vm)
 {
-    virBitmapPtr cpumask;
+    virBitmapPtr cpumask = NULL;
     virDomainDefPtr def = vm->def;
     virNodeInfo nodeinfo;
     int ret = -1;

-    if (virNodeGetInfo(conn, &nodeinfo) != 0)
-        return -1;
+    if (virNodeGetInfo(conn, &nodeinfo) < 0)
+        goto cleanup;

     if (def->cputune.emulatorpin)
         cpumask = def->cputune.emulatorpin->cpumask;
     else if (def->cpumask)
         cpumask = def->cpumask;
+
+    if (cpumask)
+        ret = virProcessInfoSetAffinity(vm->pid, cpumask);
     else
-        goto cleanup;
+        ret = 0;

-    ret = virProcessInfoSetAffinity(vm->pid, cpumask);
 cleanup:
     return ret;
 }
-- 
1.7.12.3


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