You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2017/03/13 16:49:34 UTC
[1/2] git commit: updated refs/heads/master to 3f0fbf2
Repository: cloudstack
Updated Branches:
refs/heads/master 9b85cbca4 -> 3f0fbf251
CLOUDSTACK-9794: Unable to attach more than 14 devices to a VM
Updated hardcoded value with max data volumes limit from hypervisor capabilities.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/93f5b6e8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/93f5b6e8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/93f5b6e8
Branch: refs/heads/master
Commit: 93f5b6e8a391ce8b09be484d029c54d48a2b88aa
Parents: 850c07c
Author: Suresh Kumar Anaparti <su...@accelerite.com>
Authored: Sun Feb 19 01:52:30 2017 +0530
Committer: Suresh Kumar Anaparti <su...@accelerite.com>
Committed: Mon Mar 13 16:14:12 2017 +0530
----------------------------------------------------------------------
.../hypervisor/kvm/resource/LibvirtVMDef.java | 31 ++++++++++++++------
.../com/cloud/storage/VolumeApiServiceImpl.java | 28 ++++++++++--------
2 files changed, 38 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93f5b6e8/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
index ec5d6a7..6930945 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
@@ -584,18 +584,36 @@ public class LibvirtVMDef {
/* skip iso label */
private String getDevLabel(int devId, DiskBus bus) {
+ if (devId < 0) {
+ return "";
+ }
+
if (devId == 2) {
devId++;
}
- char suffix = (char)('a' + devId);
if (bus == DiskBus.SCSI) {
- return "sd" + suffix;
+ return "sd" + getDevLabelSuffix(devId);
} else if (bus == DiskBus.VIRTIO) {
- return "vd" + suffix;
+ return "vd" + getDevLabelSuffix(devId);
+ }
+ return "hd" + getDevLabelSuffix(devId);
+ }
+
+ private String getDevLabelSuffix(int deviceIndex) {
+ if (deviceIndex < 0) {
+ return "";
}
- return "hd" + suffix;
+ int base = 'z' - 'a' + 1;
+ String labelSuffix = "";
+ do {
+ char suffix = (char)('a' + (deviceIndex % base));
+ labelSuffix = suffix + labelSuffix;
+ deviceIndex = (deviceIndex / base) - 1;
+ } while (deviceIndex >= 0);
+
+ return labelSuffix;
}
public void defFileBasedDisk(String filePath, int devId, DiskBus bus, DiskFmtType diskFmtType) {
@@ -716,11 +734,6 @@ public class LibvirtVMDef {
return _diskFmtType;
}
- public int getDiskSeq() {
- char suffix = _diskLabel.charAt(_diskLabel.length() - 1);
- return suffix - 'a';
- }
-
public void setBytesReadRate(Long bytesReadRate) {
_bytesReadRate = bytesReadRate;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93f5b6e8/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index a5bd85e..c073d5f 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1433,9 +1433,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
// that supported by hypervisor
if (deviceId == null || deviceId.longValue() != 0) {
List<VolumeVO> existingDataVolumes = _volsDao.findByInstanceAndType(vmId, Volume.Type.DATADISK);
- int maxDataVolumesSupported = getMaxDataVolumesSupported(vm);
- if (existingDataVolumes.size() >= maxDataVolumesSupported) {
- throw new InvalidParameterValueException("The specified VM already has the maximum number of data disks (" + maxDataVolumesSupported + "). Please specify another VM.");
+ int maxAttachableDataVolumesSupported = getMaxDataVolumesSupported(vm) - 2; //IDs: 0 (ROOT) and 3 (CD-ROM) are reserved
+ if (existingDataVolumes.size() >= maxAttachableDataVolumesSupported) {
+ throw new InvalidParameterValueException("The specified VM already has the maximum number of data disks (" + maxAttachableDataVolumesSupported + ") attached. Please specify another VM.");
}
}
@@ -2527,7 +2527,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
DataTO volTO = volFactory.getVolume(volumeToAttach.getId()).getTO();
- deviceId = getDeviceId(vm.getId(), deviceId);
+ deviceId = getDeviceId(vm, deviceId);
DiskTO disk = storageMgr.getDiskWithThrottling(volTO, volumeToAttach.getVolumeType(), deviceId, volumeToAttach.getPath(),
vm.getServiceOfferingId(), volumeToAttach.getDiskOfferingId());
@@ -2585,7 +2585,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
_volsDao.update(volumeToAttach.getId(), volumeToAttach);
}
} else {
- deviceId = getDeviceId(vm.getId(), deviceId);
+ deviceId = getDeviceId(vm, deviceId);
_volsDao.attachVolume(volumeToAttach.getId(), vm.getId(), deviceId);
}
@@ -2623,7 +2623,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
_hostDao.loadDetails(host);
maxDataVolumesSupported = _hypervisorCapabilitiesDao.getMaxDataVolumesLimit(host.getHypervisorType(), host.getDetail("product_version"));
}
- if (maxDataVolumesSupported == null) {
+ if (maxDataVolumesSupported == null || maxDataVolumesSupported.intValue() <= 0) {
maxDataVolumesSupported = 6; // 6 data disks by default if nothing
// is specified in
// 'hypervisor_capabilities' table
@@ -2632,28 +2632,32 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
return maxDataVolumesSupported.intValue();
}
- private Long getDeviceId(long vmId, Long deviceId) {
+ private Long getDeviceId(UserVmVO vm, Long deviceId) {
// allocate deviceId
- List<VolumeVO> vols = _volsDao.findByInstance(vmId);
+ int maxDeviceId = getMaxDataVolumesSupported(vm) - 1;
+ List<VolumeVO> vols = _volsDao.findByInstance(vm.getId());
if (deviceId != null) {
- if (deviceId.longValue() > 15 || deviceId.longValue() == 3) {
- throw new RuntimeException("deviceId should be 1,2,4-15");
+ if (deviceId.longValue() <= 0 || deviceId.longValue() > maxDeviceId || deviceId.longValue() == 3) {
+ throw new RuntimeException("deviceId should be 1,2,4-" + maxDeviceId);
}
for (VolumeVO vol : vols) {
if (vol.getDeviceId().equals(deviceId)) {
- throw new RuntimeException("deviceId " + deviceId + " is used by vm" + vmId);
+ throw new RuntimeException("deviceId " + deviceId + " is used by vm " + vm.getId());
}
}
} else {
// allocate deviceId here
List<String> devIds = new ArrayList<String>();
- for (int i = 1; i < 15; i++) {
+ for (int i = 1; i <= maxDeviceId; i++) {
devIds.add(String.valueOf(i));
}
devIds.remove("3");
for (VolumeVO vol : vols) {
devIds.remove(vol.getDeviceId().toString().trim());
}
+ if (devIds.isEmpty()) {
+ throw new RuntimeException("All device Ids are used by vm " + vm.getId());
+ }
deviceId = Long.parseLong(devIds.iterator().next());
}
[2/2] git commit: updated refs/heads/master to 3f0fbf2
Posted by ra...@apache.org.
Merge pull request #1953 from Accelerite/CLOUDSTACK-9794
CLOUDSTACK-9794: Unable to attach more than 14 devices to a VMUpdated hardcoded value with max data volumes limit from hypervisor capabilities.
* pr/1953:
CLOUDSTACK-9794: Unable to attach more than 14 devices to a VM
Signed-off-by: Rajani Karuturi <ra...@accelerite.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3f0fbf25
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3f0fbf25
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3f0fbf25
Branch: refs/heads/master
Commit: 3f0fbf251c6bea5829b524077c342ea810b52323
Parents: 9b85cbc 93f5b6e
Author: Rajani Karuturi <ra...@accelerite.com>
Authored: Mon Mar 13 22:19:04 2017 +0530
Committer: Rajani Karuturi <ra...@accelerite.com>
Committed: Mon Mar 13 22:19:04 2017 +0530
----------------------------------------------------------------------
.../hypervisor/kvm/resource/LibvirtVMDef.java | 31 ++++++++++++++------
.../com/cloud/storage/VolumeApiServiceImpl.java | 28 ++++++++++--------
2 files changed, 38 insertions(+), 21 deletions(-)
----------------------------------------------------------------------