File 1fc90ae9-libxl-mig-persist.patch of Package libvirt

commit 1fc90ae934b8b05e02ffc47cb79f181d9e5ece69
Author: Jim Fehlig <jfehlig@suse.com>
Date:   Mon Sep 19 11:34:34 2016 -0600

    libxl: support VIR_MIGRATE_PERSIST_DEST migration flag
    
    By default, virt-manager (and likely other libvirt-based apps) sets
    the VIR_MIGRATE_PERSIST_DEST flag when invoking the migrate API, which
    fails in a Xen setup since the libxl driver does not support the flag.
    
    Persisting a domain is a trivial task in the grand scheme of migration,
    so be nice to libvirt apps and add support for VIR_MIGRATE_PERSIST_DEST
    in the libxl driver.
    
    Signed-off-by: Jim Fehlig <jfehlig@suse.com>

Index: libvirt-2.0.0/src/libxl/libxl_migration.c
===================================================================
--- libvirt-2.0.0.orig/src/libxl/libxl_migration.c
+++ libvirt-2.0.0/src/libxl/libxl_migration.c
@@ -964,6 +964,29 @@ libxlDomainMigrationFinish(virConnectPtr
         event = NULL;
     }
 
+    if (flags & VIR_MIGRATE_PERSIST_DEST) {
+        unsigned int oldPersist = vm->persistent;
+        virDomainDefPtr vmdef;
+
+        vm->persistent = 1;
+        if (!(vmdef = virDomainObjGetPersistentDef(cfg->caps,
+                                                   driver->xmlopt, vm)))
+            goto cleanup;
+
+        if (virDomainSaveConfig(cfg->configDir, cfg->caps, vmdef) < 0)
+            goto cleanup;
+
+        event = virDomainEventLifecycleNewFromObj(vm,
+                                         VIR_DOMAIN_EVENT_DEFINED,
+                                         oldPersist ?
+                                         VIR_DOMAIN_EVENT_DEFINED_UPDATED :
+                                         VIR_DOMAIN_EVENT_DEFINED_ADDED);
+        if (event) {
+            libxlDomainEventQueue(driver, event);
+            event = NULL;
+        }
+    }
+
     if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, cfg->caps) < 0)
         goto cleanup;
 
Index: libvirt-2.0.0/src/libxl/libxl_migration.h
===================================================================
--- libvirt-2.0.0.orig/src/libxl/libxl_migration.h
+++ libvirt-2.0.0/src/libxl/libxl_migration.h
@@ -29,6 +29,7 @@
 # define LIBXL_MIGRATION_FLAGS                  \
     (VIR_MIGRATE_LIVE |                         \
      VIR_MIGRATE_PEER2PEER |                    \
+     VIR_MIGRATE_PERSIST_DEST |                 \
      VIR_MIGRATE_UNDEFINE_SOURCE |              \
      VIR_MIGRATE_PAUSED)