Skip to content

Commit d51d8a4

Browse files
committed
Merge release branch 4.18 to main
* 4.18: UI: Filter templates by zone and hypervisor type when reinstall a VM (#7739) KVM: fix SSVM starting when overprovisioning memory (#7663) pom.xml: add property project.systemvm.template.location (#7706) cloudutils: fix adding rocky9 host failure due to missing /etc/sysconfig/libvirtd (#7779) server: get id from persisted object ReservationVO (#7785) search in (too) large result sets (#7766) ui: fix 404 error when list volumes of system vms (#7772) packaging: install tzdata-java on centos7/centos8 (#7768)
2 parents 0bab0db + a2eb103 commit d51d8a4

File tree

14 files changed

+188
-130
lines changed

14 files changed

+188
-130
lines changed

engine/schema/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
<goal>wget</goal>
123123
</goals>
124124
<configuration>
125-
<url>https://download.cloudstack.org/systemvm/${cs.version}/md5sum.txt</url>
125+
<url>${project.systemvm.template.location}/${cs.version}/md5sum.txt</url>
126126
<outputDirectory>${basedir}/dist/systemvm-templates/</outputDirectory>
127127
<skipCache>true</skipCache>
128128
<overwrite>true</overwrite>
@@ -181,7 +181,7 @@
181181
</goals>
182182
<configuration>
183183
<checkSignature>true</checkSignature>
184-
<url>https://download.cloudstack.org/systemvm/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-kvm.qcow2.bz2</url>
184+
<url>${project.systemvm.template.location}/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-kvm.qcow2.bz2</url>
185185
<outputDirectory>${basedir}/dist/systemvm-templates/</outputDirectory>
186186
<md5>${kvm.checksum}</md5>
187187
</configuration>
@@ -217,7 +217,7 @@
217217
</goals>
218218
<configuration>
219219
<checkSignature>true</checkSignature>
220-
<url>https://download.cloudstack.org/systemvm/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-vmware.ova</url>
220+
<url>${project.systemvm.template.location}/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-vmware.ova</url>
221221
<outputDirectory>${basedir}/dist/systemvm-templates/</outputDirectory>
222222
<md5>${vmware.checksum}</md5>
223223
</configuration>
@@ -253,7 +253,7 @@
253253
</goals>
254254
<configuration>
255255
<checkSignature>true</checkSignature>
256-
<url>https://download.cloudstack.org/systemvm/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-xen.vhd.bz2</url>
256+
<url>${project.systemvm.template.location}/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-xen.vhd.bz2</url>
257257
<outputDirectory>${basedir}/dist/systemvm-templates/</outputDirectory>
258258
<md5>${xen.checksum}</md5>
259259
</configuration>
@@ -289,7 +289,7 @@
289289
</goals>
290290
<configuration>
291291
<checkSignature>true</checkSignature>
292-
<url>https://download.cloudstack.org/systemvm/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-ovm.raw.bz2</url>
292+
<url>${project.systemvm.template.location}/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-ovm.raw.bz2</url>
293293
<outputDirectory>${basedir}/dist/systemvm-templates/</outputDirectory>
294294
<md5>${ovm.checksum}</md5>
295295
</configuration>
@@ -325,7 +325,7 @@
325325
</goals>
326326
<configuration>
327327
<checkSignature>true</checkSignature>
328-
<url>https://download.cloudstack.org/systemvm/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-hyperv.vhd.zip</url>
328+
<url>${project.systemvm.template.location}/${cs.version}/systemvmtemplate-${cs.version}.${patch.version}-hyperv.vhd.zip</url>
329329
<outputDirectory>${basedir}/dist/systemvm-templates/</outputDirectory>
330330
<md5>${hyperv.checksum}</md5>
331331
</configuration>

packaging/centos7/cloud.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ intelligent IaaS cloud implementation.
6161
%package management
6262
Summary: CloudStack management server UI
6363
Requires: java-11-openjdk
64+
Requires: tzdata-java
6465
Requires: python
6566
Requires: python3
6667
Requires: bash
@@ -107,6 +108,7 @@ The Apache CloudStack files shared between agent and management server
107108
Summary: CloudStack Agent for KVM hypervisors
108109
Requires: openssh-clients
109110
Requires: java-11-openjdk
111+
Requires: tzdata-java
110112
Requires: %{name}-common = %{_ver}
111113
Requires: libvirt
112114
Requires: bridge-utils
@@ -142,6 +144,7 @@ The CloudStack baremetal agent
142144
%package usage
143145
Summary: CloudStack Usage calculation server
144146
Requires: java-11-openjdk
147+
Requires: tzdata-java
145148
Group: System Environment/Libraries
146149
%description usage
147150
The CloudStack usage calculation service

packaging/centos8/cloud.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ intelligent IaaS cloud implementation.
5353
%package management
5454
Summary: CloudStack management server UI
5555
Requires: java-11-openjdk
56+
Requires: tzdata-java
5657
Requires: python3
5758
Requires: bash
5859
Requires: gawk
@@ -98,6 +99,7 @@ The Apache CloudStack files shared between agent and management server
9899
Summary: CloudStack Agent for KVM hypervisors
99100
Requires: (openssh-clients or openssh)
100101
Requires: java-11-openjdk
102+
Requires: tzdata-java
101103
Requires: %{name}-common = %{_ver}
102104
Requires: libvirt
103105
Requires: ebtables
@@ -134,6 +136,7 @@ The CloudStack baremetal agent
134136
%package usage
135137
Summary: CloudStack Usage calculation server
136138
Requires: java-11-openjdk
139+
Requires: tzdata-java
137140
Group: System Environment/Libraries
138141
%description usage
139142
The CloudStack usage calculation service

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2791,10 +2791,15 @@ protected GuestResourceDef createGuestResourceDef(VirtualMachineTO vmTO){
27912791

27922792
grd.setMemBalloning(!_noMemBalloon);
27932793

2794-
Long maxRam = ByteScaleUtils.bytesToKibibytes(vmTO.getMaxRam());
2794+
long maxRam = ByteScaleUtils.bytesToKibibytes(vmTO.getMaxRam());
2795+
long currRam = vmTO.getType() == VirtualMachine.Type.User ? getCurrentMemAccordingToMemBallooning(vmTO, maxRam) : maxRam;
2796+
2797+
if (s_logger.isTraceEnabled()) {
2798+
s_logger.trace(String.format("memory values for VM %s are %d/%d",vmTO.getName(),maxRam, currRam));
2799+
}
27952800

27962801
grd.setMemorySize(maxRam);
2797-
grd.setCurrentMem(getCurrentMemAccordingToMemBallooning(vmTO, maxRam));
2802+
grd.setCurrentMem(currRam);
27982803

27992804
int vcpus = vmTO.getCpus();
28002805
Integer maxVcpus = vmTO.getVcpuMaxLimit();

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public void setMemBalloning(boolean memoryBalloning) {
282282
@Override
283283
public String toString() {
284284
StringBuilder response = new StringBuilder();
285-
response.append(String.format("<memory>%s</memory>\n", this.currentMemory));
285+
response.append(String.format("<memory>%s</memory>\n", this.memory));
286286
response.append(String.format("<currentMemory>%s</currentMemory>\n", this.currentMemory));
287287

288288
if (this.memory > this.currentMemory) {
@@ -1238,7 +1238,7 @@ public String getMemBalloonStatsPeriod() {
12381238
@Override
12391239
public String toString() {
12401240
StringBuilder memBalloonBuilder = new StringBuilder();
1241-
memBalloonBuilder.append("<memballoon model='" + memBalloonModel + "'>\n");
1241+
memBalloonBuilder.append("<memballoon model='" + memBalloonModel + "' autodeflate='on'>\n");
12421242
if (StringUtils.isNotBlank(memBalloonStatsPeriod)) {
12431243
memBalloonBuilder.append("<stats period='" + memBalloonStatsPeriod +"'/>\n");
12441244
}

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ private void verifyVcpu(VirtualMachineTO to, Document domainDoc) {
760760

761761
private void verifyMemory(VirtualMachineTO to, Document domainDoc, String minRam) {
762762
assertXpath(domainDoc, "/domain/maxMemory/text()", String.valueOf( to.getMaxRam() / 1024 ));
763-
assertXpath(domainDoc, "/domain/memory/text()",minRam);
763+
assertXpath(domainDoc, "/domain/currentMemory/text()",minRam);
764764
assertXpath(domainDoc, "/domain/cpu/numa/cell/@memory", minRam);
765765
assertXpath(domainDoc, "/domain/currentMemory/text()", minRam);
766766
}

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ public void testDiskDef() {
266266
assertEquals(bus, disk.getBusType());
267267
assertEquals(DiskDef.DeviceType.DISK, disk.getDeviceType());
268268

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

273-
assertEquals(xmlDef, expectedXml);
273+
assertEquals(expectedXml, resultingXml);
274274
}
275275

276276
@Test
@@ -288,7 +288,7 @@ public void testDiskDefWithEncryption() {
288288
"<secret type='passphrase' uuid='" + passphraseUuid + "' />\n" +
289289
"</encryption>\n" +
290290
"</disk>\n";
291-
assertEquals(disk.toString(), expectedXML);
291+
assertEquals(expectedXML, disk.toString());
292292
}
293293

294294
@Test
@@ -398,7 +398,7 @@ public void testDiskDefWithBurst() {
398398
LibvirtVMDef.setGlobalQemuVersion(2006000L);
399399
LibvirtVMDef.setGlobalLibvirtVersion(9008L);
400400

401-
String xmlDef = disk.toString();
401+
String resultingXml = disk.toString();
402402
String expectedXml = "<disk device='disk' type='file'>\n<driver name='qemu' type='" + type.toString() + "' cache='none' />\n" +
403403
"<source file='" + filePath + "'/>\n<target dev='" + diskLabel + "' bus='" + bus.toString() + "'/>\n" +
404404
"<iotune>\n<read_bytes_sec>"+bytesReadRate+"</read_bytes_sec>\n<write_bytes_sec>"+bytesWriteRate+"</write_bytes_sec>\n" +
@@ -408,29 +408,29 @@ public void testDiskDefWithBurst() {
408408
"<read_bytes_sec_max_length>"+bytesReadRateMaxLength+"</read_bytes_sec_max_length>\n<write_bytes_sec_max_length>"+bytesWriteRateMaxLength+"</write_bytes_sec_max_length>\n" +
409409
"<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";
410410

411-
assertEquals(xmlDef, expectedXml);
411+
assertEquals(expectedXml, resultingXml);
412412
}
413413

414414
@Test
415415
public void memBalloonDefTestNone() {
416-
String expectedXml = "<memballoon model='none'>\n</memballoon>";
416+
String expectedXml = "<memballoon model='none' autodeflate='on'>\n</memballoon>";
417417
MemBalloonDef memBalloonDef = new MemBalloonDef();
418418
memBalloonDef.defNoneMemBalloon();
419419

420-
String xmlDef = memBalloonDef.toString();
420+
String resultingXml = memBalloonDef.toString();
421421

422-
assertEquals(xmlDef, expectedXml);
422+
assertEquals(expectedXml, resultingXml);
423423
}
424424

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

431-
String xmlDef = memBalloonDef.toString();
431+
String resultingXml = memBalloonDef.toString();
432432

433-
assertEquals(xmlDef, expectedXml);
433+
assertEquals(expectedXml, resultingXml);
434434
}
435435

436436
@Test
@@ -465,11 +465,11 @@ public void testRngDef() {
465465
int bytes = 2048;
466466

467467
LibvirtVMDef.RngDef def = new LibvirtVMDef.RngDef(path, backendModel, bytes, period);
468-
assertEquals(def.getPath(), path);
469-
assertEquals(def.getRngBackendModel(), backendModel);
470-
assertEquals(def.getRngModel(), LibvirtVMDef.RngDef.RngModel.VIRTIO);
471-
assertEquals(def.getRngRateBytes(), bytes);
472-
assertEquals(def.getRngRatePeriod(), period);
468+
assertEquals(path, def.getPath());
469+
assertEquals(backendModel, def.getRngBackendModel());
470+
assertEquals(LibvirtVMDef.RngDef.RngModel.VIRTIO, def.getRngModel());
471+
assertEquals(bytes, def.getRngRateBytes());
472+
assertEquals(period, def.getRngRatePeriod());
473473
}
474474

475475
@Test
@@ -493,8 +493,8 @@ public void testWatchDogDef() {
493493
LibvirtVMDef.WatchDogDef.WatchDogAction action = LibvirtVMDef.WatchDogDef.WatchDogAction.RESET;
494494

495495
LibvirtVMDef.WatchDogDef def = new LibvirtVMDef.WatchDogDef(action, model);
496-
assertEquals(def.getModel(), model);
497-
assertEquals(def.getAction(), action);
496+
assertEquals(model, def.getModel());
497+
assertEquals(action, def.getAction());
498498
}
499499

500500
@Test
@@ -505,6 +505,6 @@ public void testSCSIDef() {
505505
"<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>\n" +
506506
"<driver queues='4'/>\n" +
507507
"</controller>\n";
508-
assertEquals(str, expected);
508+
assertEquals(expected, str);
509509
}
510510
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<!-- keep in alphabetic order -->
5050
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5151
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
52+
<project.systemvm.template.location>https://download.cloudstack.org/systemvm</project.systemvm.template.location>
5253
<project.systemvm.template.version>4.18.0.0</project.systemvm.template.version>
5354
<sonar.organization>apache</sonar.organization>
5455
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

python/lib/cloudutils/configFileOps.py

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
import re
18+
import os
1819
import tempfile
1920
import shutil
2021
from .utilities import bash
@@ -59,39 +60,42 @@ def getEntry(self, name, separator="="):
5960
return ""
6061

6162
def save(self):
62-
fp = open(self.fileName, "r")
6363
newLines = []
64-
for line in fp.readlines():
65-
matched = False
66-
for entry in self.entries:
67-
if entry.op == "add":
68-
if entry.separator == "=":
69-
matchString = "^\ *" + entry.name + ".*"
70-
elif entry.separator == " ":
71-
matchString = "^\ *" + entry.name + "\ *" + entry.value
72-
else:
73-
if entry.separator == "=":
74-
matchString = "^\ *" + entry.name + "\ *=\ *" + entry.value
64+
if os.path.exists(self.fileName) and os.path.isfile(self.fileName):
65+
fp = open(self.fileName, "r")
66+
for line in fp.readlines():
67+
matched = False
68+
for entry in self.entries:
69+
if entry.op == "add":
70+
if entry.separator == "=":
71+
matchString = "^\ *" + entry.name + ".*"
72+
elif entry.separator == " ":
73+
matchString = "^\ *" + entry.name + "\ *" + entry.value
7574
else:
76-
matchString = "^\ *" + entry.name + "\ *" + entry.value
77-
78-
match = re.match(matchString, line)
79-
if match is not None:
80-
if entry.op == "add" and entry.separator == "=":
81-
newline = "\n" + entry.name + "=" + entry.value + "\n"
82-
entry.setState("set")
83-
newLines.append(newline)
84-
self.backups.append([line, newline])
85-
matched = True
86-
break
87-
elif entry.op == "rm":
88-
entry.setState("set")
89-
self.backups.append([line, None])
90-
matched = True
91-
break
92-
93-
if not matched:
94-
newLines.append(line)
75+
if entry.separator == "=":
76+
matchString = "^\ *" + entry.name + "\ *=\ *" + entry.value
77+
else:
78+
matchString = "^\ *" + entry.name + "\ *" + entry.value
79+
80+
match = re.match(matchString, line)
81+
if match is not None:
82+
if entry.op == "add" and entry.separator == "=":
83+
newline = "\n" + entry.name + "=" + entry.value + "\n"
84+
entry.setState("set")
85+
newLines.append(newline)
86+
self.backups.append([line, newline])
87+
matched = True
88+
break
89+
elif entry.op == "rm":
90+
entry.setState("set")
91+
self.backups.append([line, None])
92+
matched = True
93+
break
94+
95+
if not matched:
96+
newLines.append(line)
97+
98+
fp.close()
9599

96100
for entry in self.entries:
97101
if entry.getState() != "set":
@@ -101,8 +105,6 @@ def save(self):
101105
self.backups.append([None, newline])
102106
entry.setState("set")
103107

104-
fp.close()
105-
106108
open(self.fileName, "w").writelines(newLines)
107109

108110
def replace_line(self, startswith,stanza,always_add=False):

server/src/main/java/com/cloud/hypervisor/KVMGuru.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ protected void configureVmMemoryAndCpuCores(VirtualMachineTO virtualMachineTo, H
213213
Integer maxHostCpuCore = max.second();
214214

215215
long minMemory = virtualMachineTo.getMinRam();
216-
Long maxMemory = minMemory;
216+
Long maxMemory = virtualMachineTo.getMaxRam();
217217
int minCpuCores = virtualMachineTo.getCpus();
218218
Integer maxCpuCores = minCpuCores;
219219

0 commit comments

Comments
 (0)