qemu: introduce migrating job status

Instead of checking stat.status let's set status to migrating
as soon as migrate command is send (waiting for completion
is a good place too).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Nikolay Shirokovskiy 2017-09-01 09:49:28 +03:00 committed by Jiri Denemark
parent b6868c3cdd
commit 5a274d4fdc
4 changed files with 12 additions and 3 deletions

View File

@ -420,6 +420,7 @@ qemuDomainJobStatusToType(qemuDomainJobStatus status)
break; break;
case QEMU_DOMAIN_JOB_STATUS_ACTIVE: case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
case QEMU_DOMAIN_JOB_STATUS_POSTCOPY: case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
return VIR_DOMAIN_JOB_UNBOUNDED; return VIR_DOMAIN_JOB_UNBOUNDED;

View File

@ -102,6 +102,7 @@ VIR_ENUM_DECL(qemuDomainAsyncJob)
typedef enum { typedef enum {
QEMU_DOMAIN_JOB_STATUS_NONE = 0, QEMU_DOMAIN_JOB_STATUS_NONE = 0,
QEMU_DOMAIN_JOB_STATUS_ACTIVE, QEMU_DOMAIN_JOB_STATUS_ACTIVE,
QEMU_DOMAIN_JOB_STATUS_MIGRATING,
QEMU_DOMAIN_JOB_STATUS_POSTCOPY, QEMU_DOMAIN_JOB_STATUS_POSTCOPY,
QEMU_DOMAIN_JOB_STATUS_COMPLETED, QEMU_DOMAIN_JOB_STATUS_COMPLETED,
QEMU_DOMAIN_JOB_STATUS_FAILED, QEMU_DOMAIN_JOB_STATUS_FAILED,

View File

@ -12993,7 +12993,8 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
} }
/* Do not ask QEMU if migration is not even running yet */ /* Do not ask QEMU if migration is not even running yet */
if (!priv->job.current || !priv->job.current->stats.status) if (!priv->job.current ||
priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE)
fetch = false; fetch = false;
if (fetch && qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) if (fetch && qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
@ -13013,6 +13014,7 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
*jobInfo = *priv->job.current; *jobInfo = *priv->job.current;
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE || if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) { jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
if (fetch && if (fetch &&
qemuMigrationFetchStats(driver, vm, QEMU_ASYNC_JOB_NONE, jobInfo) < 0) qemuMigrationFetchStats(driver, vm, QEMU_ASYNC_JOB_NONE, jobInfo) < 0)

View File

@ -1451,6 +1451,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
case QEMU_DOMAIN_JOB_STATUS_COMPLETED: case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
case QEMU_DOMAIN_JOB_STATUS_ACTIVE: case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
case QEMU_DOMAIN_JOB_STATUS_MIGRATING:
case QEMU_DOMAIN_JOB_STATUS_POSTCOPY: case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
break; break;
} }
@ -1519,7 +1520,8 @@ qemuMigrationCompleted(virQEMUDriverPtr driver,
return 0; return 0;
error: error:
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE || /* state can not be active at this point */
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) { jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
/* The migration was aborted by us rather than QEMU itself. */ /* The migration was aborted by us rather than QEMU itself. */
jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED; jobInfo->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
@ -1548,6 +1550,8 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT); bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
int rv; int rv;
jobInfo->status = QEMU_DOMAIN_JOB_STATUS_MIGRATING;
while ((rv = qemuMigrationCompleted(driver, vm, asyncJob, while ((rv = qemuMigrationCompleted(driver, vm, asyncJob,
dconn, flags)) != 1) { dconn, flags)) != 1) {
if (rv < 0) if (rv < 0)
@ -3866,7 +3870,8 @@ qemuMigrationRun(virQEMUDriverPtr driver,
ignore_value(virTimeMillisNow(&priv->job.completed->sent)); ignore_value(virTimeMillisNow(&priv->job.completed->sent));
} }
if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE) if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING)
priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_FAILED; priv->job.current->status = QEMU_DOMAIN_JOB_STATUS_FAILED;
cookieFlags |= QEMU_MIGRATION_COOKIE_NETWORK | cookieFlags |= QEMU_MIGRATION_COOKIE_NETWORK |