[libvirt] [PATCH] cpu: break out when a right cpuCandidate found

Wangyufei (James) james.wangyufei at huawei.com
Thu Feb 13 07:44:20 UTC 2014


>From 8123c5d64f940fa0fb0de32fc5e68035980b6b01 Mon Sep 17 00:00:00 2001
From: WangYufei <james.wangyufei at huawei.com>
Date: Thu, 13 Feb 2014 07:17:11 +0000
Subject: [PATCH] cpu: break out when a right cpuCandidate found

In function x86Decode there's a code segment in while cycle like this:
        if (cpuModel == NULL
            || cpuModel->nfeatures > cpuCandidate->nfeatures) {
            virCPUDefFree(cpuModel);
            cpuModel = cpuCandidate;
            cpuData = candidate->data;
        } else {
            virCPUDefFree(cpuCandidate);
        }
when it finds the right cpuCandidate, it doesn't break out the cycle, but continues
run in it, and cpuModel will never get a new value, it's meaningless. It should
break out when a right cpuCndidate found.

Signed-off-by: WangYufei <james.wangyufei at huawei.com>
---
 src/cpu/cpu_x86.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 56080ef..546b757 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1558,6 +1558,7 @@ x86Decode(virCPUDefPtr cpu,
             virCPUDefFree(cpuModel);
             cpuModel = cpuCandidate;
             cpuData = candidate->data;
+            break;
         } else {
             virCPUDefFree(cpuCandidate);
         }
-- 
1.7.12.4

Best Regards,
-WangYufei






More information about the libvir-list mailing list