On Wed, Dec 28, 2016 at 17:39:12 +0300, Nikolay Shirokovskiy wrote:
Current code consults job.current->stats.status to check for
postcopy
state. First it is more correct to check for both job.current->status
and job.current->stats.status.code because on some paths on failures
we change only the former. Second if qemu supports migration events
then stats can change unexpectedly.
Let's introduce QEMU_DOMAIN_JOB_STATUS_POSTCOPY state for job.current->status.
This patch removes all state checking usage of stats except for
qemuDomainGetJobStatsInternal. This place will be handled separately.
---
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 5 +++--
src/qemu/qemu_migration.c | 18 +++++++++++-------
src/qemu/qemu_process.c | 4 ++--
5 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 3582151..952a933 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -393,6 +393,7 @@ qemuDomainJobStatusToType(qemuDomainJobStatus status)
case QEMU_DOMAIN_JOB_STATUS_NONE:
return VIR_DOMAIN_JOB_NONE;
case QEMU_DOMAIN_JOB_STATUS_ACTIVE:
+ case QEMU_DOMAIN_JOB_STATUS_POSTCOPY:
return VIR_DOMAIN_JOB_UNBOUNDED;
case QEMU_DOMAIN_JOB_STATUS_COMPLETED:
return VIR_DOMAIN_JOB_COMPLETED;
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index f257dc1..273145d 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -102,6 +102,7 @@ typedef enum {
QEMU_DOMAIN_JOB_STATUS_NONE = 0,
QEMU_DOMAIN_JOB_STATUS_ACTIVE,
QEMU_DOMAIN_JOB_STATUS_COMPLETED,
+ QEMU_DOMAIN_JOB_STATUS_POSTCOPY,
Adding this item above QEMU_DOMAIN_JOB_STATUS_COMPLETED would make more
sense.
QEMU_DOMAIN_JOB_STATUS_FAILED,
QEMU_DOMAIN_JOB_STATUS_CANCELED,
} qemuDomainJobStatus;
...
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index c5184b2..64e5b91 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2558,6 +2558,10 @@ qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
break;
+ case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY:
+ jobInfo->status = QEMU_DOMAIN_JOB_STATUS_POSTCOPY;
+ break;
+
This case would also better fit above the COMPLETED one.
case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE:
jobInfo->status = QEMU_DOMAIN_JOB_STATUS_NONE;
break;
Nice cleanup. ACK once enum items are reordered.
Jirka