mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu: Convert jobInfo stats into a union
Convert the stats field in _qemuDomainJobInfo to be a union. This will allow for the collection of various different types of stats in the same field. When starting the async job that will end up being used for stats, set the @statsType value appropriately. The @mirrorStats are special and are used with stats.mig in order to generate the returned job stats for a migration. Using the NONE should avoid the possibility that some random async job would try to return stats for migration even though a migration is not in progress. For now a migration and a save job will use the same statsType Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
cb775a51a0
commit
93412bb827
@ -408,8 +408,8 @@ qemuDomainJobInfoUpdateDowntime(qemuDomainJobInfoPtr jobInfo)
|
||||
return 0;
|
||||
}
|
||||
|
||||
jobInfo->stats.downtime = now - jobInfo->stopped;
|
||||
jobInfo->stats.downtime_set = true;
|
||||
jobInfo->stats.mig.downtime = now - jobInfo->stopped;
|
||||
jobInfo->stats.mig.downtime_set = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -447,17 +447,23 @@ qemuDomainJobInfoToInfo(qemuDomainJobInfoPtr jobInfo,
|
||||
info->type = qemuDomainJobStatusToType(jobInfo->status);
|
||||
info->timeElapsed = jobInfo->timeElapsed;
|
||||
|
||||
info->memTotal = jobInfo->stats.ram_total;
|
||||
info->memRemaining = jobInfo->stats.ram_remaining;
|
||||
info->memProcessed = jobInfo->stats.ram_transferred;
|
||||
switch (jobInfo->statsType) {
|
||||
case QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION:
|
||||
info->memTotal = jobInfo->stats.mig.ram_total;
|
||||
info->memRemaining = jobInfo->stats.mig.ram_remaining;
|
||||
info->memProcessed = jobInfo->stats.mig.ram_transferred;
|
||||
info->fileTotal = jobInfo->stats.mig.disk_total +
|
||||
jobInfo->mirrorStats.total;
|
||||
info->fileRemaining = jobInfo->stats.mig.disk_remaining +
|
||||
(jobInfo->mirrorStats.total -
|
||||
jobInfo->mirrorStats.transferred);
|
||||
info->fileProcessed = jobInfo->stats.mig.disk_transferred +
|
||||
jobInfo->mirrorStats.transferred;
|
||||
break;
|
||||
|
||||
info->fileTotal = jobInfo->stats.disk_total +
|
||||
jobInfo->mirrorStats.total;
|
||||
info->fileRemaining = jobInfo->stats.disk_remaining +
|
||||
(jobInfo->mirrorStats.total -
|
||||
jobInfo->mirrorStats.transferred);
|
||||
info->fileProcessed = jobInfo->stats.disk_transferred +
|
||||
jobInfo->mirrorStats.transferred;
|
||||
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
info->dataTotal = info->memTotal + info->fileTotal;
|
||||
info->dataRemaining = info->memRemaining + info->fileRemaining;
|
||||
@ -466,13 +472,14 @@ qemuDomainJobInfoToInfo(qemuDomainJobInfoPtr jobInfo,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
||||
int *type,
|
||||
virTypedParameterPtr *params,
|
||||
int *nparams)
|
||||
|
||||
static int
|
||||
qemuDomainMigrationJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
||||
int *type,
|
||||
virTypedParameterPtr *params,
|
||||
int *nparams)
|
||||
{
|
||||
qemuMonitorMigrationStats *stats = &jobInfo->stats;
|
||||
qemuMonitorMigrationStats *stats = &jobInfo->stats.mig;
|
||||
qemuDomainMirrorStatsPtr mirrorStats = &jobInfo->mirrorStats;
|
||||
virTypedParameterPtr par = NULL;
|
||||
int maxpar = 0;
|
||||
@ -634,6 +641,24 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
||||
int *type,
|
||||
virTypedParameterPtr *params,
|
||||
int *nparams)
|
||||
{
|
||||
switch (jobInfo->statsType) {
|
||||
case QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION:
|
||||
return qemuDomainMigrationJobInfoToParams(jobInfo, type, params, nparams);
|
||||
|
||||
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* qemuDomainGetMasterKeyFilePath:
|
||||
* @libDir: Directory path to domain lib files
|
||||
*
|
||||
|
@ -110,6 +110,11 @@ typedef enum {
|
||||
QEMU_DOMAIN_JOB_STATUS_CANCELED,
|
||||
} qemuDomainJobStatus;
|
||||
|
||||
typedef enum {
|
||||
QEMU_DOMAIN_JOB_STATS_TYPE_NONE = 0,
|
||||
QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION,
|
||||
} qemuDomainJobStatsType;
|
||||
|
||||
|
||||
typedef struct _qemuDomainMirrorStats qemuDomainMirrorStats;
|
||||
typedef qemuDomainMirrorStats *qemuDomainMirrorStatsPtr;
|
||||
@ -138,7 +143,10 @@ struct _qemuDomainJobInfo {
|
||||
destination. */
|
||||
bool timeDeltaSet;
|
||||
/* Raw values from QEMU */
|
||||
qemuMonitorMigrationStats stats;
|
||||
qemuDomainJobStatsType statsType;
|
||||
union {
|
||||
qemuMonitorMigrationStats mig;
|
||||
} stats;
|
||||
qemuDomainMirrorStats mirrorStats;
|
||||
};
|
||||
|
||||
|
@ -3386,6 +3386,8 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
|
||||
goto endjob;
|
||||
}
|
||||
|
||||
priv->job.current->statsType = QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION;
|
||||
|
||||
/* Pause */
|
||||
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
|
||||
was_running = true;
|
||||
@ -3937,6 +3939,9 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom,
|
||||
goto endjob;
|
||||
}
|
||||
|
||||
priv = vm->privateData;
|
||||
priv->job.current->statsType = QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION;
|
||||
|
||||
/* Migrate will always stop the VM, so the resume condition is
|
||||
independent of whether the stop command is issued. */
|
||||
resume = virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING;
|
||||
@ -3972,7 +3977,6 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom,
|
||||
} else if (((resume && paused) || (flags & VIR_DUMP_RESET)) &&
|
||||
virDomainObjIsActive(vm)) {
|
||||
if ((ret == 0) && (flags & VIR_DUMP_RESET)) {
|
||||
priv = vm->privateData;
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
ret = qemuMonitorSystemReset(priv->mon);
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
@ -13220,8 +13224,15 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
|
||||
}
|
||||
*jobInfo = *priv->job.current;
|
||||
|
||||
if (qemuDomainGetJobInfoMigrationStats(driver, vm, jobInfo) < 0)
|
||||
goto cleanup;
|
||||
switch (jobInfo->statsType) {
|
||||
case QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION:
|
||||
if (qemuDomainGetJobInfoMigrationStats(driver, vm, jobInfo) < 0)
|
||||
goto cleanup;
|
||||
break;
|
||||
|
||||
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
@ -1368,7 +1368,7 @@ qemuMigrationWaitForSpice(virDomainObjPtr vm)
|
||||
static void
|
||||
qemuMigrationUpdateJobType(qemuDomainJobInfoPtr jobInfo)
|
||||
{
|
||||
switch ((qemuMonitorMigrationStatus) jobInfo->stats.status) {
|
||||
switch ((qemuMonitorMigrationStatus) jobInfo->stats.mig.status) {
|
||||
case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY:
|
||||
jobInfo->status = QEMU_DOMAIN_JOB_STATUS_POSTCOPY;
|
||||
break;
|
||||
@ -1425,7 +1425,7 @@ qemuMigrationFetchStats(virQEMUDriverPtr driver,
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0)
|
||||
return -1;
|
||||
|
||||
jobInfo->stats = stats;
|
||||
jobInfo->stats.mig = stats;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1461,7 +1461,7 @@ qemuMigrationCheckJobStatus(virQEMUDriverPtr driver,
|
||||
int ret = -1;
|
||||
|
||||
if (!events ||
|
||||
jobInfo->stats.status == QEMU_MONITOR_MIGRATION_STATUS_ERROR) {
|
||||
jobInfo->stats.mig.status == QEMU_MONITOR_MIGRATION_STATUS_ERROR) {
|
||||
if (qemuMigrationFetchStats(driver, vm, asyncJob, jobInfo, &error) < 0)
|
||||
return -1;
|
||||
}
|
||||
@ -3254,8 +3254,8 @@ qemuMigrationConfirmPhase(virQEMUDriverPtr driver,
|
||||
qemuDomainJobInfoUpdateTime(jobInfo);
|
||||
jobInfo->timeDeltaSet = mig->jobInfo->timeDeltaSet;
|
||||
jobInfo->timeDelta = mig->jobInfo->timeDelta;
|
||||
jobInfo->stats.downtime_set = mig->jobInfo->stats.downtime_set;
|
||||
jobInfo->stats.downtime = mig->jobInfo->stats.downtime;
|
||||
jobInfo->stats.mig.downtime_set = mig->jobInfo->stats.mig.downtime_set;
|
||||
jobInfo->stats.mig.downtime = mig->jobInfo->stats.mig.downtime;
|
||||
}
|
||||
|
||||
if (flags & VIR_MIGRATE_OFFLINE)
|
||||
@ -5756,6 +5756,7 @@ qemuMigrationJobStart(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
qemuDomainAsyncJob job)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
virDomainJobOperation op;
|
||||
unsigned long long mask;
|
||||
|
||||
@ -5772,6 +5773,8 @@ qemuMigrationJobStart(virQEMUDriverPtr driver,
|
||||
if (qemuDomainObjBeginAsyncJob(driver, vm, job, op) < 0)
|
||||
return -1;
|
||||
|
||||
priv->job.current->statsType = QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION;
|
||||
|
||||
qemuDomainObjSetAsyncJobMask(vm, mask);
|
||||
return 0;
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ static void
|
||||
qemuMigrationCookieStatisticsXMLFormat(virBufferPtr buf,
|
||||
qemuDomainJobInfoPtr jobInfo)
|
||||
{
|
||||
qemuMonitorMigrationStats *stats = &jobInfo->stats;
|
||||
qemuMonitorMigrationStats *stats = &jobInfo->stats.mig;
|
||||
|
||||
virBufferAddLit(buf, "<statistics>\n");
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
@ -993,7 +993,7 @@ qemuMigrationCookieStatisticsXMLParse(xmlXPathContextPtr ctxt)
|
||||
if (VIR_ALLOC(jobInfo) < 0)
|
||||
goto cleanup;
|
||||
|
||||
stats = &jobInfo->stats;
|
||||
stats = &jobInfo->stats.mig;
|
||||
jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
|
||||
|
||||
virXPathULongLong("string(./started[1])", ctxt, &jobInfo->started);
|
||||
|
@ -1639,7 +1639,7 @@ qemuProcessHandleMigrationStatus(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
priv->job.current->stats.status = status;
|
||||
priv->job.current->stats.mig.status = status;
|
||||
virDomainObjBroadcast(vm);
|
||||
|
||||
cleanup:
|
||||
|
Loading…
Reference in New Issue
Block a user