]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Clarify semantics of virDomainMigrate2
authorJiri Denemark <jdenemar@redhat.com>
Fri, 14 Oct 2011 19:24:18 +0000 (21:24 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 14 Oct 2011 20:04:31 +0000 (22:04 +0200)
Explicitly disallow conflicts between domain name from dxml and dname.

src/libvirt.c
src/qemu/qemu_driver.c
src/qemu/qemu_migration.c
src/qemu/qemu_migration.h

index f1e6a6b995d39b92ec1aaf373eba11544d9244b6..69cffc5431382996cf40795a39c81981b15b24ea 100644 (file)
@@ -4854,6 +4854,9 @@ error:
  * in accessing the underlying storage.  The migration will fail
  * if @dxml would cause any guest-visible changes.  Pass NULL
  * if no changes are needed to the XML between source and destination.
+ * @dxml cannot be used to rename the domain during migration (use
+ * @dname for that purpose).  Domain name in @dxml must either match the
+ * original domain name or @dname if it was specified.
  *
  * Returns the new domain object if the migration was successful,
  *   or NULL in case of error.  Note that the new domain object
index 98f4d7f7435ad8bf92c80e6c1272358afdab234f..f833655b8ae2f9e43622e1806c3c6cdc7593cfa6 100644 (file)
@@ -8043,7 +8043,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
                         char **cookieout,
                         int *cookieoutlen,
                         unsigned long flags,
-                        const char *dname ATTRIBUTE_UNUSED,
+                        const char *dname,
                         unsigned long resource ATTRIBUTE_UNUSED)
 {
     struct qemud_driver *driver = domain->conn->privateData;
@@ -8083,7 +8083,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
     if (qemuDomainCheckEjectableMedia(driver, vm) < 0)
         goto endjob;
 
-    if (!(xml = qemuMigrationBegin(driver, vm, xmlin,
+    if (!(xml = qemuMigrationBegin(driver, vm, xmlin, dname,
                                    cookieout, cookieoutlen)))
         goto endjob;
 
index f0a0e49a877e5d6478961967fdd35e84eeef4430..ac65459377259f0b14ed88d74bb678023c2abf5f 100644 (file)
@@ -993,6 +993,7 @@ qemuDomainMigrateGraphicsRelocate(struct qemud_driver *driver,
 char *qemuMigrationBegin(struct qemud_driver *driver,
                          virDomainObjPtr vm,
                          const char *xmlin,
+                         const char *dname,
                          char **cookieout,
                          int *cookieoutlen)
 {
@@ -1001,8 +1002,10 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
     virDomainDefPtr def = NULL;
     qemuDomainObjPrivatePtr priv = vm->privateData;
 
-    VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, cookieout=%p, cookieoutlen=%p",
-              driver, vm, NULLSTR(xmlin), cookieout, cookieoutlen);
+    VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, dname=%s,"
+              " cookieout=%p, cookieoutlen=%p",
+              driver, vm, NULLSTR(xmlin), NULLSTR(dname),
+              cookieout, cookieoutlen);
 
     /* Only set the phase if we are inside QEMU_ASYNC_JOB_MIGRATION_OUT.
      * Otherwise we will start the async job later in the perform phase losing
@@ -1028,6 +1031,14 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
                                             VIR_DOMAIN_XML_INACTIVE)))
             goto cleanup;
 
+        if (STRNEQ(def->name, vm->def->name) &&
+            STRNEQ_NULLABLE(def->name, dname)) {
+            qemuReportError(VIR_ERR_INVALID_ARG, "%s",
+                            _("target domain name doesn't match source name"
+                              " nor destination name"));
+            goto cleanup;
+        }
+
         if (!virDomainDefCheckABIStability(vm->def, def))
             goto cleanup;
 
@@ -2012,7 +2023,7 @@ static int doPeer2PeerMigrate3(struct qemud_driver *driver,
      * bit here, because we are already running inside the context of
      * a single job.  */
 
-    dom_xml = qemuMigrationBegin(driver, vm, xmlin,
+    dom_xml = qemuMigrationBegin(driver, vm, xmlin, dname,
                                  &cookieout, &cookieoutlen);
     if (!dom_xml)
         goto cleanup;
index ec704220807b619abc93f56ddadcd6adac0f0566..f806ca1be684307b6eb5dd483a22dfa4c8b55a2c 100644 (file)
@@ -79,6 +79,7 @@ int qemuMigrationSetOffline(struct qemud_driver *driver,
 char *qemuMigrationBegin(struct qemud_driver *driver,
                          virDomainObjPtr vm,
                          const char *xmlin,
+                         const char *dname,
                          char **cookieout,
                          int *cookieoutlen);