cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [2/3] git commit: updated refs/heads/4.5 to ea7fd37
Date Tue, 28 Apr 2015 11:18:38 GMT
Fixed few coverity issues

Signed-off-by: Santhosh Edukulla <santhosh.edukulla@gmail.com>
(cherry picked from commit 0a9742f91462867cc9d5f9321a13a73483fcf149)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/86943da2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/86943da2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/86943da2

Branch: refs/heads/4.5
Commit: 86943da26e0bff316ae91062cdc741ff29bf619e
Parents: db379bf
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Tue Oct 14 16:47:03 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Apr 27 14:43:48 2015 +0200

----------------------------------------------------------------------
 agent/src/com/cloud/agent/Agent.java            |  4 +--
 .../com/cloud/vm/VirtualMachineManagerImpl.java |  4 ++-
 .../allocator/AbstractStoragePoolAllocator.java | 30 +++++++++-----------
 .../framework/rpc/RpcServerCallImpl.java        |  2 +-
 .../kvm/resource/LibvirtComputingResource.java  |  2 +-
 .../src/com/cloud/ovm/object/Connection.java    |  4 +--
 .../vmware/resource/VmwareResource.java         | 25 +++++++---------
 .../resource/VmwareStorageProcessor.java        |  6 ++--
 .../xenserver/resource/CitrixResourceBase.java  |  2 +-
 .../impl/UserConcentratedAllocator.java         |  2 +-
 .../cloud/ha/HighAvailabilityManagerImpl.java   |  2 +-
 .../hypervisor/vmware/util/VmwareHelper.java    |  2 +-
 12 files changed, 40 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/agent/src/com/cloud/agent/Agent.java
----------------------------------------------------------------------
diff --git a/agent/src/com/cloud/agent/Agent.java b/agent/src/com/cloud/agent/Agent.java
index 7d5f7b1..ac2d9ba 100755
--- a/agent/src/com/cloud/agent/Agent.java
+++ b/agent/src/com/cloud/agent/Agent.java
@@ -426,7 +426,7 @@ public class Agent implements HandlerFactory, IAgentControl {
         s_logger.info("Proccess agent startup answer, agent id = " + startup.getHostId());
 
         setId(startup.getHostId());
-        _pingInterval = startup.getPingInterval() * 1000; // change to ms.
+        _pingInterval = (long)startup.getPingInterval() * 1000; // change to ms.
 
         setLastPingResponseTime();
         scheduleWatch(link, response, _pingInterval, _pingInterval);
@@ -461,7 +461,7 @@ public class Agent implements HandlerFactory, IAgentControl {
 
                     if (cmd instanceof CronCommand) {
                         final CronCommand watch = (CronCommand)cmd;
-                        scheduleWatch(link, request, watch.getInterval() * 1000, watch.getInterval()
* 1000);
+                        scheduleWatch(link, request, (long)watch.getInterval() * 1000, watch.getInterval()
* 1000);
                         answer = new Answer(cmd, true, null);
                     } else if (cmd instanceof ShutdownCommand) {
                         ShutdownCommand shutdown = (ShutdownCommand)cmd;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 387abda..3cf8c2d 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -435,7 +435,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
     }
 
     private VirtualMachineGuru getVmGuru(VirtualMachine vm) {
-        return _vmGurus.get(vm.getType());
+        if(vm != null)
+            return _vmGurus.get(vm.getType());
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
b/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
index 71360ee..1bb85c1 100755
--- a/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java
@@ -76,24 +76,20 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase
implement
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
         super.configure(name, params);
-
-        Map<String, String> configs = _configDao.getConfiguration(null, params);
-
-        String globalStorageOverprovisioningFactor = configs.get("storage.overprovisioning.factor");
-        _storageOverprovisioningFactor = new BigDecimal(NumbersUtil.parseFloat(globalStorageOverprovisioningFactor,
2.0f));
-
-        _extraBytesPerVolume = 0;
-
-        _rand = new Random(System.currentTimeMillis());
-
-        _dontMatter = Boolean.parseBoolean(configs.get("storage.overwrite.provisioning"));
-
-        String allocationAlgorithm = configs.get("vm.allocation.algorithm");
-        if (allocationAlgorithm != null) {
-            _allocationAlgorithm = allocationAlgorithm;
+        if(_configDao != null) {
+            Map<String, String> configs = _configDao.getConfiguration(null, params);
+            String globalStorageOverprovisioningFactor = configs.get("storage.overprovisioning.factor");
+            _storageOverprovisioningFactor = new BigDecimal(NumbersUtil.parseFloat(globalStorageOverprovisioningFactor,
2.0f));
+            _extraBytesPerVolume = 0;
+            _rand = new Random(System.currentTimeMillis());
+            _dontMatter = Boolean.parseBoolean(configs.get("storage.overwrite.provisioning"));
+            String allocationAlgorithm = configs.get("vm.allocation.algorithm");
+            if (allocationAlgorithm != null) {
+                _allocationAlgorithm = allocationAlgorithm;
+            }
+            return true;
         }
-
-        return true;
+        return false;
     }
 
     protected abstract List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile
vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcServerCallImpl.java
----------------------------------------------------------------------
diff --git a/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcServerCallImpl.java
b/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcServerCallImpl.java
index 40995da..4d04ec3 100644
--- a/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcServerCallImpl.java
+++ b/framework/ipc/src/org/apache/cloudstack/framework/rpc/RpcServerCallImpl.java
@@ -64,6 +64,6 @@ public class RpcServerCallImpl implements RpcServerCall {
             pdu.setSerializedResult(_rpcProvider.getMessageSerializer().serializeTo(returnObject.getClass(),
returnObject));
         }
 
-        _rpcProvider.sendRpcPdu(_targetAddress, _sourceAddress, _rpcProvider.getMessageSerializer().serializeTo(RpcCallResponsePdu.class,
pdu));
+        _rpcProvider.sendRpcPdu(_sourceAddress,_targetAddress,_rpcProvider.getMessageSerializer().serializeTo(RpcCallResponsePdu.class,
pdu));
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 294891e..974e3b2 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -964,7 +964,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
Serv
 
         String unameKernelVersion = Script.runSimpleBashScript("uname -r");
         String[] kernelVersions = unameKernelVersion.split("[\\.\\-]");
-        _kernelVersion = Integer.parseInt(kernelVersions[0]) * 1000 * 1000 + Integer.parseInt(kernelVersions[1])
* 1000 + Integer.parseInt(kernelVersions[2]);
+        _kernelVersion = Integer.parseInt(kernelVersions[0]) * 1000 * 1000 + (long)Integer.parseInt(kernelVersions[1])
* 1000 + Integer.parseInt(kernelVersions[2]);
 
         getOsVersion();
         return true;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Connection.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Connection.java b/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Connection.java
index 495c28d..8d2edac 100755
--- a/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Connection.java
+++ b/plugins/hypervisors/ovm/src/com/cloud/ovm/object/Connection.java
@@ -108,8 +108,8 @@ public class Connection {
             throw new XmlRpcException(-2, e.getMessage());
         } finally {
             long endTime = System.currentTimeMillis();
-            float during = (endTime - startTime) / 1000; // in secs
-            s_logger.debug("Ovm call " + method + " finished in " + during + " secs");
+            long during = (endTime - startTime) / 1000; // in secs
+            s_logger.debug("Ovm call " + method + " finished in " + String.valueOf(during)
+ " secs");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index f992b70..9f90901 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -2228,21 +2228,18 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
             }
 
             VolumeObjectTO volInSpec = getVolumeInSpec(vmSpec, volumeTO);
-
-            if (managed) {
-                String datastoreVolumePath = diskChain[0];
-
-                iqnToPath.put(details.get(DiskTO.IQN), datastoreVolumePath);
-
-                vol.setPath(datastoreVolumePath);
-                volumeTO.setPath(datastoreVolumePath);
-                volInSpec.setPath(datastoreVolumePath);
-            }
-            else {
-                volInSpec.setPath(file.getFileBaseName());
+            if (volInSpec != null) {
+                if (managed) {
+                    String datastoreVolumePath = diskChain[0];
+                    iqnToPath.put(details.get(DiskTO.IQN), datastoreVolumePath);
+                    vol.setPath(datastoreVolumePath);
+                    volumeTO.setPath(datastoreVolumePath);
+                    volInSpec.setPath(datastoreVolumePath);
+                } else {
+                    volInSpec.setPath(file.getFileBaseName());
+                }
+                volInSpec.setChainInfo(_gson.toJson(diskInfo));
             }
-
-            volInSpec.setChainInfo(_gson.toJson(diskInfo));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index 60cd682..0ab97c0 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -562,7 +562,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
                 }
             }
 
-            Pair<String, String> result = copyVolumeFromSecStorage(hyperHost, srcVolume.getPath(),
new DatastoreMO(context, morDatastore), srcStore.getUrl(), cmd.getWait() * 1000);
+            Pair<String, String> result = copyVolumeFromSecStorage(hyperHost, srcVolume.getPath(),
new DatastoreMO(context, morDatastore), srcStore.getUrl(), (long)cmd.getWait() * 1000);
             deleteVolumeDirOnSecondaryStorage(result.first(), srcStore.getUrl());
             VolumeObjectTO newVolume = new VolumeObjectTO();
             newVolume.setPath(result.second());
@@ -1013,7 +1013,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
             }
 
             NfsTO nfsSvr = (NfsTO)imageStore;
-            Ternary<String, Long, Long> result = createTemplateFromSnapshot(template.getPath(),
uniqeName, nfsSvr.getUrl(), snapshot.getPath(), template.getId(), cmd.getWait() * 1000);
+            Ternary<String, Long, Long> result = createTemplateFromSnapshot(template.getPath(),
uniqeName, nfsSvr.getUrl(), snapshot.getPath(), template.getId(), (long)cmd.getWait() * 1000);
 
             TemplateObjectTO newTemplate = new TemplateObjectTO();
             newTemplate.setPath(result.first());
@@ -2183,7 +2183,7 @@ public class VmwareStorageProcessor implements StorageProcessor {
                 backedUpSnapshotUuid = backedUpSnapshotUuid.replace(".ovf", "");
             }
             DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
-            restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName, secondaryStorageUrl,
backupPath, backedUpSnapshotUuid, cmd.getWait() * 1000);
+            restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName, secondaryStorageUrl,
backupPath, backedUpSnapshotUuid, (long)cmd.getWait() * 1000);
 
             VolumeObjectTO newVol = new VolumeObjectTO();
             newVol.setPath(newVolumeName);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
index f24b214..de11de1 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
@@ -3391,7 +3391,7 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
         try {
             task = vdi.copyAsync(conn, sr);
             // poll every 1 seconds , timeout after 2 hours
-            waitForTask(conn, task, 1000, wait * 1000);
+            waitForTask(conn, task, 1000, (long)wait * 1000);
             checkForSuccess(conn, task);
             VDI dvdi = Types.toVDI(task, conn);
             return dvdi;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
index 946eee6..885032e 100755
--- a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
@@ -120,7 +120,7 @@ public class UserConcentratedAllocator extends AdapterBase implements
PodAllocat
 
                     // test for enough CPU in the pod
                     enoughCapacity =
-                        dataCenterAndPodHasEnoughCapacity(zoneId, podId, (offering.getCpu()
* offering.getSpeed()), Capacity.CAPACITY_TYPE_CPU, hostCandiates);
+                        dataCenterAndPodHasEnoughCapacity(zoneId, podId, ((long)offering.getCpu()
* offering.getSpeed()), Capacity.CAPACITY_TYPE_CPU, hostCandiates);
                     if (!enoughCapacity) {
                         if (s_logger.isDebugEnabled()) {
                             s_logger.debug("Not enough cpu available in zone/pod to allocate
storage for user VM (zone: " + zoneId + ", pod: " + podId + ")");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
index ce6239a..b96247a 100755
--- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
@@ -782,7 +782,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements
HighAvai
         _forceHA = Boolean.parseBoolean(value);
 
         value = params.get("time.to.sleep");
-        _timeToSleep = NumbersUtil.parseInt(value, 60) * 1000;
+        _timeToSleep = (long)NumbersUtil.parseInt(value, 60) * 1000;
 
         value = params.get("max.retries");
         _maxRetries = NumbersUtil.parseInt(value, 5);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86943da2/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
index 7c69210..b2b1090 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
@@ -577,7 +577,7 @@ public class VmwareHelper {
 
         ResourceAllocationInfo cpuInfo = new ResourceAllocationInfo();
         if (limitCpuUse) {
-            cpuInfo.setLimit((long)(cpuSpeedMHz * cpuCount));
+            cpuInfo.setLimit(((long)cpuSpeedMHz * cpuCount));
         } else {
             cpuInfo.setLimit(-1L);
         }


Mime
View raw message