CLOUDSTACK-6023: Non windows instances are created on XenServer with a vcpu-max above supported xenserver limits

Changed the VCPU max limit to 16 and provided a cluster level configuration parameter for this max limit named xen.vm.vcpu.max
This commit is contained in:
Harikrishna Patnala 2014-02-07 16:44:11 +05:30 committed by Nitin Mehta
parent f0b861fede
commit 95e41fdf0d
3 changed files with 48 additions and 5 deletions

View File

@ -60,6 +60,7 @@ public class VirtualMachineTO {
DiskTO[] disks;
NicTO[] nics;
Integer vcpuMaxLimit;
public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer speed, long minRam, long maxRam, BootloaderType bootloader, String os, boolean enableHA, boolean limitCpuUse, String vncPassword) {
this.id = id;
@ -263,5 +264,13 @@ public class VirtualMachineTO {
this.uuid = uuid;
}
public Integer getVcpuMaxLimit() {
return vcpuMaxLimit;
}
public void setVcpuMaxLimit(Integer vcpuMaxLimit) {
this.vcpuMaxLimit = vcpuMaxLimit;
}
}

View File

@ -35,19 +35,24 @@ import com.cloud.storage.dao.GuestOSDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
import com.cloud.utils.Pair;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.UserVmDao;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
import org.apache.cloudstack.framework.config.Configurable;
import org.apache.cloudstack.storage.command.CopyCommand;
import org.apache.cloudstack.storage.command.DettachCommand;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.framework.config.ConfigKey;
@Local(value=HypervisorGuru.class)
public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru {
public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru, Configurable{
@Inject GuestOSDao _guestOsDao;
@Inject
EndPointSelector endPointSelector;
@ -59,6 +64,11 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru
PrimaryDataStoreDao _storagePoolDao;
@Inject
VolumeDataFactory _volFactory;
@Inject
UserVmDao _userVmDao;
static final ConfigKey<Integer> MaxNumberOfVCPUSPerVM = new ConfigKey<Integer>("Advanced", Integer.class, "xen.vm.vcpu.max", "16",
"Maximum number of VCPUs that VM can get in XenServer.", true, ConfigKey.Scope.Cluster);
protected XenServerGuru() {
super();
@ -76,6 +86,14 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru
bt = vm.getBootLoaderType();
}
VirtualMachineTO to = toVirtualMachineTO(vm);
UserVmVO userVmVO = _userVmDao.findById(vm.getId());
if (userVmVO != null) {
HostVO host = hostDao.findById(userVmVO.getHostId());
if (host != null) {
to.setVcpuMaxLimit(MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId()));
}
}
to.setBootloader(bt);
// Determine the VM's OS description
@ -151,4 +169,14 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru
}
return new Pair<Boolean, Long>(Boolean.FALSE, new Long(hostId));
}
@Override
public String getConfigComponentName() {
return XenServerGuru.class.getSimpleName();
}
@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {MaxNumberOfVCPUSPerVM};
}
}

View File

@ -1265,6 +1265,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
vmr.nameLabel = vmSpec.getName();
vmr.actionsAfterCrash = Types.OnCrashBehaviour.DESTROY;
vmr.actionsAfterShutdown = Types.OnNormalExit.DESTROY;
vmr.VCPUsMax = (long) vmSpec.getCpus(); // FIX ME: In case of dynamic scaling this VCPU max should be the minumum of
// recommended value for that template and capacity remaining on host
if (isDmcEnabled(conn, host) && vmSpec.isEnableDynamicallyScaleVm()) {
//scaling is allowed
@ -1272,6 +1274,14 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
vmr.memoryStaticMax = getStaticMax(vmSpec.getOs(), vmSpec.getBootloader() == BootloaderType.CD, vmSpec.getMinRam(), vmSpec.getMaxRam());
vmr.memoryDynamicMin = vmSpec.getMinRam();
vmr.memoryDynamicMax = vmSpec.getMaxRam();
if (guestOsTypeName.toLowerCase().contains("windows")) {
vmr.VCPUsMax = (long) vmSpec.getCpus();
} else {
if (vmSpec.getVcpuMaxLimit() != null) {
vmr.VCPUsMax = (long) vmSpec.getVcpuMaxLimit();
}
}
} else {
//scaling disallowed, set static memory target
if (vmSpec.isEnableDynamicallyScaleVm() && !isDmcEnabled(conn, host)) {
@ -1281,12 +1291,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
vmr.memoryStaticMax = vmSpec.getMaxRam();
vmr.memoryDynamicMin = vmSpec.getMinRam();
vmr.memoryDynamicMax = vmSpec.getMaxRam();
}
if (guestOsTypeName.toLowerCase().contains("windows")) {
vmr.VCPUsMax = (long) vmSpec.getCpus();
} else {
vmr.VCPUsMax = 32L;
}
vmr.VCPUsAtStartup = (long) vmSpec.getCpus();