Re: [libvirt] Re: [PATCH] Implement finer grained migration control for Xen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Anno domini 2009 Daniel Veillard scripsit:

[persistent migration for Xen]
>   Yes adding a different error with a clear semantic so that the
> management code can understand the current situation and not assume the
> domain in still running on the source node sounds the right approach to
> me. We can't make this a completely atomic operation, so we need to deal
> with this !

>   Patch welcome :-) Thanks !

So, after a bit of delay due to some private things, here we are.

> Any chance you could provide an updated patch for the Xen side
> independantly, or did I missed it ?

I wanted to do it "right" on the first shot, therefore I didn't post
an updated patch with my last mail. :)

 * 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

Ciao
Max
-- 
Arroganz verkürzt fruchtlose Gespräche.
-- Jan-Benedict Glaw
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 4c28501..c36ab70 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -171,6 +171,7 @@ typedef enum {
     VIR_ERR_INVALID_SECRET, /* invalid secret */
     VIR_ERR_NO_SECRET, /* secret not found */
     VIR_ERR_CONFIG_UNSUPPORTED, /* unsupported configuration construct */
+    VIR_ERR_MIGRATE_PERSIST_FAILED, /* a migration worked, but making the VM persist on the dest host failed */
 } virErrorNumber;
 
 /**
diff --git a/src/util/virterror.c b/src/util/virterror.c
index c8e8623..054d060 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -1095,6 +1095,12 @@ virErrorMsg(virErrorNumber error, const char *info)
             else
                 errmsg = _("unsupported configuration: %s");
             break;
+        case VIR_ERR_MIGRATE_PERSIST_FAILED:
+            if (info == NULL)
+                errmsg = _("Failed to make domain persistent after successful migration");
+            else
+                errmsg = _("Failed to make domain persistent after successful migration: %s");
+            break;
     }
     return (errmsg);
 }
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 479db10..adef710 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1187,9 +1187,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
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index f86e022..dc53967 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -4378,6 +4378,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,
@@ -4396,11 +4398,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) {
@@ -4486,6 +4501,9 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
                    NULL);
     VIR_FREE (hostname);
 
+    if (ret == 0 && undefined_source)
+        xenDaemonDomainUndefine (domain);
+
     DEBUG0("migration done");
 
     return ret;
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]