Skip to content

Commit ffe90c0

Browse files
Harikrishna Patnalanitinmeh
authored andcommitted
CLOUDSTACK-2085: VM weight on xen remain same as before vmscaleup ;because "Add-To-VCPUs-Params-Live.sh" is not getting copied on xs host
Fixed by updating the patch files that has entries to copy scipts on xenserver. Here we added Add-To-VCPUs-Params-Live.sh Added a check on Host params whether host restricts Dynamic memory control(DMC) to able to allow scale up VM. If DMC is not enabled then static max and min are set to SO. Signed Off by - Nitin Mehta <nitin.mehta@citrix.com>
1 parent 9542f10 commit ffe90c0

9 files changed

Lines changed: 27 additions & 8 deletions

File tree

plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,8 @@ protected void scaleVM(Connection conn, VM vm, VirtualMachineTO vmSpec, Host hos
639639
if (vmSpec.getLimitCpuUse()) {
640640
long utilization = 0; // max CPU cap, default is unlimited
641641
utilization = ((long)speed * 100 * vmSpec.getCpus()) / _host.speed ;
642-
vm.addToVCPUsParamsLive(conn, "cap", Long.toString(utilization));
642+
//vm.addToVCPUsParamsLive(conn, "cap", Long.toString(utilization)); currently xenserver doesnot support Xapi to add VCPUs params live.
643+
callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value", Long.toString(utilization), "vmname", vmSpec.getName() );
643644
}
644645
//vm.addToVCPUsParamsLive(conn, "weight", Integer.toString(cpuWeight));
645646
callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "weight", "value", Integer.toString(cpuWeight), "vmname", vmSpec.getName() );
@@ -672,6 +673,11 @@ public ScaleVmAnswer execute(ScaleVmCommand cmd) {
672673
for (VM vm : vms) {
673674
VM.Record vmr = vm.getRecord(conn);
674675
try {
676+
Map<String, String> hostParams = new HashMap<String, String>();
677+
hostParams = host.getLicenseParams(conn);
678+
if (hostParams.get("restrict_dmc").equalsIgnoreCase("true")) {
679+
throw new CloudRuntimeException("Host "+ _host.uuid + " does not support Dynamic Memory Control, so we cannot scale up the vm");
680+
}
675681
scaleVM(conn, vm, vmSpec, host);
676682

677683
} catch (Exception e) {

plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,17 @@ protected VM createVmFromTemplate(Connection conn, VirtualMachineTO vmSpec, Host
139139
record.actionsAfterShutdown = Types.OnNormalExit.DESTROY;
140140
record.memoryDynamicMax = vmSpec.getMaxRam();
141141
record.memoryDynamicMin = vmSpec.getMinRam();
142-
record.memoryStaticMax = 8589934592L; //128GB
143-
record.memoryStaticMin = 134217728L; //128MB
142+
Map<String, String> hostParams = new HashMap<String, String>();
143+
hostParams = host.getLicenseParams(conn);
144+
if (hostParams.get("restrict_dmc").equalsIgnoreCase("false")) {
145+
record.memoryStaticMax = 8589934592L; //8GB
146+
record.memoryStaticMin = 134217728L; //128MB
147+
} else {
148+
s_logger.warn("Host "+ _host.uuid + " does not support Dynamic Memory Control, so we cannot scale up the vm");
149+
record.memoryStaticMax = vmSpec.getMaxRam();
150+
record.memoryStaticMin = vmSpec.getMinRam();
151+
}
152+
144153
if (guestOsTypeName.toLowerCase().contains("windows")) {
145154
record.VCPUsMax = (long) vmSpec.getCpus();
146155
} else {

plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void testScaleVMF1() throws
110110
@Test
111111
public void testScaleVMF2() throws Types.XenAPIException, XmlRpcException {
112112

113-
doReturn(null).when(vm).setMemoryDynamicRangeAsync(conn, 536870912L, 536870912L);
113+
doNothing().when(vm).setMemoryDynamicRange(conn, 536870912L, 536870912L);
114114
doReturn(1).when(vmSpec).getCpus();
115115
doNothing().when(vm).setVCPUsNumberLive(conn, 1L);
116116
doReturn(500).when(vmSpec).getSpeed();
@@ -129,12 +129,12 @@ public void testScaleVMF2() throws Types.XenAPIException, XmlRpcException {
129129
@Test
130130
public void testScaleVMF3() throws Types.XenAPIException, XmlRpcException {
131131

132-
doReturn(null).when(vm).setMemoryDynamicRangeAsync(conn, 536870912L, 536870912L);
132+
doNothing().when(vm).setMemoryDynamicRange(conn, 536870912L, 536870912L);
133133
doReturn(1).when(vmSpec).getCpus();
134134
doNothing().when(vm).setVCPUsNumberLive(conn, 1L);
135135
doReturn(500).when(vmSpec).getSpeed();
136136
doReturn(true).when(vmSpec).getLimitCpuUse();
137-
doNothing().when(vm).addToVCPUsParamsLive(conn, "cap", "100");
137+
doReturn(null).when(_resource).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value", "100", "vmname", "i-2-3-VM");
138138
Map<String, String> args = (Map<String, String>)mock(HashMap.class);
139139
when(host.callPlugin(conn, "vmops", "add_to_VCPUs_params_live", args)).thenReturn("Success");
140140
doReturn(null).when(_resource).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "weight", "value", "253", "vmname", "i-2-3-VM");
@@ -143,6 +143,6 @@ public void testScaleVMF3() throws Types.XenAPIException, XmlRpcException {
143143

144144
verify(vmSpec, times(1)).getLimitCpuUse();
145145
verify(_resource, times(1)).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "weight", "value", "253", "vmname", "i-2-3-VM");
146-
verify(vm, times(1)).addToVCPUsParamsLive(conn, "cap", "100");
146+
verify(_resource, times(1)).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value", "100", "vmname", "i-2-3-VM");
147147
}
148148
}

scripts/vm/hypervisor/xenserver/Add-To-VCPUs-Params-Live.sh renamed to scripts/vm/hypervisor/xenserver/add_to_vcpus_params_live.sh

File renamed without changes.

scripts/vm/hypervisor/xenserver/vmops

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def add_to_VCPUs_params_live(session, args):
4848
value = args['value']
4949
vmname = args['vmname']
5050
try:
51-
cmd = ["bash", "/opt/xensource/bin/Add-To-VCPUs-Params-Live.sh", vmname, key, value]
51+
cmd = ["bash", "/opt/xensource/bin/add_to_vcpus_params_live.sh", vmname, key, value]
5252
txt = util.pread2(cmd)
5353
except:
5454
return 'false'

scripts/vm/hypervisor/xenserver/xcpserver/patch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin
6464
getRouterStatus.sh=../../../../network/domr/,0755,/opt/xensource/bin
6565
bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
6666
getDomRVersion.sh=../../../../network/domr/,0755,/opt/xensource/bin
67+
add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin

scripts/vm/hypervisor/xenserver/xenserver56/patch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
6565
swift=..,0755,/opt/xensource/bin
6666
swiftxen=..,0755,/etc/xapi.d/plugins
6767
s3xen=..,0755,/etc/xapi.d/plugins
68+
add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin
6869

scripts/vm/hypervisor/xenserver/xenserver56fp1/patch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,5 @@ bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
6464
swift=..,0755,/opt/xensource/bin
6565
swiftxen=..,0755,/etc/xapi.d/plugins
6666
s3xen=..,0755,/etc/xapi.d/plugins
67+
add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin
6768

scripts/vm/hypervisor/xenserver/xenserver60/patch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin
6969
swift=..,0755,/opt/xensource/bin
7070
swiftxen=..,0755,/etc/xapi.d/plugins
7171
s3xen=..,0755,/etc/xapi.d/plugins
72+
add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin
7273

0 commit comments

Comments
 (0)