mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu_migration_cookie.c: modernize qemuMigrationEatCookie()
Use g_autoptr() and remove the obsolete 'error' label. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
ce15bd09d1
commit
c54dba525d
@ -1464,14 +1464,14 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
|
|||||||
int cookieinlen,
|
int cookieinlen,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
qemuMigrationCookiePtr mig = NULL;
|
g_autoptr(qemuMigrationCookie) mig = NULL;
|
||||||
|
|
||||||
/* Parse & validate incoming cookie (if any) */
|
/* Parse & validate incoming cookie (if any) */
|
||||||
if (cookiein && cookieinlen &&
|
if (cookiein && cookieinlen &&
|
||||||
cookiein[cookieinlen-1] != '\0') {
|
cookiein[cookieinlen-1] != '\0') {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Migration cookie was not NULL terminated"));
|
_("Migration cookie was not NULL terminated"));
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_DEBUG("cookielen=%d cookie='%s'", cookieinlen, NULLSTR(cookiein));
|
VIR_DEBUG("cookielen=%d cookie='%s'", cookieinlen, NULLSTR(cookiein));
|
||||||
@ -1485,7 +1485,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
|
|||||||
priv ? priv->qemuCaps : NULL,
|
priv ? priv->qemuCaps : NULL,
|
||||||
cookiein,
|
cookiein,
|
||||||
flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
if (flags & QEMU_MIGRATION_COOKIE_PERSISTENT &&
|
if (flags & QEMU_MIGRATION_COOKIE_PERSISTENT &&
|
||||||
mig->persistent &&
|
mig->persistent &&
|
||||||
@ -1500,7 +1500,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Missing %s lock state for migration cookie"),
|
_("Missing %s lock state for migration cookie"),
|
||||||
virLockManagerPluginGetName(driver->lockManager));
|
virLockManagerPluginGetName(driver->lockManager));
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else if (STRNEQ(mig->lockDriver,
|
} else if (STRNEQ(mig->lockDriver,
|
||||||
virLockManagerPluginGetName(driver->lockManager))) {
|
virLockManagerPluginGetName(driver->lockManager))) {
|
||||||
@ -1508,16 +1508,12 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
|
|||||||
_("Source host lock driver %s different from target %s"),
|
_("Source host lock driver %s different from target %s"),
|
||||||
mig->lockDriver,
|
mig->lockDriver,
|
||||||
virLockManagerPluginGetName(driver->lockManager));
|
virLockManagerPluginGetName(driver->lockManager));
|
||||||
goto error;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo)
|
if (flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo)
|
||||||
mig->jobInfo->operation = priv->job.current->operation;
|
mig->jobInfo->operation = priv->job.current->operation;
|
||||||
|
|
||||||
return mig;
|
return g_steal_pointer(&mig);
|
||||||
|
|
||||||
error:
|
|
||||||
qemuMigrationCookieFree(mig);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user