Skip to content

Commit b86214b

Browse files
weizhouapacherohityadavcloud
authored andcommitted
kvm: truncate vnc password to 8 chars (apache#6244)
This PR truncates the vnc password of kvm vms to 8 chars to support latest versions of libvirt. (cherry picked from commit aa0197c) Signed-off-by: Rohit Yadav <[email protected]>
1 parent 8180741 commit b86214b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ public String toString() {
17641764
graphicBuilder.append(" listen=''");
17651765
}
17661766
if (_passwd != null) {
1767-
graphicBuilder.append(" passwd='" + _passwd + "'");
1767+
graphicBuilder.append(" passwd='" + StringUtils.truncate(_passwd, 8) + "'");
17681768
} else if (_keyMap != null) {
17691769
graphicBuilder.append(" _keymap='" + _keyMap + "'");
17701770
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.apache.cloudstack.utils.linux.MemStat;
6161
import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
6262
import org.apache.commons.lang.SystemUtils;
63+
import org.apache.commons.lang3.StringUtils;
6364
import org.joda.time.Duration;
6465
import org.junit.Assert;
6566
import org.junit.Before;
@@ -773,7 +774,7 @@ private void verifyGraphicsDevices(VirtualMachineTO to, Document domainDoc, Stri
773774
assertXpath(domainDoc, prefix + "/graphics/@type", "vnc");
774775
assertXpath(domainDoc, prefix + "/graphics/@listen", to.getVncAddr());
775776
assertXpath(domainDoc, prefix + "/graphics/@autoport", "yes");
776-
assertXpath(domainDoc, prefix + "/graphics/@passwd", to.getVncPassword());
777+
assertXpath(domainDoc, prefix + "/graphics/@passwd", StringUtils.truncate(to.getVncPassword(), 8));
777778
}
778779

779780
private void verifySerialDevices(Document domainDoc, String prefix) {

0 commit comments

Comments
 (0)