qemuMigrationCookieAddNBD: Use virHashNew and automatic freeing of virHashTablePtr

Swithc to the helper which doesn't require checking of the return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2020-01-30 15:01:41 +01:00
parent 464345e153
commit 45eefb2c78

View File

@ -454,7 +454,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virHashTablePtr stats = NULL;
g_autoptr(virHashTable) stats = virHashNew(virHashValueFree);
size_t i;
int ret = -1, rc;
@ -472,9 +472,6 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
mig->nbd->disks = g_new0(struct qemuMigrationCookieNBDDisk, vm->def->ndisks);
mig->nbd->ndisks = 0;
if (!(stats = virHashCreate(10, virHashValueFree)))
goto cleanup;
if (qemuDomainObjEnterMonitorAsync(driver, vm, priv->job.asyncJob) < 0)
goto cleanup;
rc = qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false);
@ -496,7 +493,6 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig,
ret = 0;
cleanup:
virHashFree(stats);
return ret;
}