Repository: cloudstack
Updated Branches:
  refs/heads/master 22c78ede3 -> c8bfeb88c


Support live migration on older version of Libvirt


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c5a0d5e0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c5a0d5e0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c5a0d5e0

Branch: refs/heads/master
Commit: c5a0d5e01c98a1a1915ea2d778baa2f30807f788
Parents: 1bbd23e
Author: Mike Tutkowski <[email protected]>
Authored: Mon Aug 31 12:40:08 2015 -0600
Committer: Mike Tutkowski <[email protected]>
Committed: Mon Aug 31 22:06:51 2015 -0600

----------------------------------------------------------------------
 .../resource/wrapper/LibvirtMigrateCommandWrapper.java |  6 +++++-
 .../kvm/resource/LibvirtComputingResourceTest.java     | 13 ++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5a0d5e0/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
index a6bb591..c1328aa 100644
--- 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
+++ 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
@@ -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");
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5a0d5e0/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
 
b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
index 03d9f49..920c86a 100644
--- 
a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
+++ 
b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
@@ -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

Reply via email to