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(a)redhat.com>
---
Notes:
Version 2:
- moved to the end of the series since it is not required
by another patch in this series anymore
src/qemu/qemu_migration.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 2a34b4a..55a8be0 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2847,21 +2847,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,
@@ -4527,6 +4520,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, "
@@ -4709,9 +4703,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)
@@ -6327,8 +6329,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) {
--
2.7.0