To keep all cookie handling (parsing and formatting) in the same
function.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_migration.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index dcd7ff3597..170d99d789 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -5843,11 +5843,19 @@ static virDomainPtr
qemuMigrationDstFinishOffline(virQEMUDriver *driver,
virConnectPtr dconn,
virDomainObj *vm,
- qemuMigrationCookie *mig,
+ int cookie_flags,
+ const char *cookiein,
+ int cookieinlen,
char **cookieout,
int *cookieoutlen)
{
virDomainPtr dom = NULL;
+ qemuDomainObjPrivate *priv = vm->privateData;
+ g_autoptr(qemuMigrationCookie) mig = NULL;
+
+ if (!(mig = qemuMigrationCookieParse(driver, vm->def, priv->origname, priv,
+ cookiein, cookieinlen, cookie_flags)))
+ return NULL;
if (qemuMigrationDstPersist(driver, vm, mig, false) < 0)
return NULL;
@@ -6050,13 +6058,11 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
* even though VIR_MIGRATE_PERSIST_DEST was not used. */
cookie_flags |= QEMU_MIGRATION_COOKIE_PERSISTENT;
- if (!(mig = qemuMigrationCookieParse(driver, vm->def, priv->origname, priv,
- cookiein, cookieinlen, cookie_flags)))
- goto error;
-
if (flags & VIR_MIGRATE_OFFLINE) {
if (retcode == 0) {
- dom = qemuMigrationDstFinishOffline(driver, dconn, vm, mig,
+ dom = qemuMigrationDstFinishOffline(driver, dconn, vm,
+ cookie_flags,
+ cookiein, cookieinlen,
cookieout, cookieoutlen);
}
@@ -6064,6 +6070,10 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
goto cleanup;
}
+ if (!(mig = qemuMigrationCookieParse(driver, vm->def, priv->origname, priv,
+ cookiein, cookieinlen, cookie_flags)))
+ goto error;
+
if (retcode != 0) {
/* Check for a possible error on the monitor in case Finish was called
* earlier than monitor EOF handler got a chance to process the error
--
2.35.1