Skip to content

Commit ca0d2ef

Browse files
Harikrishna Patnalasudison
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 8842224 commit ca0d2ef

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
@@ -691,7 +691,8 @@ protected void scaleVM(Connection conn, VM vm, VirtualMachineTO vmSpec, Host hos
691691
if (vmSpec.getLimitCpuUse()) {
692692
long utilization = 0; // max CPU cap, default is unlimited
693693
utilization = ((long)speed * 100 * vmSpec.getCpus()) / _host.speed ;
694-
vm.addToVCPUsParamsLive(conn, "cap", Long.toString(utilization));
694+
//vm.addToVCPUsParamsLive(conn, "cap", Long.toString(utilization)); currently xenserver doesnot support Xapi to add VCPUs params live.
695+
callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value", Long.toString(utilization), "vmname", vmSpec.getName() );
695696
}
696697
//vm.addToVCPUsParamsLive(conn, "weight", Integer.toString(cpuWeight));
697698
callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "weight", "value", Integer.toString(cpuWeight), "vmname", vmSpec.getName() );
@@ -724,6 +725,11 @@ public ScaleVmAnswer execute(ScaleVmCommand cmd) {
724725
for (VM vm : vms) {
725726
VM.Record vmr = vm.getRecord(conn);
726727
try {
728+
Map<String, String> hostParams = new HashMap<String, String>();
729+
hostParams = host.getLicenseParams(conn);
730+
if (hostParams.get("restrict_dmc").equalsIgnoreCase("true")) {
731+
throw new CloudRuntimeException("Host "+ _host.uuid + " does not support Dynamic Memory Control, so we cannot scale up the vm");
732+
}
727733
scaleVM(conn, vm, vmSpec, host);
728734

729735
} 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
@@ -142,8 +142,17 @@ protected VM createVmFromTemplate(Connection conn, VirtualMachineTO vmSpec, Host
142142
record.actionsAfterShutdown = Types.OnNormalExit.DESTROY;
143143
record.memoryDynamicMax = vmSpec.getMaxRam();
144144
record.memoryDynamicMin = vmSpec.getMinRam();
145-
record.memoryStaticMax = 8589934592L; //128GB
146-
record.memoryStaticMin = 134217728L; //128MB
145+
Map<String, String> hostParams = new HashMap<String, String>();
146+
hostParams = host.getLicenseParams(conn);
147+
if (hostParams.get("restrict_dmc").equalsIgnoreCase("false")) {
148+
record.memoryStaticMax = 8589934592L; //8GB
149+
record.memoryStaticMin = 134217728L; //128MB
150+
} else {
151+
s_logger.warn("Host "+ _host.uuid + " does not support Dynamic Memory Control, so we cannot scale up the vm");
152+
record.memoryStaticMax = vmSpec.getMaxRam();
153+
record.memoryStaticMin = vmSpec.getMinRam();
154+
}
155+
147156
if (guestOsTypeName.toLowerCase().contains("windows")) {
148157
record.VCPUsMax = (long) vmSpec.getCpus();
149158
} 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)