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(a)suse.com>
---
src/libxl/libxl_migration.c | 23 +++++++++++++++++++++++
src/libxl/libxl_migration.h | 1 +
2 files changed, 24 insertions(+)
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index f1da251..3b0dc74 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -1021,6 +1021,29 @@ libxlDomainMigrationFinish(virConnectPtr dconn,
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;
diff --git a/src/libxl/libxl_migration.h b/src/libxl/libxl_migration.h
index c02026d..8a074a0 100644
--- a/src/libxl/libxl_migration.h
+++ b/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)
--
2.1.4