Oved Ourfali has uploaded a new change for review.

Change subject: core: fix possible null dereference in CpuLevelFilterPolicyUnit
......................................................................

core: fix possible null dereference in CpuLevelFilterPolicyUnit

Change-Id: I01e9196fd4d48dffe5ee136c0137f16a0cd77094
Signed-off-by: Oved Ourfali <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java
1 file changed, 15 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/19780/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java
index b01de0d..68cf380 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/CpuLevelFilterPolicyUnit.java
@@ -24,19 +24,21 @@
             List<VDS> hostsToRunOn = new ArrayList<VDS>();
             for (VDS host : hosts) {
                 String hostCpuName = 
CpuFlagsManagerHandler.FindMaxServerCpuByFlags(host.getCpuFlags(), 
host.getVdsGroupCompatibilityVersion()).getCpuName();
-                int compareResult = 
CpuFlagsManagerHandler.compareCpuLevels(vm.getCpuName(), hostCpuName, 
vm.getVdsGroupCompatibilityVersion());
-                if (compareResult <= 0) {
-                    hostsToRunOn.add(host);
-                    log.debugFormat("Host {0} wasn't filtered out as it has a 
CPU level ({1}) which is higher or equal than the CPU level the VM was run with 
({2})",
-                            host.getName(),
-                            hostCpuName,
-                            vm.getCpuName());
-                } else {
-                    log.debugFormat("Host {0} was filtered out as it has a CPU 
level ({1}) which is lower than the CPU level the VM was run with ({2})",
-                            host.getName(),
-                            hostCpuName,
-                            vm.getCpuName());
-                    filteredOutHosts = true;
+                if (StringUtils.isNotEmpty(hostCpuName)) {
+                    int compareResult = 
CpuFlagsManagerHandler.compareCpuLevels(vm.getCpuName(), hostCpuName, 
vm.getVdsGroupCompatibilityVersion());
+                    if (compareResult <= 0) {
+                        hostsToRunOn.add(host);
+                        log.debugFormat("Host {0} wasn't filtered out as it 
has a CPU level ({1}) which is higher or equal than the CPU level the VM was 
run with ({2})",
+                                host.getName(),
+                                hostCpuName,
+                                vm.getCpuName());
+                    } else {
+                        log.debugFormat("Host {0} was filtered out as it has a 
CPU level ({1}) which is lower than the CPU level the VM was run with ({2})",
+                                host.getName(),
+                                hostCpuName,
+                                vm.getCpuName());
+                        filteredOutHosts = true;
+                    }
                 }
             }
 


-- 
To view, visit http://gerrit.ovirt.org/19780
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I01e9196fd4d48dffe5ee136c0137f16a0cd77094
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Oved Ourfali <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to