Implement finer grained migration control for Xen

* src/xen/xen_driver.c: Add support for VIR_MIGRATE_PERSIST_DEST flag
* src/xen/xend_internal.c: Add support for VIR_MIGRATE_UNDEFINE_SOURCE flag
* include/libvirt/virterror.h, src/util/virterror.c: Add new errorcode
  VIR_ERR_MIGRATE_PERSIST_FAILED
This commit is contained in:
Maximilian Wilhelm 2009-11-12 16:04:43 +01:00 committed by Daniel Veillard
parent 2e23607448
commit 632be33689
4 changed files with 67 additions and 3 deletions

View File

@ -172,6 +172,8 @@ typedef enum {
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;
/**

View File

@ -1101,6 +1101,12 @@ virErrorMsg(virErrorNumber error, const char *info)
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);
}

View File

@ -1301,9 +1301,47 @@ xenUnifiedDomainMigrateFinish (virConnectPtr dconn,
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

View File

@ -4396,6 +4396,8 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
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,
@ -4414,11 +4416,24 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
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) {
@ -4504,6 +4519,9 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
NULL);
VIR_FREE (hostname);
if (ret == 0 && undefined_source)
xenDaemonDomainUndefine (domain);
DEBUG0("migration done");
return ret;