This way we get stats only in one place. The former code waits for
complete/postcopy status basically and don't need to mess with stats.
The patch drops raising an error on stats updates failure. This
does not make much sense anyway.
---
src/qemu/qemu_migration.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index b4fc46c..f766ca6 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1404,8 +1404,7 @@ qemuMigrationUpdateJobStatus(virQEMUDriverPtr driver,
static int
qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
virDomainObjPtr vm,
- qemuDomainAsyncJob asyncJob,
- bool updateJobStats)
+ qemuDomainAsyncJob asyncJob)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainJobInfoPtr jobInfo = priv->job.current;
@@ -1434,12 +1433,6 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
return -1;
case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
- /* Fetch statistics of a completed migration */
- if (events && updateJobStats &&
- qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0)
- return -1;
- break;
-
case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
break;
@@ -1451,10 +1444,10 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
enum qemuMigrationCompletedFlags {
QEMU_MIGRATION_COMPLETED_ABORT_ON_ERROR = (1 << 0),
QEMU_MIGRATION_COMPLETED_CHECK_STORAGE = (1 << 1),
- QEMU_MIGRATION_COMPLETED_UPDATE_STATS = (1 << 2),
- QEMU_MIGRATION_COMPLETED_POSTCOPY = (1 << 3),
+ QEMU_MIGRATION_COMPLETED_POSTCOPY = (1 << 2),
};
+
/**
* Returns 1 if migration completed successfully,
* 0 if the domain is still being migrated,
@@ -1471,9 +1464,8 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainJobInfoPtr jobInfo = priv->job.current;
int pauseReason;
- bool updateStats = !!(flags & QEMU_MIGRATION_COMPLETED_UPDATE_STATS);
- if (qemuMigrationCheckJobStatus(driver, vm, asyncJob, updateStats) < 0)
+ if (qemuMigrationCheckJobStatus(driver, vm, asyncJob) < 0)
goto error;
if (flags & QEMU_MIGRATION_COMPLETED_CHECK_STORAGE &&
@@ -1501,9 +1493,6 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
if (flags & QEMU_MIGRATION_COMPLETED_POSTCOPY &&
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
VIR_DEBUG("Migration switched to post-copy");
- if (updateStats &&
- qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0)
- goto error;
return 1;
}
@@ -1542,8 +1531,6 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
int rv;
- flags |= QEMU_MIGRATION_COMPLETED_UPDATE_STATS;
-
jobInfo->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
while ((rv = qemuMigrationCompleted(driver, vm, asyncJob,
dconn, flags)) != 1) {
@@ -1565,6 +1552,9 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
}
}
+ if (events)
+ ignore_value(qemuMigrationUpdateJobStatus(driver, vm, asyncJob));
+
qemuDomainJobInfoUpdateDowntime(jobInfo);
VIR_FREE(priv->job.completed);
if (VIR_ALLOC(priv->job.completed) == 0)
--
1.8.3.1