Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ public VirtualMachineTO implement(VirtualMachineProfile 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()));
}
setMaxVCPUs(host, vm, to);
}

to.setBootloader(bt);
Expand All @@ -126,6 +124,23 @@ public VirtualMachineTO implement(VirtualMachineProfile vm) {
return to;
}

private void setMaxVCPUs(HostVO host, VirtualMachineProfile vm, VirtualMachineTO to) {
if (host != null) {
if (host.getCpus() < MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId())) {
String message = String.valueOf(new StringBuilder()
.append("Ignoring global max vCPUs limit (from global setting xen.vm.vcpu.max) on vm ")
.append(vm.getUuid()).append(" and setting VM max vCPU to host pCPU max: ")
.append(host.getCpus())
.append(". Requested number of virtual CPUs exceeds number of host physical CPUs"));
logger.info(message);
to.setVcpuMaxLimit(host.getCpus());
} else {
logger.info("Setting vm: " + vm.getUuid() + " max vCPU limit (from global setting xen.vm.vcpu.max) to: " + MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId()));
to.setVcpuMaxLimit(MaxNumberOfVCPUSPerVM.valueIn(host.getClusterId()));
}
}
}

@Override
public boolean trackVmHostChange() {
return true;
Expand Down
16 changes: 15 additions & 1 deletion test/integration/smoke/test_scale_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from marvin.lib.utils import cleanup_resources
from marvin.lib.base import (Account,
VirtualMachine,
ServiceOffering)
ServiceOffering,
Configurations)
from marvin.lib.common import (get_zone,
get_template,
get_domain)
Expand Down Expand Up @@ -81,6 +82,12 @@ def setUpClass(cls):
cls.services["service_offerings"]["big"]
)

Configurations.update(
cls.apiclient,
name="enable.dynamic.scale.vm",
value="true"
)

# create a virtual machine
cls.virtual_machine = VirtualMachine.create(
cls.apiclient,
Expand All @@ -101,6 +108,13 @@ def tearDownClass(cls):
TestScaleVm,
cls).getClsTestClient().getApiClient()
cleanup_resources(cls.apiclient, cls._cleanup)

Configurations.update(
cls.apiclient,
name="enable.dynamic.scale.vm",
value="false"
)

return

def setUp(self):
Expand Down