Struct virDomainJobData is meant for statistics for async jobs.
It was used to keep track of only two attributes, one of which is
also in the generalized virDomainJobObj ("started") and one which
is always set to the same value, if any job is active
("jobType").
This patch removes usage & allocation of virDomainJobData
structure and rewrites libxlDomainJobUpdateTime() into more
suitable libxlDomainJobGetTimeElapsed().
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/libxl/libxl_domain.c | 16 ++++++----------
src/libxl/libxl_domain.h | 4 ++--
src/libxl/libxl_driver.c | 16 ++++++++--------
3 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 52e0aa1e60..6695ec670e 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -81,8 +81,7 @@ libxlDomainObjBeginJob(libxlDriverPrivate *driver G_GNUC_UNUSED,
VIR_DEBUG("Starting job: %s", virDomainJobTypeToString(job));
priv->job.active = job;
priv->job.owner = virThreadSelfID();
- priv->job.current->started = now;
- priv->job.current->jobType = VIR_DOMAIN_JOB_UNBOUNDED;
+ priv->job.started = now;
return 0;
@@ -129,23 +128,22 @@ libxlDomainObjEndJob(libxlDriverPrivate *driver G_GNUC_UNUSED,
}
int
-libxlDomainJobUpdateTime(virDomainJobObj *job)
+libxlDomainJobGetTimeElapsed(virDomainJobObj *job, unsigned long long *timeElapsed)
{
- virDomainJobData *jobData = job->current;
unsigned long long now;
- if (!jobData->started)
+ if (!job->started)
return 0;
if (virTimeMillisNow(&now) < 0)
return -1;
- if (now < jobData->started) {
- jobData->started = 0;
+ if (now < job->started) {
+ job->started = 0;
return 0;
}
- jobData->timeElapsed = now - jobData->started;
+ *timeElapsed = now - job->started;
return 0;
}
@@ -167,8 +165,6 @@ libxlDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED)
return NULL;
}
- priv->job.current = virDomainJobDataInit(NULL);
-
return priv;
}
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 5843a4921f..8ad56f1e88 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -62,8 +62,8 @@ libxlDomainObjEndJob(libxlDriverPrivate *driver,
virDomainObj *obj);
int
-libxlDomainJobUpdateTime(virDomainJobObj *job)
- G_GNUC_WARN_UNUSED_RESULT;
+libxlDomainJobGetTimeElapsed(virDomainJobObj *job,
+ unsigned long long *timeElapsed);
char *
libxlDomainManagedSavePath(libxlDriverPrivate *driver,
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index f980039165..ff6c2f6506 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -5207,6 +5207,7 @@ libxlDomainGetJobInfo(virDomainPtr dom,
libxlDomainObjPrivate *priv;
virDomainObj *vm;
int ret = -1;
+ unsigned long long timeElapsed = 0;
if (!(vm = libxlDomObjFromDomain(dom)))
goto cleanup;
@@ -5225,14 +5226,14 @@ libxlDomainGetJobInfo(virDomainPtr dom,
/* In libxl we don't have an estimated completion time
* thus we always set to unbounded and update time
* for the active job. */
- if (libxlDomainJobUpdateTime(&priv->job) < 0)
+ if (libxlDomainJobGetTimeElapsed(&priv->job, &timeElapsed) < 0)
goto cleanup;
/* setting only these two attributes is enough because libxl never sets
* anything else */
memset(info, 0, sizeof(*info));
- info->type = priv->job.current->jobType;
- info->timeElapsed = priv->job.current->timeElapsed;
+ info->type = VIR_DOMAIN_JOB_UNBOUNDED;
+ info->timeElapsed = timeElapsed;
ret = 0;
cleanup:
@@ -5249,9 +5250,9 @@ libxlDomainGetJobStats(virDomainPtr dom,
{
libxlDomainObjPrivate *priv;
virDomainObj *vm;
- virDomainJobData *jobData;
int ret = -1;
int maxparams = 0;
+ unsigned long long timeElapsed = 0;
/* VIR_DOMAIN_JOB_STATS_COMPLETED not supported yet */
virCheckFlags(0, -1);
@@ -5263,7 +5264,6 @@ libxlDomainGetJobStats(virDomainPtr dom,
goto cleanup;
priv = vm->privateData;
- jobData = priv->job.current;
if (!priv->job.active) {
*type = VIR_DOMAIN_JOB_NONE;
*params = NULL;
@@ -5275,15 +5275,15 @@ libxlDomainGetJobStats(virDomainPtr dom,
/* In libxl we don't have an estimated completion time
* thus we always set to unbounded and update time
* for the active job. */
- if (libxlDomainJobUpdateTime(&priv->job) < 0)
+ if (libxlDomainJobGetTimeElapsed(&priv->job, &timeElapsed) < 0)
goto cleanup;
if (virTypedParamsAddULLong(params, nparams, &maxparams,
VIR_DOMAIN_JOB_TIME_ELAPSED,
- jobData->timeElapsed) < 0)
+ timeElapsed) < 0)
goto cleanup;
- *type = jobData->jobType;
+ *type = VIR_DOMAIN_JOB_UNBOUNDED;
ret = 0;
cleanup:
--
2.37.2