mirror of https://github.com/apache/cloudstack.git
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>
This commit is contained in:
parent
2778486c34
commit
8da7ec05f1
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue