diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java index 60261a47837..a3e5f11b7c0 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java @@ -145,7 +145,11 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper * @param xmlDesc the qemu xml description * @param target the ip address to migrate to + * @param vncPassword if set, the VNC password truncated to 8 characters * @return the new xmlDesc */ - String replaceIpForVNCInDescFile(String xmlDesc, final String target) { + String replaceIpForVNCInDescFileAndNormalizePassword(String xmlDesc, final String target, String vncPassword) { final int begin = xmlDesc.indexOf(GRAPHICS_ELEM_START); if (begin >= 0) { final int end = xmlDesc.lastIndexOf(GRAPHICS_ELEM_END) + GRAPHICS_ELEM_END.length(); @@ -430,6 +435,9 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper" + - " " + + " " + " " + " " + " " + @@ -588,22 +588,23 @@ public class LibvirtMigrateCommandWrapperTest { final String expectedXmlDesc = "" + " " + - " " + + " " + " " + " " + " " + ""; final String targetIp = "10.10.10.10"; - final String result = libvirtMigrateCmdWrapper.replaceIpForVNCInDescFile(xmlDesc, targetIp); + final String password = "12345678"; + final String result = libvirtMigrateCmdWrapper.replaceIpForVNCInDescFileAndNormalizePassword(xmlDesc, targetIp, password); assertTrue("transformation does not live up to expectation:\n" + result, expectedXmlDesc.equals(result)); } @Test - public void testReplaceFqdnForVNCInDesc() { + public void testReplaceFqdnAndPasswordForVNCInDesc() { final String xmlDesc = "" + " " + - " " + + " " + " " + " " + " " + @@ -611,13 +612,14 @@ public class LibvirtMigrateCommandWrapperTest { final String expectedXmlDesc = "" + " " + - " " + + " " + " " + " " + " " + ""; final String targetIp = "localhost.localdomain"; - final String result = libvirtMigrateCmdWrapper.replaceIpForVNCInDescFile(xmlDesc, targetIp); + final String password = "12345678"; + final String result = libvirtMigrateCmdWrapper.replaceIpForVNCInDescFileAndNormalizePassword(xmlDesc, targetIp, password); assertTrue("transformation does not live up to expectation:\n" + result, expectedXmlDesc.equals(result)); } @@ -789,5 +791,4 @@ public class LibvirtMigrateCommandWrapperTest { Assert.assertTrue(replaced.contains("csdpdk-7")); Assert.assertFalse(replaced.contains("csdpdk-1")); } - }