Add an API to allow fetching the memory only dump statistics
for a job via the qemuDomainGetJobInfo API. This adds a new
statsType QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP and corresponding
data structure to the stats union in _qemuDomainJobInfo.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_domain.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_domain.h | 2 ++
src/qemu/qemu_driver.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 111 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4c91f6d5f..56aeaef36 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -475,6 +475,12 @@ qemuDomainJobInfoToInfo(qemuDomainJobInfoPtr jobInfo,
info->fileProcessed = jobInfo->s.migStats.disk_transferred;
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;
@@ -656,6 +662,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,
@@ -667,6 +716,9 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
case QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP:
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_domain.h b/src/qemu/qemu_domain.h
index c891a4e28..ce25d7b92 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -114,6 +114,7 @@ typedef enum {
QEMU_DOMAIN_JOB_STATS_TYPE_NONE = 0,
QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION,
QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP,
+ QEMU_DOMAIN_JOB_STATS_TYPE_MEMDUMP,
QEMU_DOMAIN_JOB_STATS_TYPE_LAST
} qemuDomainJobStatsType;
@@ -149,6 +150,7 @@ struct _qemuDomainJobInfo {
qemuDomainJobStatsType statsType;
union {
qemuMonitorMigrationStats migStats;
+ qemuMonitorDumpStats dumpStats;
} s;
qemuDomainMirrorStats mirrorStats;
};
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 113bd8480..96617c9dd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13191,6 +13191,57 @@ qemuDomainGetJobInfoMigrationStats(virQEMUDriverPtr driver,
static int
+qemuDomainGetJobInfoDumpStats(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ qemuDomainJobInfoPtr jobInfo)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ qemuMonitorDumpStatsPtr stats;
+
+ if (qemuDomainObjEnterMonitorAsync(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
+ return -1;
+
+ stats = qemuMonitorQueryDump(priv->mon);
+
+ if (qemuDomainObjExitMonitor(driver, vm) < 0 || stats == NULL)
+ return -1;
+
+ memcpy(&jobInfo->s.dumpStats, stats, sizeof(jobInfo->s.dumpStats));
+ qemuMonitorEventDumpStatsFree(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,
@@ -13239,6 +13290,12 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
ret = 0;
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