commit 7d704812b9c50cd3804dd1e7f9e2ea3e75fdc847
Author: Michal Privoznik <mprivozn@redhat.com>
Date:   Thu Oct 10 10:53:56 2013 +0200

    qemu: Introduce qemuDomainDefCheckABIStability

    https://bugzilla.redhat.com/show_bug.cgi?id=994364

    Whenever we check for ABI stability, we have new xml (e.g. provided by
    user, or obtained from snapshot, whatever) which we compare to old xml
    and see if ABI won't break. However, if the new xml was produced via
    virDomainGetXMLDesc(..., VIR_DOMAIN_XML_MIGRATABLE) it lacks some
    devices, e.g. 'pci-root' controller. Hence, the ABI stability check
    fails even though it is stable. Moreover, we can't simply fix
    virDomainDefCheckABIStability because removing the correct devices is
    task for the driver. For instance, qemu driver wants to remove the usb
    controller too, while LXC driver doesn't. That's why we need special
    qemu wrapper over virDomainDefCheckABIStability which removes the
    correct devices from domain XML, produces MIGRATABLE xml and calls the
    check ABI stability function.

    Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Index: libvirt-1.0.5.9/src/qemu/qemu_domain.c
===================================================================
--- libvirt-1.0.5.9.orig/src/qemu/qemu_domain.c
+++ libvirt-1.0.5.9/src/qemu/qemu_domain.c
@@ -2170,3 +2170,25 @@ cleanup:
     virObjectUnref(cfg);
     return ret;
 }
+
+bool
+qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
+                               virDomainDefPtr src,
+                               virDomainDefPtr dst)
+{
+    virDomainDefPtr migratableDefSrc = NULL;
+    virDomainDefPtr migratableDefDst = NULL;
+    const int flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_MIGRATABLE;
+    bool ret = false;
+
+    if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, flags)) ||
+        !(migratableDefDst = qemuDomainDefCopy(driver, dst, flags)))
+        goto cleanup;
+
+    ret = virDomainDefCheckABIStability(migratableDefSrc, migratableDefDst);
+
+cleanup:
+    virDomainDefFree(migratableDefSrc);
+    virDomainDefFree(migratableDefDst);
+    return ret;
+}
Index: libvirt-1.0.5.9/src/qemu/qemu_domain.h
===================================================================
--- libvirt-1.0.5.9.orig/src/qemu/qemu_domain.h
+++ libvirt-1.0.5.9/src/qemu/qemu_domain.h
@@ -352,4 +352,7 @@ extern virDomainXMLPrivateDataCallbacks
 extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
 extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
 
+bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
+                                    virDomainDefPtr src,
+                                    virDomainDefPtr dst);
 #endif /* __QEMU_DOMAIN_H__ */
Index: libvirt-1.0.5.9/src/qemu/qemu_driver.c
===================================================================
--- libvirt-1.0.5.9.orig/src/qemu/qemu_driver.c
+++ libvirt-1.0.5.9/src/qemu/qemu_driver.c
@@ -2833,7 +2833,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr
                                             VIR_DOMAIN_XML_INACTIVE))) {
             goto endjob;
         }
-        if (!virDomainDefCheckABIStability(vm->def, def)) {
+        if (!qemuDomainDefCheckABIStability(driver, vm->def, def)) {
             virDomainDefFree(def);
             goto endjob;
         }
@@ -12154,7 +12154,7 @@ static int qemuDomainRevertToSnapshot(vi
         if (virDomainObjIsActive(vm)) {
             /* Transitions 5, 6, 8, 9 */
             /* Check for ABI compatibility.  */
-            if (config && !virDomainDefCheckABIStability(vm->def, config)) {
+            if (config && !qemuDomainDefCheckABIStability(driver, vm->def, config)) {
                 virErrorPtr err = virGetLastError();
 
                 if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) {
Index: libvirt-1.0.5.9/src/qemu/qemu_migration.c
===================================================================
--- libvirt-1.0.5.9.orig/src/qemu/qemu_migration.c
+++ libvirt-1.0.5.9/src/qemu/qemu_migration.c
@@ -1967,7 +1967,7 @@ char *qemuMigrationBegin(virQEMUDriverPt
             goto cleanup;
         }
 
-        if (!virDomainDefCheckABIStability(vm->def, def))
+        if (!qemuDomainDefCheckABIStability(driver, vm->def, def))
             goto cleanup;
 
         rv = qemuDomainDefFormatLive(driver, def, false, true);
@@ -2111,7 +2111,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr
                 if (!newdef)
                     goto cleanup;
 
-                if (!virDomainDefCheckABIStability(def, newdef)) {
+                if (!qemuDomainDefCheckABIStability(driver, def, newdef)) {
                     virDomainDefFree(newdef);
                     goto cleanup;
                 }

