mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 12:35:20 +00:00
qemu: Introduce qemuDomainGetJobInfoDumpStats
Add an API to allow fetching the memory only dump statistics for a job via the qemuDomainGetJobInfo API. Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
88c2360753
commit
501e3c3c96
@ -470,6 +470,11 @@ qemuDomainJobInfoToInfo(qemuDomainJobInfoPtr jobInfo,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP:
|
case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP:
|
||||||
|
info->memTotal = jobInfo->stats.dump.total;
|
||||||
|
info->memProcessed = jobInfo->stats.dump.completed;
|
||||||
|
info->memRemaining = info->memTotal - info->memProcessed;
|
||||||
|
break;
|
||||||
|
|
||||||
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -656,6 +661,49 @@ qemuDomainMigrationJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainDumpJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
||||||
|
int *type,
|
||||||
|
virTypedParameterPtr *params,
|
||||||
|
int *nparams)
|
||||||
|
{
|
||||||
|
qemuMonitorDumpStats *stats = &jobInfo->stats.dump;
|
||||||
|
virTypedParameterPtr par = NULL;
|
||||||
|
int maxpar = 0;
|
||||||
|
int npar = 0;
|
||||||
|
|
||||||
|
if (virTypedParamsAddInt(&par, &npar, &maxpar,
|
||||||
|
VIR_DOMAIN_JOB_OPERATION,
|
||||||
|
jobInfo->operation) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (virTypedParamsAddULLong(&par, &npar, &maxpar,
|
||||||
|
VIR_DOMAIN_JOB_TIME_ELAPSED,
|
||||||
|
jobInfo->timeElapsed) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (virTypedParamsAddULLong(&par, &npar, &maxpar,
|
||||||
|
VIR_DOMAIN_JOB_MEMORY_TOTAL,
|
||||||
|
stats->total) < 0 ||
|
||||||
|
virTypedParamsAddULLong(&par, &npar, &maxpar,
|
||||||
|
VIR_DOMAIN_JOB_MEMORY_PROCESSED,
|
||||||
|
stats->completed) < 0 ||
|
||||||
|
virTypedParamsAddULLong(&par, &npar, &maxpar,
|
||||||
|
VIR_DOMAIN_JOB_MEMORY_REMAINING,
|
||||||
|
stats->total - stats->completed) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
*type = qemuDomainJobStatusToType(jobInfo->status);
|
||||||
|
*params = par;
|
||||||
|
*nparams = npar;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
virTypedParamsFree(par, npar);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
||||||
int *type,
|
int *type,
|
||||||
@ -668,6 +716,8 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
|
|||||||
return qemuDomainMigrationJobInfoToParams(jobInfo, type, params, nparams);
|
return qemuDomainMigrationJobInfoToParams(jobInfo, type, params, nparams);
|
||||||
|
|
||||||
case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP:
|
case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP:
|
||||||
|
return qemuDomainDumpJobInfoToParams(jobInfo, type, params, nparams);
|
||||||
|
|
||||||
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -13184,6 +13184,57 @@ qemuDomainGetJobInfoMigrationStats(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainGetJobInfoDumpStats(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm,
|
||||||
|
qemuDomainJobInfoPtr jobInfo)
|
||||||
|
{
|
||||||
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
qemuMonitorDumpStats stats = { 0 };
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
rc = qemuMonitorQueryDump(priv->mon, &stats);
|
||||||
|
|
||||||
|
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
jobInfo->stats.dump = stats;
|
||||||
|
|
||||||
|
if (qemuDomainJobInfoUpdateTime(jobInfo) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
switch (jobInfo->stats.dump.status) {
|
||||||
|
case QEMU_MONITOR_DUMP_STATUS_NONE:
|
||||||
|
case QEMU_MONITOR_DUMP_STATUS_FAILED:
|
||||||
|
case QEMU_MONITOR_DUMP_STATUS_LAST:
|
||||||
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
|
_("dump query failed, status=%d"),
|
||||||
|
jobInfo->stats.dump.status);
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QEMU_MONITOR_DUMP_STATUS_ACTIVE:
|
||||||
|
jobInfo->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
|
||||||
|
VIR_DEBUG("dump active, bytes written='%llu' remaining='%llu'",
|
||||||
|
jobInfo->stats.dump.completed,
|
||||||
|
jobInfo->stats.dump.total -
|
||||||
|
jobInfo->stats.dump.completed);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QEMU_MONITOR_DUMP_STATUS_COMPLETED:
|
||||||
|
jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
|
||||||
|
VIR_DEBUG("dump completed, bytes written='%llu'",
|
||||||
|
jobInfo->stats.dump.completed);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
|
qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
@ -13233,6 +13284,10 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP:
|
case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP:
|
||||||
|
if (qemuDomainGetJobInfoDumpStats(driver, vm, jobInfo) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
break;
|
||||||
|
|
||||||
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user