On Thu, Feb 01, 2018 at 18:24:39 -0500, John Ferlan wrote:
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;
This patch will be affected by the change of the union's name, so while
changing it, you could initialize stats with { 0 }.
Otherwise this looks OK.
Jirka