qemu: Add flags to qemuMigrationWaitForCompletion

The function already takes two bool arguments, switching to flags makes
it a lot easier to read. Especially in case we need to add another
boolean in the future.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2015-12-17 13:46:18 +01:00
parent d64adcdb96
commit 109017d9b3

View File

@ -2740,21 +2740,14 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virConnectPtr dconn,
bool abort_on_error,
bool storage)
unsigned int flags)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainJobInfoPtr jobInfo = priv->job.current;
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
unsigned int flags;
int rv;
flags = QEMU_MIGRATION_COMPLETED_UPDATE_STATS |
QEMU_MIGRATION_COMPLETED_POSTCOPY;
if (abort_on_error)
flags |= QEMU_MIGRATION_COMPLETED_ABORT_ON_ERROR;
if (storage)
flags |= QEMU_MIGRATION_COMPLETED_CHECK_STORAGE;
flags |= QEMU_MIGRATION_COMPLETED_UPDATE_STATS;
jobInfo->type = VIR_DOMAIN_JOB_UNBOUNDED;
while ((rv = qemuMigrationCompleted(driver, vm, asyncJob,
@ -4461,6 +4454,7 @@ qemuMigrationRun(virQEMUDriverPtr driver,
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
bool inPostCopy = false;
unsigned int waitFlags;
int rc;
VIR_DEBUG("driver=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
@ -4646,9 +4640,17 @@ qemuMigrationRun(virQEMUDriverPtr driver,
fd = -1;
}
waitFlags = 0;
if (abort_on_error)
waitFlags |= QEMU_MIGRATION_COMPLETED_ABORT_ON_ERROR;
if (mig->nbd)
waitFlags |= QEMU_MIGRATION_COMPLETED_CHECK_STORAGE;
if (flags & VIR_MIGRATE_POSTCOPY)
waitFlags |= QEMU_MIGRATION_COMPLETED_POSTCOPY;
rc = qemuMigrationWaitForCompletion(driver, vm,
QEMU_ASYNC_JOB_MIGRATION_OUT,
dconn, abort_on_error, !!mig->nbd);
dconn, waitFlags);
if (rc == -2)
goto cancel;
else if (rc == -1)
@ -6279,8 +6281,7 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
if (rc < 0)
goto cleanup;
rc = qemuMigrationWaitForCompletion(driver, vm, asyncJob,
NULL, false, false);
rc = qemuMigrationWaitForCompletion(driver, vm, asyncJob, NULL, 0);
if (rc < 0) {
if (rc == -2) {