cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject git commit: updated refs/heads/resize-root to 5eeee5c
Date Tue, 04 Mar 2014 01:42:13 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/resize-root 974fc4e67 -> 5eeee5cf7


rootdisksize: fail earlier when template size is greater than specified rootdisksize


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

Branch: refs/heads/resize-root
Commit: 5eeee5cf739f10ecdf89b739bc70047f303fb72c
Parents: 974fc4e
Author: Marcus Sorensen <marcus@betterservers.com>
Authored: Mon Mar 3 18:42:04 2014 -0700
Committer: Marcus Sorensen <marcus@betterservers.com>
Committed: Mon Mar 3 18:42:04 2014 -0700

----------------------------------------------------------------------
 server/src/com/cloud/vm/UserVmManagerImpl.java | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5eeee5cf/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 72a80a9..48166f3 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -2835,17 +2835,29 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
                     vm.setIsoId(template.getId());
                 }
                 Long rootDiskSize = null;
+                // custom root disk size, resizes base template to larger size
                 if (customParameters.containsKey("rootdisksize")) {
                     if (NumbersUtil.parseLong(customParameters.get("rootdisksize"), -1) <=
0) {
                         throw new InvalidParameterValueException("rootdisk size should be
a non zero number.");
                     }
+                    rootDiskSize = Long.parseLong(customParameters.get("rootdisksize"));
+
                     // only KVM supports rootdisksize override
                     if (hypervisor != HypervisorType.KVM) {
                         throw new InvalidParameterValueException("Hypervisor " + hypervisor
+ " does not support rootdisksize override");
                     }
 
-                    s_logger.debug("found root disk size of " + customParameters.get("rootdisksize"));
-                    rootDiskSize = Long.parseLong(customParameters.get("rootdisksize"));
+                    // rotdisksize must be larger than template
+                    VMTemplateVO templateVO = _templateDao.findById(template.getId());
+                    if (templateVO == null) {
+                        throw new InvalidParameterValueException("Unable to look up template
by id " + template.getId());
+                    }
+
+                    if ((rootDiskSize << 30) < templateVO.getSize()) {
+                        throw new InvalidParameterValueException("unsupported: rootdisksize
override is smaller than template size " + templateVO.getSize());
+                    }
+
+                    s_logger.debug("found root disk size of " + rootDiskSize);
                     customParameters.remove("rootdisksize");
                 }
 


Mime
View raw message