Merge pull request #767 from mike-tutkowski/CLOUDSTACK-8792

Support live migration on older version of Libvirthttps://issues.apache.org/jira/browse/CLOUDSTACK-8792

A flag being passed to Libvirt assumes v1.0.0 or later.

We need to put a check in the code to pass in a different flag if the version of Libvirt is < 1.0.0.

* pr/767:
  Support live migration on older version of Libvirt

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2015-09-01 17:21:59 +05:30
commit c8bfeb88c3
2 changed files with 17 additions and 2 deletions

View File

@ -87,8 +87,12 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
CVE-2015-3252: Get XML with sensitive information suitable for migration by using
VIR_DOMAIN_XML_MIGRATABLE flag (value = 8)
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainXMLFlags
Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
*/
xmlDesc = dm.getXMLDesc(8).replace(libvirtComputingResource.getPrivateIp(), command.getDestinationIp());
int xmlFlag = conn.getLibVirVersion() >= 1000000 ? 8 : 1; // 1000000 equals v1.0.0
xmlDesc = dm.getXMLDesc(xmlFlag).replace(libvirtComputingResource.getPrivateIp(), command.getDestinationIp());
dconn = libvirtUtilitiesHelper.retrieveQemuConnection("qemu+tcp://" + command.getDestinationIp() + "/system");

View File

@ -1246,6 +1246,7 @@ public class LibvirtComputingResourceTest {
when(libvirtComputingResource.getPrivateIp()).thenReturn("127.0.0.1");
when(dm.getXMLDesc(8)).thenReturn("host_domain");
when(dm.getXMLDesc(1)).thenReturn("host_domain");
when(dm.isPersistent()).thenReturn(1);
doNothing().when(dm).undefine();
@ -1273,10 +1274,20 @@ public class LibvirtComputingResourceTest {
verify(libvirtComputingResource, times(1)).getDisks(conn, vmName);
try {
verify(conn, times(1)).domainLookupByName(vmName);
verify(dm, times(1)).getXMLDesc(8);
} catch (final LibvirtException e) {
fail(e.getMessage());
}
try {
verify(dm, times(1)).getXMLDesc(8);
} catch (final Throwable t) {
try {
verify(dm, times(1)).getXMLDesc(1);
}
catch (final LibvirtException e) {
fail(e.getMessage());
}
}
}
@Test