Add an API to allow fetching the memory only dump statistics
for a job via the qemuDomainGetJobInfo API.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_domain.c | 50 ++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_driver.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 106 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 57dd412fe..3ceba67ff 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -473,6 +473,11 @@ qemuDomainJobInfoToInfo(qemuDomainJobInfoPtr jobInfo,
break;
case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP:
+ info->memTotal = jobInfo->s.dumpStats.total;
+ info->memProcessed = jobInfo->s.dumpStats.completed;
+ info->memRemaining = info->memTotal - info->memProcessed;
+ break;
+
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
case QEMU_DOMAIN_JOB_STATS_TYPE_LAST:
break;
@@ -654,6 +659,49 @@ qemuDomainMigrationJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
}
+static int
+qemuDomainDumpJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
+ int *type,
+ virTypedParameterPtr *params,
+ int *nparams)
+{
+ qemuMonitorDumpStats *stats = &jobInfo->s.dumpStats;
+ 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
qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
int *type,
@@ -666,6 +714,8 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
return qemuDomainMigrationJobInfoToParams(jobInfo, type, params, nparams);
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_LAST:
break;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ed1af55e3..f7afa11b2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13192,6 +13192,57 @@ qemuDomainGetJobInfoMigrationStats(virQEMUDriverPtr driver,
static int
+qemuDomainGetJobInfoDumpStats(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ qemuDomainJobInfoPtr jobInfo)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ qemuMonitorDumpStats stats;
+ 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->s.dumpStats = stats;
+
+ if (qemuDomainJobInfoUpdateTime(jobInfo) < 0)
+ return -1;
+
+ switch (jobInfo->s.dumpStats.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->s.dumpStats.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->s.dumpStats.completed,
+ jobInfo->s.dumpStats.total -
+ jobInfo->s.dumpStats.completed);
+ break;
+
+ case QEMU_MONITOR_DUMP_STATUS_COMPLETED:
+ jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
+ VIR_DEBUG("dump completed, bytes written='%llu'",
+ jobInfo->s.dumpStats.completed);
+ break;
+ }
+
+ return 0;
+}
+
+
+static int
qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
virDomainObjPtr vm,
bool completed,
@@ -13241,6 +13292,11 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
break;
case QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP:
+ if (qemuDomainGetJobInfoDumpStats(driver, vm, jobInfo) < 0)
+ goto cleanup;
+ ret = 0;
+ break;
+
case QEMU_DOMAIN_JOB_STATS_TYPE_NONE:
case QEMU_DOMAIN_JOB_STATS_TYPE_LAST:
break;
--
2.13.6