Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 3 additions & 2 deletions agent/conf/agent.properties
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ hypervisor.type=kvm
#guest.cpu.features=

# Disables memory ballooning on VM guests for overcommit.
# By default overcommit feature enables balloon and sets currentMemory to a minimum value.
#vm.memballoon.disable=false
# By default this feature is disabled, when enabled by setting the value to false
# the overcommit feature enables balloon and sets currentMemory to a minimum value.
#vm.memballoon.disable=true

# The time interval (in seconds) at which the balloon driver will get memory stats updates.
# This is equivalent to Libvirt's --period parameter when using the dommemstat command.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,11 @@ public class AgentProperties{

/**
* Disables memory ballooning on VM guests for overcommit.<br>
* By default overcommit feature enables balloon and sets currentMemory to a minimum value.<br>
* By default the setting is disabled; when it's enabled overcommit feature enables balloon and sets currentMemory to a minimum value.<br>
* Data type: Boolean.<br>
* Default value: <code>false</code>
* Default value: <code>true</code>
*/
public static final Property<Boolean> VM_MEMBALLOON_DISABLE = new Property<>("vm.memballoon.disable", false);
public static final Property<Boolean> VM_MEMBALLOON_DISABLE = new Property<>("vm.memballoon.disable", true);

/**
* Set to true to check disk activity on VM's disks before starting a VM.<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2780,15 +2780,10 @@ protected GuestResourceDef createGuestResourceDef(VirtualMachineTO vmTO){

grd.setMemBalloning(!_noMemBalloon);

long maxRam = ByteScaleUtils.bytesToKibibytes(vmTO.getMaxRam());
long currRam = vmTO.getType() == VirtualMachine.Type.User ? getCurrentMemAccordingToMemBallooning(vmTO, maxRam) : maxRam;

if (s_logger.isTraceEnabled()) {
s_logger.trace(String.format("memory values for VM %s are %d/%d",vmTO.getName(),maxRam, currRam));
}
Long maxRam = ByteScaleUtils.bytesToKibibytes(vmTO.getMaxRam());

grd.setMemorySize(maxRam);
grd.setCurrentMem(currRam);
grd.setCurrentMem(getCurrentMemAccordingToMemBallooning(vmTO, maxRam));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realised the maxRam seetting is fixed as in the KVMGuru the correct maxRam is passed now.
cc @DaanHoogland @weizhouapache let's test


int vcpus = vmTO.getCpus();
Integer maxVcpus = vmTO.getVcpuMaxLimit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public void setMemBalloning(boolean memoryBalloning) {
@Override
public String toString() {
StringBuilder response = new StringBuilder();
response.append(String.format("<memory>%s</memory>\n", this.memory));
response.append(String.format("<memory>%s</memory>\n", this.currentMemory));
response.append(String.format("<currentMemory>%s</currentMemory>\n", this.currentMemory));

if (this.memory > this.currentMemory) {
Expand Down Expand Up @@ -1238,7 +1238,7 @@ public String getMemBalloonStatsPeriod() {
@Override
public String toString() {
StringBuilder memBalloonBuilder = new StringBuilder();
memBalloonBuilder.append("<memballoon model='" + memBalloonModel + "' autodeflate='on'>\n");
memBalloonBuilder.append("<memballoon model='" + memBalloonModel + "'>\n");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohityadavcloud does this mean, the blocker issue #7794 is fixed here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly - we need to check/test cc @DaanHoogland

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (StringUtils.isNotBlank(memBalloonStatsPeriod)) {
memBalloonBuilder.append("<stats period='" + memBalloonStatsPeriod +"'/>\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ private void verifyVcpu(VirtualMachineTO to, Document domainDoc) {

private void verifyMemory(VirtualMachineTO to, Document domainDoc, String minRam) {
assertXpath(domainDoc, "/domain/maxMemory/text()", String.valueOf( to.getMaxRam() / 1024 ));
assertXpath(domainDoc, "/domain/currentMemory/text()",minRam);
assertXpath(domainDoc, "/domain/memory/text()",minRam);
assertXpath(domainDoc, "/domain/cpu/numa/cell/@memory", minRam);
assertXpath(domainDoc, "/domain/currentMemory/text()", minRam);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ public void testDiskDef() {
assertEquals(bus, disk.getBusType());
assertEquals(DiskDef.DeviceType.DISK, disk.getDeviceType());

String resultingXml = disk.toString();
String xmlDef = disk.toString();
String expectedXml = "<disk device='disk' type='file'>\n<driver name='qemu' type='" + type.toString() + "' cache='" + cacheMode.toString() + "' />\n" +
"<source file='" + filePath + "'/>\n<target dev='" + diskLabel + "' bus='" + bus.toString() + "'/>\n</disk>\n";

assertEquals(expectedXml, resultingXml);
assertEquals(xmlDef, expectedXml);
Comment thread
yadvr marked this conversation as resolved.
Outdated
}

@Test
Expand All @@ -236,7 +236,7 @@ public void testDiskDefWithEncryption() {
"<secret type='passphrase' uuid='" + passphraseUuid + "' />\n" +
"</encryption>\n" +
"</disk>\n";
assertEquals(expectedXML, disk.toString());
assertEquals(disk.toString(), expectedXML);
Comment thread
yadvr marked this conversation as resolved.
Outdated
}

@Test
Expand Down Expand Up @@ -346,7 +346,7 @@ public void testDiskDefWithBurst() {
LibvirtVMDef.setGlobalQemuVersion(2006000L);
LibvirtVMDef.setGlobalLibvirtVersion(9008L);

String resultingXml = disk.toString();
String xmlDef = disk.toString();
String expectedXml = "<disk device='disk' type='file'>\n<driver name='qemu' type='" + type.toString() + "' cache='none' />\n" +
"<source file='" + filePath + "'/>\n<target dev='" + diskLabel + "' bus='" + bus.toString() + "'/>\n" +
"<iotune>\n<read_bytes_sec>"+bytesReadRate+"</read_bytes_sec>\n<write_bytes_sec>"+bytesWriteRate+"</write_bytes_sec>\n" +
Expand All @@ -356,29 +356,29 @@ public void testDiskDefWithBurst() {
"<read_bytes_sec_max_length>"+bytesReadRateMaxLength+"</read_bytes_sec_max_length>\n<write_bytes_sec_max_length>"+bytesWriteRateMaxLength+"</write_bytes_sec_max_length>\n" +
"<read_iops_sec_max_length>"+iopsReadRateMaxLength+"</read_iops_sec_max_length>\n<write_iops_sec_max_length>"+iopsWriteRateMaxLength+"</write_iops_sec_max_length>\n</iotune>\n</disk>\n";

assertEquals(expectedXml, resultingXml);
assertEquals(xmlDef, expectedXml);
Comment thread
yadvr marked this conversation as resolved.
Outdated
}

@Test
public void memBalloonDefTestNone() {
String expectedXml = "<memballoon model='none' autodeflate='on'>\n</memballoon>";
String expectedXml = "<memballoon model='none'>\n</memballoon>";
MemBalloonDef memBalloonDef = new MemBalloonDef();
memBalloonDef.defNoneMemBalloon();

String resultingXml = memBalloonDef.toString();
String xmlDef = memBalloonDef.toString();

assertEquals(expectedXml, resultingXml);
assertEquals(xmlDef, expectedXml);
Comment thread
yadvr marked this conversation as resolved.
Outdated
}

@Test
public void memBalloonDefTestVirtio() {
String expectedXml = "<memballoon model='virtio' autodeflate='on'>\n<stats period='60'/>\n</memballoon>";
String expectedXml = "<memballoon model='virtio'>\n<stats period='60'/>\n</memballoon>";
MemBalloonDef memBalloonDef = new MemBalloonDef();
memBalloonDef.defVirtioMemBalloon("60");

String resultingXml = memBalloonDef.toString();
String xmlDef = memBalloonDef.toString();

assertEquals(expectedXml, resultingXml);
assertEquals(xmlDef, expectedXml);
Comment thread
yadvr marked this conversation as resolved.
Outdated
}

@Test
Expand Down Expand Up @@ -413,11 +413,11 @@ public void testRngDef() {
int bytes = 2048;

LibvirtVMDef.RngDef def = new LibvirtVMDef.RngDef(path, backendModel, bytes, period);
assertEquals(path, def.getPath());
assertEquals(backendModel, def.getRngBackendModel());
assertEquals(LibvirtVMDef.RngDef.RngModel.VIRTIO, def.getRngModel());
assertEquals(bytes, def.getRngRateBytes());
assertEquals(period, def.getRngRatePeriod());
assertEquals(def.getPath(), path);
assertEquals(def.getRngBackendModel(), backendModel);
assertEquals(def.getRngModel(), LibvirtVMDef.RngDef.RngModel.VIRTIO);
assertEquals(def.getRngRateBytes(), bytes);
assertEquals(def.getRngRatePeriod(), period);
Comment thread
yadvr marked this conversation as resolved.
Outdated
}

@Test
Expand All @@ -441,8 +441,8 @@ public void testWatchDogDef() {
LibvirtVMDef.WatchDogDef.WatchDogAction action = LibvirtVMDef.WatchDogDef.WatchDogAction.RESET;

LibvirtVMDef.WatchDogDef def = new LibvirtVMDef.WatchDogDef(action, model);
assertEquals(model, def.getModel());
assertEquals(action, def.getAction());
assertEquals(def.getModel(), model);
assertEquals(def.getAction(), action);
Comment thread
yadvr marked this conversation as resolved.
Outdated
}

@Test
Expand All @@ -453,6 +453,6 @@ public void testSCSIDef() {
"<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>\n" +
"<driver queues='4'/>\n" +
"</controller>\n";
assertEquals(expected, str);
assertEquals(str, expected);
Comment thread
yadvr marked this conversation as resolved.
Outdated
}
}