VIR_ERR_NO_SECRET, /* secret not found */
VIR_ERR_CONFIG_UNSUPPORTED, /* unsupported configuration construct */
VIR_ERR_OPERATION_TIMEOUT, /* timeout occurred during operation */
+ VIR_ERR_MIGRATE_PERSIST_FAILED, /* a migration worked, but making the
+ VM persist on the dest host failed */
} virErrorNumber;
/**
else
errmsg = _("Timed out during operation: %s");
break;
+ case VIR_ERR_MIGRATE_PERSIST_FAILED:
+ if (info == NULL)
+ errmsg = _("Failed to make domain persistent after migration");
+ else
+ errmsg = _("Failed to make domain persistent after migration: %s");
+ break;
}
return (errmsg);
}
const char *cookie ATTRIBUTE_UNUSED,
int cookielen ATTRIBUTE_UNUSED,
const char *uri ATTRIBUTE_UNUSED,
- unsigned long flags ATTRIBUTE_UNUSED)
+ unsigned long flags)
{
- return xenUnifiedDomainLookupByName (dconn, dname);
+ virDomainPtr dom = NULL;
+ char *domain_xml = NULL;
+ virDomainPtr dom_new = NULL;
+
+ dom = xenUnifiedDomainLookupByName (dconn, dname);
+ if (! dom) {
+ return NULL;
+ }
+
+ if (flags & VIR_MIGRATE_PERSIST_DEST) {
+ domain_xml = xenDaemonDomainDumpXML (dom, 0, NULL);
+ if (! domain_xml) {
+ xenUnifiedError(dconn, VIR_ERR_MIGRATE_PERSIST_FAILED,
+ _("failed to get XML representation of migrated domain"));
+ goto failure;
+ }
+
+ dom_new = xenDaemonDomainDefineXML (dconn, domain_xml);
+ if (! dom_new) {
+ xenUnifiedError (dconn, VIR_ERR_MIGRATE_PERSIST_FAILED,
+ _("failed to define domain on destination host"));
+ goto failure;
+ }
+
+ /* Free additional reference added by Define */
+ virDomainFree (dom_new);
+ }
+
+ VIR_FREE (domain_xml);
+
+ return dom;
+
+
+failure:
+ virDomainFree (dom);
+
+ VIR_FREE (domain_xml);
+
+ return NULL;
}
static int
int ret;
char *p, *hostname = NULL;
+ int undefined_source = 0;
+
/* Xen doesn't support renaming domains during migration. */
if (dname) {
virXendError (conn, VIR_ERR_NO_SUPPORT,
return -1;
}
- /* Check the flags. */
+ /*
+ * Check the flags.
+ */
if ((flags & VIR_MIGRATE_LIVE)) {
strcpy (live, "1");
flags &= ~VIR_MIGRATE_LIVE;
}
+
+ /* Undefine the VM on the source host after migration? */
+ if (flags & VIR_MIGRATE_UNDEFINE_SOURCE) {
+ undefined_source = 1;
+ flags &= ~VIR_MIGRATE_UNDEFINE_SOURCE;
+ }
+
+ /* Ignore the persist_dest flag here */
+ if (flags & VIR_MIGRATE_PERSIST_DEST)
+ flags &= ~VIR_MIGRATE_PERSIST_DEST;
+
/* XXX we could easily do tunnelled & peer2peer migration too
if we want to. support these... */
if (flags != 0) {
NULL);
VIR_FREE (hostname);
+ if (ret == 0 && undefined_source)
+ xenDaemonDomainUndefine (domain);
+
DEBUG0("migration done");
return ret;