mirror of https://github.com/apache/cloudstack.git
KVM: fix SSVM starting when overprovisioning memory (#7663)
This commit is contained in:
parent
f4a4417e4c
commit
d127d7939d
|
|
@ -2780,10 +2780,15 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ public class LibvirtVMDef {
|
|||
@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));
|
||||
response.append(String.format("<currentMemory>%s</currentMemory>\n", this.currentMemory));
|
||||
|
||||
if (this.memory > this.currentMemory) {
|
||||
|
|
@ -1238,7 +1238,7 @@ public class LibvirtVMDef {
|
|||
@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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -760,7 +760,7 @@ public class LibvirtComputingResourceTest {
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,11 +214,11 @@ public class LibvirtVMDefTest extends TestCase {
|
|||
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
|
||||
|
|
@ -236,7 +236,7 @@ public class LibvirtVMDefTest extends TestCase {
|
|||
"<secret type='passphrase' uuid='" + passphraseUuid + "' />\n" +
|
||||
"</encryption>\n" +
|
||||
"</disk>\n";
|
||||
assertEquals(disk.toString(), expectedXML);
|
||||
assertEquals(expectedXML, disk.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -346,7 +346,7 @@ public class LibvirtVMDefTest extends TestCase {
|
|||
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" +
|
||||
|
|
@ -356,29 +356,29 @@ public class LibvirtVMDefTest extends TestCase {
|
|||
"<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
|
||||
|
|
@ -413,11 +413,11 @@ public class LibvirtVMDefTest extends TestCase {
|
|||
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
|
||||
|
|
@ -441,8 +441,8 @@ public class LibvirtVMDefTest extends TestCase {
|
|||
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
|
||||
|
|
@ -453,6 +453,6 @@ public class LibvirtVMDefTest extends TestCase {
|
|||
"<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>\n" +
|
||||
"<driver queues='4'/>\n" +
|
||||
"</controller>\n";
|
||||
assertEquals(str, expected);
|
||||
assertEquals(expected, str);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||
Integer maxHostCpuCore = max.second();
|
||||
|
||||
long minMemory = virtualMachineTo.getMinRam();
|
||||
Long maxMemory = minMemory;
|
||||
Long maxMemory = virtualMachineTo.getMaxRam();
|
||||
int minCpuCores = virtualMachineTo.getCpus();
|
||||
Integer maxCpuCores = minCpuCores;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue