mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: refactor fetching migration stats
qemuMigrationFetchJobStatus is rather inconvinient. Some of its callers don't need status to be updated, some don't need to update elapsed time right away. So let's update status or elapsed time in callers instead. This patch drops updating job status on getting job stats by client. This way we will not provide status 'completed' while it is not yet updated by migration routine. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
e796747092
commit
6a2a80c653
@ -13020,15 +13020,16 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
|
if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
|
||||||
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
|
jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
|
||||||
if (fetch)
|
if (fetch &&
|
||||||
ret = qemuMigrationFetchJobStatus(driver, vm, QEMU_ASYNC_JOB_NONE,
|
qemuMigrationFetchStats(driver, vm, QEMU_ASYNC_JOB_NONE, jobInfo) < 0)
|
||||||
jobInfo);
|
goto cleanup;
|
||||||
else
|
|
||||||
ret = qemuDomainJobInfoUpdateTime(jobInfo);
|
if (qemuDomainJobInfoUpdateTime(jobInfo) < 0)
|
||||||
} else {
|
goto cleanup;
|
||||||
ret = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (fetch)
|
if (fetch)
|
||||||
qemuDomainObjEndJob(driver, vm);
|
qemuDomainObjEndJob(driver, vm);
|
||||||
|
@ -1376,24 +1376,26 @@ qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuMigrationFetchJobStatus(virQEMUDriverPtr driver,
|
qemuMigrationFetchStats(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
qemuDomainAsyncJob asyncJob,
|
qemuDomainAsyncJob asyncJob,
|
||||||
qemuDomainJobInfoPtr jobInfo)
|
qemuDomainJobInfoPtr jobInfo)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
qemuMonitorMigrationStats stats;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rv = qemuMonitorGetMigrationStats(priv->mon, &jobInfo->stats);
|
rv = qemuMonitorGetMigrationStats(priv->mon, &stats);
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
qemuMigrationUpdateJobType(jobInfo);
|
jobInfo->stats = stats;
|
||||||
return qemuDomainJobInfoUpdateTime(jobInfo);
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1415,23 +1417,6 @@ qemuMigrationJobName(virDomainObjPtr vm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
qemuMigrationUpdateJobStatus(virQEMUDriverPtr driver,
|
|
||||||
virDomainObjPtr vm,
|
|
||||||
qemuDomainAsyncJob asyncJob)
|
|
||||||
{
|
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
||||||
qemuDomainJobInfoPtr jobInfo = priv->job.current;
|
|
||||||
qemuDomainJobInfo newInfo = *jobInfo;
|
|
||||||
|
|
||||||
if (qemuMigrationFetchJobStatus(driver, vm, asyncJob, &newInfo) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
*jobInfo = newInfo;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
|
qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
@ -1442,11 +1427,12 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
|
bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
|
||||||
|
|
||||||
if (events)
|
if (!events &&
|
||||||
qemuMigrationUpdateJobType(jobInfo);
|
qemuMigrationFetchStats(driver, vm, asyncJob, jobInfo) < 0)
|
||||||
else if (qemuMigrationUpdateJobStatus(driver, vm, asyncJob) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
qemuMigrationUpdateJobType(jobInfo);
|
||||||
|
|
||||||
switch (jobInfo->status) {
|
switch (jobInfo->status) {
|
||||||
case QEMU_DOMAIN_JOB_STATUS_NONE:
|
case QEMU_DOMAIN_JOB_STATUS_NONE:
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED, _("%s: %s"),
|
virReportError(VIR_ERR_OPERATION_FAILED, _("%s: %s"),
|
||||||
@ -1584,8 +1570,9 @@ qemuMigrationWaitForCompletion(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (events)
|
if (events)
|
||||||
ignore_value(qemuMigrationUpdateJobStatus(driver, vm, asyncJob));
|
ignore_value(qemuMigrationFetchStats(driver, vm, asyncJob, jobInfo));
|
||||||
|
|
||||||
|
qemuDomainJobInfoUpdateTime(jobInfo);
|
||||||
qemuDomainJobInfoUpdateDowntime(jobInfo);
|
qemuDomainJobInfoUpdateDowntime(jobInfo);
|
||||||
VIR_FREE(priv->job.completed);
|
VIR_FREE(priv->job.completed);
|
||||||
if (VIR_ALLOC(priv->job.completed) == 0)
|
if (VIR_ALLOC(priv->job.completed) == 0)
|
||||||
@ -3176,9 +3163,8 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
|
|||||||
*/
|
*/
|
||||||
if (virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED &&
|
if (virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED &&
|
||||||
reason == VIR_DOMAIN_PAUSED_POSTCOPY &&
|
reason == VIR_DOMAIN_PAUSED_POSTCOPY &&
|
||||||
qemuMigrationFetchJobStatus(driver, vm,
|
qemuMigrationFetchStats(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
|
||||||
QEMU_ASYNC_JOB_MIGRATION_OUT,
|
jobInfo) < 0)
|
||||||
jobInfo) < 0)
|
|
||||||
VIR_WARN("Could not refresh migration statistics");
|
VIR_WARN("Could not refresh migration statistics");
|
||||||
|
|
||||||
qemuDomainJobInfoUpdateTime(jobInfo);
|
qemuDomainJobInfoUpdateTime(jobInfo);
|
||||||
|
@ -279,10 +279,10 @@ qemuMigrationCancel(virQEMUDriverPtr driver,
|
|||||||
virDomainObjPtr vm);
|
virDomainObjPtr vm);
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuMigrationFetchJobStatus(virQEMUDriverPtr driver,
|
qemuMigrationFetchStats(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
qemuDomainAsyncJob asyncJob,
|
qemuDomainAsyncJob asyncJob,
|
||||||
qemuDomainJobInfoPtr jobInfo);
|
qemuDomainJobInfoPtr jobInfo);
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuMigrationErrorInit(virQEMUDriverPtr driver);
|
qemuMigrationErrorInit(virQEMUDriverPtr driver);
|
||||||
|
Loading…
Reference in New Issue
Block a user