cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yas...@apache.org
Subject [26/50] [abbrv] git commit: updated refs/heads/pvlan to ce299da
Date Mon, 22 Jul 2013 05:37:35 GMT
CLOUDSTACK-2085: DMC enable guest scaling

When dmc is enabled allow cloudstack to scale the VM between dynamic
ranges. This requires a further commit where there is enough memory
available between dynamic-max and static-max for the VM to scale under
memory pressure. See the TODO in Xenserver56FP1Resource.java

Signed-off-by: Prasanna Santhanam <tsp@apache.org>


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

Branch: refs/heads/pvlan
Commit: 8da7ec05f1c7dae0aab827ae0568e120111c6579
Parents: 2778486
Author: Prasanna Santhanam <tsp@apache.org>
Authored: Mon May 20 17:48:07 2013 +0530
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Mon May 20 17:51:49 2013 +0530

----------------------------------------------------------------------
 .../xen/resource/CitrixResourceBase.java        | 11 +++
 .../xen/resource/XcpServerResource.java         |  9 ++-
 .../xen/resource/XenServer56FP1Resource.java    | 71 +++++++++++++-------
 3 files changed, 64 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8da7ec05/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 19444cc..cd49773 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -3523,6 +3523,17 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
         vm.setMemoryLimits(conn, mem_128m, maxMemsize, minMemsize, maxMemsize);
     }
 
+    /**
+     * When Dynamic Memory Control (DMC) is enabled -
+     * xen allows scaling the guest memory while the guest is running
+     *
+     * By default this is disallowed, override the specific xen resource
+     * if this is enabled
+     */
+    protected boolean isDmcEnabled(Connection conn, Host host) throws XenAPIException, XmlRpcException
{
+        return false;
+    }
+
     protected void waitForTask(Connection c, Task task, long pollInterval, long timeout)
throws XenAPIException, XmlRpcException {
         long beginTime = System.currentTimeMillis();
         while (task.getStatus(c) == Types.TaskStatusType.PENDING) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8da7ec05/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java
index bf0a408..67e37d52 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpServerResource.java
@@ -24,6 +24,7 @@ import com.cloud.resource.ServerResource;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.script.Script;
 import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.Host;
 import com.xensource.xenapi.Types.XenAPIException;
 import com.xensource.xenapi.VM;
 import org.apache.log4j.Logger;
@@ -38,7 +39,6 @@ import java.util.List;
 public class XcpServerResource extends CitrixResourceBase {
     private final static Logger s_logger = Logger.getLogger(XcpServerResource.class);
     private static final long mem_32m = 33554432L;
-
     private String version;
 
     public XcpServerResource() {
@@ -148,4 +148,11 @@ public class XcpServerResource extends CitrixResourceBase {
         }
         vm.setMemoryLimits(conn, mem_32m, maxMemsize, minMemsize, maxMemsize);
     }
+
+    @Override
+    protected boolean isDmcEnabled(Connection conn, Host host) {
+        //Dynamic Memory Control (DMC) is a technology provided by Xen Cloud Platform (XCP),
starting from the 0.5 release
+        //For the supported XCPs dmc is default enabled, XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta,
1.6.x;
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8da7ec05/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
index ad412c1..78ad236 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
@@ -47,6 +47,7 @@ import java.util.Set;
 
 @Local(value=ServerResource.class)
 public class XenServer56FP1Resource extends XenServer56Resource {
+    private static final long mem_128m = 134217728L;
     private static final Logger s_logger = Logger.getLogger(XenServer56FP1Resource.class);
     
     public XenServer56FP1Resource() {
@@ -126,41 +127,46 @@ public class XenServer56FP1Resource extends XenServer56Resource {
         assert templates.size() == 1 : "Should only have 1 template but found " + templates.size();
         VM template = templates.iterator().next();
 
-        VM.Record record = template.getRecord(conn);
-        record.affinity = host;
-        record.otherConfig.remove("disks");
-        record.otherConfig.remove("default_template");
-        record.otherConfig.remove("mac_seed");
-        record.isATemplate = false;
-        record.nameLabel = vmSpec.getName();
-        record.actionsAfterCrash = Types.OnCrashBehaviour.DESTROY;
-        record.actionsAfterShutdown = Types.OnNormalExit.DESTROY;
-        record.memoryDynamicMin = vmSpec.getMinRam();
-        record.memoryDynamicMax = vmSpec.getMaxRam();
-        Map<String, String> hostParams = new HashMap<String, String>();
-        hostParams = host.getLicenseParams(conn);
-        if (hostParams.get("restrict_dmc").equalsIgnoreCase("false")) {
-            record.memoryStaticMin = vmSpec.getMinRam();
-            record.memoryStaticMax = vmSpec.getMaxRam();
+        VM.Record vmr = template.getRecord(conn);
+        vmr.affinity = host;
+        vmr.otherConfig.remove("disks");
+        vmr.otherConfig.remove("default_template");
+        vmr.otherConfig.remove("mac_seed");
+        vmr.isATemplate = false;
+        vmr.nameLabel = vmSpec.getName();
+        vmr.actionsAfterCrash = Types.OnCrashBehaviour.DESTROY;
+        vmr.actionsAfterShutdown = Types.OnNormalExit.DESTROY;
+
+        if (isDmcEnabled(conn, host)) {
+            //scaling is allowed
+            vmr.memoryStaticMin = mem_128m; //128MB
+            //TODO: Remove hardcoded 8GB and assign proportionate to ServiceOffering and
mem overcommit ratio
+            vmr.memoryStaticMax = 8589934592L; //8GB
+            vmr.memoryDynamicMin = vmSpec.getMinRam();
+            vmr.memoryDynamicMax = vmSpec.getMaxRam();
         } else {
-            s_logger.warn("Host "+ _host.uuid + " does not support Dynamic Memory Control,
so we cannot scale up the vm");
-            record.memoryStaticMin = 134217728L; //128MB
-            record.memoryStaticMax = 8589934592L; //8GB
+            //scaling disallowed, set static memory target
+            if (s_logger.isDebugEnabled()) {
+                s_logger.warn("Host "+ host.getHostname(conn) +" does not support dynamic
scaling");
+            }
+            vmr.memoryStaticMin = vmSpec.getMinRam();
+            vmr.memoryStaticMax = vmSpec.getMaxRam();
+            vmr.memoryDynamicMin = vmSpec.getMinRam();
+            vmr.memoryDynamicMax = vmSpec.getMaxRam();
         }
 
         if (guestOsTypeName.toLowerCase().contains("windows")) {
-            record.VCPUsMax = (long) vmSpec.getCpus();
+            vmr.VCPUsMax = (long) vmSpec.getCpus();
         } else {
-            record.VCPUsMax = 32L;
+            vmr.VCPUsMax = 32L;
         }
 
-        record.VCPUsAtStartup = (long) vmSpec.getCpus();
-        record.consoles.clear();
+        vmr.VCPUsAtStartup = (long) vmSpec.getCpus();
+        vmr.consoles.clear();
 
-        VM vm = VM.create(conn, record);
-        VM.Record vmr = vm.getRecord(conn);
+        VM vm = VM.create(conn, vmr);
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Created VM " + vmr.uuid + " for " + vmSpec.getName());
+            s_logger.debug("Created VM " + vm.getUuid(conn) + " for " + vmSpec.getName());
         }
 
         Map<String, String> vcpuParams = new HashMap<String, String>();
@@ -227,4 +233,17 @@ public class XenServer56FP1Resource extends XenServer56Resource {
         return vm;
     }
 
+    /**
+     * When Dynamic Memory Control (DMC) is enabled -
+     * xen allows scaling the guest memory while the guest is running
+     *
+     * This is determined by the 'restrict_dmc' option on the host.
+     * When false, scaling is allowed hence DMC is enabled
+     */
+    @Override
+    protected boolean isDmcEnabled(Connection conn, Host host) throws XenAPIException, XmlRpcException
{
+        Map<String, String> hostParams = new HashMap<String, String>();
+        hostParams = host.getLicenseParams(conn);
+        return hostParams.get("restrict_dmc").equalsIgnoreCase("false");
+    }
 }


Mime
View raw message