[PATCH v2 2/4] qemuMigrationEatCookie: Pass virDomainDef instead of virDomainObj

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

 



The function currently takes virDomainObjPtr because it's using
both: the domain definition and domain private data.
Unfortunately, this means that in prepare phase we can't parse
migration cookie before putting incoming domain def onto domain
objects list (addressed in the very next commit). Change the
arguments so that virDomainDef and private data are passed
instead of virDomainObjPtr.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c        | 16 ++++++++++------
 src/qemu/qemu_migration_cookie.c | 23 ++++++++++++-----------
 src/qemu/qemu_migration_cookie.h |  4 +++-
 3 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 317df4bed5..0317a35246 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2041,7 +2041,8 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver,
     if (!(flags & VIR_MIGRATE_OFFLINE))
         cookieFlags |= QEMU_MIGRATION_COOKIE_CAPS;
 
-    if (!(mig = qemuMigrationEatCookie(driver, vm, NULL, 0, 0)))
+    if (!(mig = qemuMigrationEatCookie(driver, vm->def,
+                                       priv->origname, priv, NULL, 0, 0)))
         goto cleanup;
 
     if (qemuMigrationBakeCookie(mig, driver, vm,
@@ -2411,7 +2412,8 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver,
         priv->hookRun = true;
     }
 
-    if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
+    if (!(mig = qemuMigrationEatCookie(driver, vm->def, origname, priv,
+                                       cookiein, cookieinlen,
                                        QEMU_MIGRATION_COOKIE_LOCKSTATE |
                                        QEMU_MIGRATION_COOKIE_NBD |
                                        QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG |
@@ -2922,7 +2924,8 @@ qemuMigrationSrcConfirmPhase(virQEMUDriverPtr driver,
                              ? QEMU_MIGRATION_PHASE_CONFIRM3
                              : QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED);
 
-    if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
+    if (!(mig = qemuMigrationEatCookie(driver, vm->def, priv->origname, priv,
+                                       cookiein, cookieinlen,
                                        QEMU_MIGRATION_COOKIE_STATS)))
         goto cleanup;
 
@@ -3427,7 +3430,8 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver,
         }
     }
 
-    mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
+    mig = qemuMigrationEatCookie(driver, vm->def, priv->origname, priv,
+                                 cookiein, cookieinlen,
                                  cookieFlags |
                                  QEMU_MIGRATION_COOKIE_GRAPHICS |
                                  QEMU_MIGRATION_COOKIE_CAPS);
@@ -4948,8 +4952,8 @@ qemuMigrationDstFinish(virQEMUDriverPtr driver,
      * even though VIR_MIGRATE_PERSIST_DEST was not used. */
     cookie_flags |= QEMU_MIGRATION_COOKIE_PERSISTENT;
 
-    if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein,
-                                       cookieinlen, cookie_flags)))
+    if (!(mig = qemuMigrationEatCookie(driver, vm->def, priv->origname, priv,
+                                       cookiein, cookieinlen, cookie_flags)))
         goto endjob;
 
     if (flags & VIR_MIGRATE_OFFLINE) {
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 60df449d53..295e28ae30 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -279,22 +279,22 @@ qemuMigrationCookieNetworkAlloc(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
 
 
 static qemuMigrationCookiePtr
-qemuMigrationCookieNew(virDomainObjPtr dom)
+qemuMigrationCookieNew(const virDomainDef *def,
+                       const char *origname)
 {
-    qemuDomainObjPrivatePtr priv = dom->privateData;
     qemuMigrationCookiePtr mig = NULL;
     const char *name;
 
     if (VIR_ALLOC(mig) < 0)
         goto error;
 
-    if (priv->origname)
-        name = priv->origname;
+    if (origname)
+        name = origname;
     else
-        name = dom->def->name;
+        name = def->name;
     if (VIR_STRDUP(mig->name, name) < 0)
         goto error;
-    memcpy(mig->uuid, dom->def->uuid, VIR_UUID_BUFLEN);
+    memcpy(mig->uuid, def->uuid, VIR_UUID_BUFLEN);
 
     if (!(mig->localHostname = virGetHostname()))
         goto error;
@@ -1472,12 +1472,13 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
 
 qemuMigrationCookiePtr
 qemuMigrationEatCookie(virQEMUDriverPtr driver,
-                       virDomainObjPtr dom,
+                       const virDomainDef *def,
+                       const char *origname,
+                       qemuDomainObjPrivatePtr priv,
                        const char *cookiein,
                        int cookieinlen,
                        unsigned int flags)
 {
-    qemuDomainObjPrivatePtr priv = dom->privateData;
     qemuMigrationCookiePtr mig = NULL;
 
     /* Parse & validate incoming cookie (if any) */
@@ -1490,7 +1491,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
 
     VIR_DEBUG("cookielen=%d cookie='%s'", cookieinlen, NULLSTR(cookiein));
 
-    if (!(mig = qemuMigrationCookieNew(dom)))
+    if (!(mig = qemuMigrationCookieNew(def, origname)))
         return NULL;
 
     if (cookiein && cookieinlen &&
@@ -1502,9 +1503,9 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
 
     if (flags & QEMU_MIGRATION_COOKIE_PERSISTENT &&
         mig->persistent &&
-        STRNEQ(dom->def->name, mig->persistent->name)) {
+        STRNEQ(def->name, mig->persistent->name)) {
         VIR_FREE(mig->persistent->name);
-        if (VIR_STRDUP(mig->persistent->name, dom->def->name) < 0)
+        if (VIR_STRDUP(mig->persistent->name, def->name) < 0)
             goto error;
     }
 
diff --git a/src/qemu/qemu_migration_cookie.h b/src/qemu/qemu_migration_cookie.h
index 08c5de8f06..b399787074 100644
--- a/src/qemu/qemu_migration_cookie.h
+++ b/src/qemu/qemu_migration_cookie.h
@@ -160,7 +160,9 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
 
 qemuMigrationCookiePtr
 qemuMigrationEatCookie(virQEMUDriverPtr driver,
-                       virDomainObjPtr dom,
+                       const virDomainDef *def,
+                       const char *origname,
+                       qemuDomainObjPrivatePtr priv,
                        const char *cookiein,
                        int cookieinlen,
                        unsigned int flags);
-- 
2.18.1

--
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]

  Powered by Linux