[libvirt] [PATCH 0/2] qemu: update jobinfo type if the job is not completed in qemuMigrationRun

In qemuMigrationRun the jobinfo type won't be updated until qemuMigrationWaitForCompletion. If migration is failed or cancelled before that(such as in qemuMigrationDriveMirror), we can't get the right jobinfo type. The following patches fix it. diff to v1: Reword commit message to clarify why we can't use qemuMigrationUpdateJobStatus. Wang Rui (2): qemu: set jobinfo type to CANCELLED if migration is cancelled in all conditions qemu: set jobinfo type to FAILED if job is failed in qemuMigrationRun src/qemu/qemu_migration.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 1.7.12.4

The migration job status is traced in qemuMigrationUpdateJobStatus which is called in qemuMigrationRun. But if migration is cancelled before the trace such as in qemuMigrationDriveMirror, the jobinfo type won't be updated to CANCELLED. After this patch, we can get jobinfo type CANCELLED if migration is cancelled during drive mirror. Moreover, we can't use qemuMigrationUpdateJobStatus because from qemu's point of view it's just the drive mirror being cancelled and the migration hasn't even started yet. Signed-off-by: Wang Rui <moon.wangrui@huawei.com> --- src/qemu/qemu_migration.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a1b1458..c678ba7 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1504,6 +1504,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver, * as this is a critical section so we are guaranteed * priv->job.asyncAbort will not change */ qemuDomainObjExitMonitor(driver, vm); + priv->job.current->type = VIR_DOMAIN_JOB_CANCELLED; virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"), qemuDomainAsyncJobTypeToString(priv->job.asyncJob), _("canceled by client")); @@ -3611,6 +3612,7 @@ qemuMigrationRun(virQEMUDriverPtr driver, * as this is a critical section so we are guaranteed * priv->job.asyncAbort will not change */ qemuDomainObjExitMonitor(driver, vm); + priv->job.current->type = VIR_DOMAIN_JOB_CANCELLED; virReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"), qemuDomainAsyncJobTypeToString(priv->job.asyncJob), _("canceled by client")); -- 1.7.12.4

If job is failed in qemuMigrationRun, we expect the jobinfo type as FAILED. But jobinfo type won't be updated until entering qemuMigrationWaitForCompletion. We should make it updated in all conditions. Moreover, we can't use qemuMigrationUpdateJobStatus here because job may fail in libvirt, so we can't query job status from QEMU. Signed-off-by: Wang Rui <moon.wangrui@huawei.com> --- src/qemu/qemu_migration.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c678ba7..75c77ae 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3723,8 +3723,10 @@ qemuMigrationRun(virQEMUDriverPtr driver, * confirm3 step, but need to release the lock state */ if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) { - if (qemuMigrationSetOffline(driver, vm) < 0) + if (qemuMigrationSetOffline(driver, vm) < 0) { + priv->job.current->type = VIR_DOMAIN_JOB_FAILED; goto cleanup; + } } ret = 0; @@ -3748,6 +3750,9 @@ qemuMigrationRun(virQEMUDriverPtr driver, qemuDomainJobInfoUpdateDowntime(priv->job.completed); } + if (priv->job.current->type == VIR_DOMAIN_JOB_UNBOUNDED) + priv->job.current->type = VIR_DOMAIN_JOB_FAILED; + cookieFlags |= QEMU_MIGRATION_COOKIE_NETWORK | QEMU_MIGRATION_COOKIE_STATS; if (flags & VIR_MIGRATE_PERSIST_DEST) -- 1.7.12.4

On Mon, Dec 01, 2014 at 03:05:31PM +0800, Wang Rui wrote:
In qemuMigrationRun the jobinfo type won't be updated until qemuMigrationWaitForCompletion. If migration is failed or cancelled before that(such as in qemuMigrationDriveMirror), we can't get the right jobinfo type. The following patches fix it.
diff to v1: Reword commit message to clarify why we can't use qemuMigrationUpdateJobStatus.
Wang Rui (2): qemu: set jobinfo type to CANCELLED if migration is cancelled in all conditions qemu: set jobinfo type to FAILED if job is failed in qemuMigrationRun
src/qemu/qemu_migration.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
-- 1.7.12.4
ACK && pushed Martin
participants (2)
-
Martin Kletzander
-
Wang Rui