Skip to content
Merged
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 @@ -2780,10 +2780,15 @@ protected GuestResourceDef createGuestResourceDef(VirtualMachineTO vmTO){

grd.setMemBalloning(!_noMemBalloon);

Long maxRam = ByteScaleUtils.bytesToKibibytes(vmTO.getMaxRam());
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));
}

grd.setMemorySize(maxRam);
grd.setCurrentMem(getCurrentMemAccordingToMemBallooning(vmTO, maxRam));
grd.setCurrentMem(currRam);

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.currentMemory));
response.append(String.format("<memory>%s</memory>\n", this.memory));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this seems to have no effect in my tests. looking for the answer.

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 + "'>\n");
memBalloonBuilder.append("<memballoon model='" + memBalloonModel + "' autodeflate='on'>\n");
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/memory/text()",minRam);
assertXpath(domainDoc, "/domain/currentMemory/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 xmlDef = disk.toString();
String resultingXml = 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(xmlDef, expectedXml);
assertEquals(expectedXml, resultingXml);
}

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

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

String xmlDef = disk.toString();
String resultingXml = 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(xmlDef, expectedXml);
assertEquals(expectedXml, resultingXml);
}

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

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

assertEquals(xmlDef, expectedXml);
assertEquals(expectedXml, resultingXml);
}

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

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

assertEquals(xmlDef, expectedXml);
assertEquals(expectedXml, resultingXml);
}

@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(def.getPath(), path);
assertEquals(def.getRngBackendModel(), backendModel);
assertEquals(def.getRngModel(), LibvirtVMDef.RngDef.RngModel.VIRTIO);
assertEquals(def.getRngRateBytes(), bytes);
assertEquals(def.getRngRatePeriod(), period);
assertEquals(path, def.getPath());
assertEquals(backendModel, def.getRngBackendModel());
assertEquals(LibvirtVMDef.RngDef.RngModel.VIRTIO, def.getRngModel());
assertEquals(bytes, def.getRngRateBytes());
assertEquals(period, def.getRngRatePeriod());
}

@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(def.getModel(), model);
assertEquals(def.getAction(), action);
assertEquals(model, def.getModel());
assertEquals(action, def.getAction());
}

@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(str, expected);
assertEquals(expected, str);
}
}
2 changes: 1 addition & 1 deletion server/src/main/java/com/cloud/hypervisor/KVMGuru.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ protected void configureVmMemoryAndCpuCores(VirtualMachineTO virtualMachineTo, H
Integer maxHostCpuCore = max.second();

long minMemory = virtualMachineTo.getMinRam();
Long maxMemory = minMemory;
Long maxMemory = virtualMachineTo.getMaxRam();
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.

I think only this fix was enough :)

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.

Closing my PR as this main line/change has been addressed - #7807

int minCpuCores = virtualMachineTo.getCpus();
Integer maxCpuCores = minCpuCores;

Expand Down