Skip to content

Commit 3d420b9

Browse files
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. Backport of apache@aa0197c Signed-off-by: Rohit Yadav <[email protected]>
1 parent 3e1d851 commit 3d420b9

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
@@ -1723,7 +1723,7 @@ public String toString() {
17231723
graphicBuilder.append(" listen=''");
17241724
}
17251725
if (_passwd != null) {
1726-
graphicBuilder.append(" passwd='" + _passwd + "'");
1726+
graphicBuilder.append(" passwd='" + StringUtils.truncate(_passwd, 8) + "'");
17271727
} else if (_keyMap != null) {
17281728
graphicBuilder.append(" _keymap='" + _keyMap + "'");
17291729
}

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;
@@ -372,7 +373,7 @@ private void verifyVm(final VirtualMachineTO to, final LibvirtVMDef vm) {
372373
assertXpath(domainDoc, "/domain/devices/graphics/@type", "vnc");
373374
assertXpath(domainDoc, "/domain/devices/graphics/@listen", to.getVncAddr());
374375
assertXpath(domainDoc, "/domain/devices/graphics/@autoport", "yes");
375-
assertXpath(domainDoc, "/domain/devices/graphics/@passwd", to.getVncPassword());
376+
assertXpath(domainDoc, "/domain/devices/graphics/@passwd", StringUtils.truncate(to.getVncPassword(), 8));
376377

377378
assertXpath(domainDoc, "/domain/devices/console/@type", "pty");
378379
assertXpath(domainDoc, "/domain/devices/console/target/@port", "0");

0 commit comments

Comments
 (0)