cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [07/10] git commit: updated refs/heads/ui-restyle to fbb0499
Date Thu, 03 Oct 2013 19:48:00 GMT
CLOUDSTACK-4790: Skip reserved VMware scsi device number for SCSI disks


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

Branch: refs/heads/ui-restyle
Commit: a3babdd61ca8cae668a1b13c2724a0a6dd13fa05
Parents: 765f56a
Author: Kelven Yang <kelveny@gmail.com>
Authored: Wed Oct 2 17:52:39 2013 -0700
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Wed Oct 2 17:53:56 2013 -0700

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java         |  3 +-
 .../hypervisor/vmware/mo/VirtualMachineMO.java  | 15 +++++--
 .../hypervisor/vmware/util/VmwareHelper.java    | 44 ++++++++++++++------
 3 files changed, 45 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3babdd6/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 fd56cc1..83dcc58 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
@@ -2827,7 +2827,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
                 String[] diskChain = syncDiskChain(dcMo, vmMo, vmSpec, 
                     	vol, matchingExistingDisk,
                     	dataStoresDetails);
-                
+                if(controllerKey == scsiControllerKey && VmwareHelper.isReservedScsiDeviceNumber(scsiUnitNumber))
+                	scsiUnitNumber++;
                 device = VmwareHelper.prepareDiskDevice(vmMo, null, controllerKey, 
                 	diskChain, 
                 	volumeDsDetails.first(),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3babdd6/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 3cd4463..56f2f38 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -908,8 +908,9 @@ public class VirtualMachineMO extends BaseMO {
 		assert(vmdkDatastorePath != null);
 		assert(morDs != null);
 
+		int ideControllerKey = getIDEDeviceControllerKey();
 		if(controllerKey < 0) {
-            controllerKey = getIDEDeviceControllerKey();
+            controllerKey = ideControllerKey;
         }
 
 		VirtualDisk newDisk = new VirtualDisk();
@@ -952,6 +953,8 @@ public class VirtualMachineMO extends BaseMO {
 		}
 
 		int deviceNumber = getNextDeviceNumber(controllerKey);
+		if(controllerKey != ideControllerKey && VmwareHelper.isReservedScsiDeviceNumber(deviceNumber))
+			deviceNumber++;
 
 		newDisk.setControllerKey(controllerKey);
 	    newDisk.setKey(-deviceNumber);
@@ -1714,9 +1717,13 @@ public class VirtualMachineMO extends BaseMO {
 
 	public int getNextScsiDiskDeviceNumber() throws Exception {
 		int scsiControllerKey = getScsiDeviceControllerKey();
-		return getNextDeviceNumber(scsiControllerKey);
+		int deviceNumber = getNextDeviceNumber(scsiControllerKey);
+		if(VmwareHelper.isReservedScsiDeviceNumber(deviceNumber))
+			deviceNumber++;
+		
+		return deviceNumber;
 	}
-
+	
 	public int getScsiDeviceControllerKey() throws Exception {
 	    List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().
 	    	getDynamicProperty(_mor, "config.hardware.device");
@@ -1732,7 +1739,7 @@ public class VirtualMachineMO extends BaseMO {
 	    assert(false);
 	    throw new Exception("SCSI Controller Not Found");
 	}
-
+	
 	public int getScsiDeviceControllerKeyNoException() throws Exception {
 	    List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().
 	    	getDynamicProperty(_mor, "config.hardware.device");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3babdd6/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 bcf9f14..1927b9f 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
@@ -72,6 +72,10 @@ import com.cloud.utils.exception.ExceptionUtil;
 
 public class VmwareHelper {
     private static final Logger s_logger = Logger.getLogger(VmwareHelper.class);
+    
+	public static boolean isReservedScsiDeviceNumber(int deviceNumber) {
+		return deviceNumber == 7;
+	}
 
 	public static VirtualDevice prepareNicDevice(VirtualMachineMO vmMo, ManagedObjectReference
morNetwork, VirtualEthernetCardType deviceType,
 		String portGroupName, String macAddress, int deviceNumber, int contextNumber, boolean conntected,
boolean connectOnStart) throws Exception {
@@ -178,11 +182,15 @@ public class VmwareHelper {
         backingInfo.setFileName(vmdkDatastorePath);
         disk.setBacking(backingInfo);
 
+        int ideControllerKey = vmMo.getIDEDeviceControllerKey();
 		if(controllerKey < 0)
-			controllerKey = vmMo.getIDEDeviceControllerKey();
-        if(deviceNumber < 0)
+			controllerKey = ideControllerKey;
+        if(deviceNumber < 0) {
         	deviceNumber = vmMo.getNextDeviceNumber(controllerKey);
-		disk.setControllerKey(controllerKey);
+        	if(controllerKey != ideControllerKey && isReservedScsiDeviceNumber(deviceNumber))
+        		deviceNumber++;
+        }
+        disk.setControllerKey(controllerKey);
 
 	    disk.setKey(-contextNumber);
 	    disk.setUnitNumber(deviceNumber);
@@ -246,12 +254,16 @@ public class VmwareHelper {
 			throw new Exception("Unsupported disk backing: " + parentBacking.getClass().getCanonicalName());
 		}
 
+		int ideControllerKey = vmMo.getIDEDeviceControllerKey();
 		if(controllerKey < 0)
-			controllerKey = vmMo.getIDEDeviceControllerKey();
+			controllerKey = ideControllerKey;
 		disk.setControllerKey(controllerKey);
-		if(deviceNumber < 0)
+		if(deviceNumber < 0) {
 			deviceNumber = vmMo.getNextDeviceNumber(controllerKey);
-
+			if(controllerKey != ideControllerKey && isReservedScsiDeviceNumber(deviceNumber))
+				deviceNumber++;
+		}
+		
 	    disk.setKey(-contextNumber);
 	    disk.setUnitNumber(deviceNumber);
 	    disk.setCapacityInKB(sizeInMb*1024);
@@ -282,11 +294,15 @@ public class VmwareHelper {
 	        backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.value());
 			disk.setBacking(backingInfo);
 			
+			int ideControllerKey = vmMo.getIDEDeviceControllerKey();
 			if(controllerKey < 0)
-				controllerKey = vmMo.getIDEDeviceControllerKey();
-	        if(deviceNumber < 0)
+				controllerKey = ideControllerKey;
+	        if(deviceNumber < 0) {
 	        	deviceNumber = vmMo.getNextDeviceNumber(controllerKey);
-
+	        	if(controllerKey != ideControllerKey && isReservedScsiDeviceNumber(deviceNumber))
+	        		deviceNumber++;
+	        }
+	        
 			disk.setControllerKey(controllerKey);
 		    disk.setKey(-contextNumber);
 		    disk.setUnitNumber(deviceNumber);
@@ -332,11 +348,15 @@ public class VmwareHelper {
 
         disk.setBacking(backingInfo);
 
+        int ideControllerKey = vmMo.getIDEDeviceControllerKey();
 		if(controllerKey < 0)
-			controllerKey = vmMo.getIDEDeviceControllerKey();
-        if(deviceNumber < 0)
+			controllerKey = ideControllerKey;
+        if(deviceNumber < 0) {
         	deviceNumber = vmMo.getNextDeviceNumber(controllerKey);
-
+        	if(controllerKey != ideControllerKey && isReservedScsiDeviceNumber(deviceNumber))
+        		deviceNumber++;
+        }
+        
 		disk.setControllerKey(controllerKey);
 	    disk.setKey(-contextNumber);
 	    disk.setUnitNumber(deviceNumber);


Mime
View raw message