qemu: Separate cookie parsing for qemuMigrationDstFinishOffline

To keep all cookie handling (parsing and formatting) in the same
function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Jiri Denemark 2022-05-10 15:20:25 +02:00
parent 71951e9869
commit 229456b140

View File

@ -5812,11 +5812,19 @@ static virDomainPtr
qemuMigrationDstFinishOffline(virQEMUDriver *driver, qemuMigrationDstFinishOffline(virQEMUDriver *driver,
virConnectPtr dconn, virConnectPtr dconn,
virDomainObj *vm, virDomainObj *vm,
qemuMigrationCookie *mig, int cookie_flags,
const char *cookiein,
int cookieinlen,
char **cookieout, char **cookieout,
int *cookieoutlen) int *cookieoutlen)
{ {
virDomainPtr dom = NULL; 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) if (qemuMigrationDstPersist(driver, vm, mig, false) < 0)
return NULL; return NULL;
@ -6019,13 +6027,11 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
* even though VIR_MIGRATE_PERSIST_DEST was not used. */ * even though VIR_MIGRATE_PERSIST_DEST was not used. */
cookie_flags |= QEMU_MIGRATION_COOKIE_PERSISTENT; 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 (flags & VIR_MIGRATE_OFFLINE) {
if (retcode == 0) { if (retcode == 0) {
dom = qemuMigrationDstFinishOffline(driver, dconn, vm, mig, dom = qemuMigrationDstFinishOffline(driver, dconn, vm,
cookie_flags,
cookiein, cookieinlen,
cookieout, cookieoutlen); cookieout, cookieoutlen);
} }
@ -6033,6 +6039,10 @@ qemuMigrationDstFinish(virQEMUDriver *driver,
goto cleanup; goto cleanup;
} }
if (!(mig = qemuMigrationCookieParse(driver, vm->def, priv->origname, priv,
cookiein, cookieinlen, cookie_flags)))
goto error;
if (retcode != 0) { if (retcode != 0) {
/* Check for a possible error on the monitor in case Finish was called /* 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 * earlier than monitor EOF handler got a chance to process the error