This transition will make it easier for me to generalize jobs in
the future as they will always use virDomainJobData and
virDomainJobInfo will be only used in the public api..
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/libxl/libxl_domain.c | 10 +++++-----
src/libxl/libxl_domain.h | 3 ++-
src/libxl/libxl_driver.c | 14 +++++++++-----
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index b995f20a64..c91e531a9a 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -60,7 +60,7 @@ libxlDomainObjInitJob(libxlDomainObjPrivate *priv)
if (virCondInit(&priv->job.cond) < 0)
return -1;
- priv->job.current = g_new0(virDomainJobInfo, 1);
+ priv->job.current = virDomainJobDataInit(NULL);
return 0;
}
@@ -78,7 +78,7 @@ static void
libxlDomainObjFreeJob(libxlDomainObjPrivate *priv)
{
ignore_value(virCondDestroy(&priv->job.cond));
- VIR_FREE(priv->job.current);
+ virDomainJobDataFree(priv->job.current);
}
/* Give up waiting for mutex after 30 seconds */
@@ -119,7 +119,7 @@ libxlDomainObjBeginJob(libxlDriverPrivate *driver G_GNUC_UNUSED,
priv->job.active = job;
priv->job.owner = virThreadSelfID();
priv->job.started = now;
- priv->job.current->type = VIR_DOMAIN_JOB_UNBOUNDED;
+ priv->job.current->jobType = VIR_DOMAIN_JOB_UNBOUNDED;
return 0;
@@ -168,7 +168,7 @@ libxlDomainObjEndJob(libxlDriverPrivate *driver G_GNUC_UNUSED,
int
libxlDomainJobUpdateTime(struct libxlDomainJobObj *job)
{
- virDomainJobInfoPtr jobInfo = job->current;
+ virDomainJobData *jobData = job->current;
unsigned long long now;
if (!job->started)
@@ -182,7 +182,7 @@ libxlDomainJobUpdateTime(struct libxlDomainJobObj *job)
return 0;
}
- jobInfo->timeElapsed = now - job->started;
+ jobData->timeElapsed = now - job->started;
return 0;
}
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 981bfc2bca..475e4a6933 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -26,6 +26,7 @@
#include "libxl_conf.h"
#include "virchrdev.h"
#include "virenum.h"
+#include "domain_job.h"
/* Only 1 job is allowed at any time
* A job includes *all* libxl.so api, even those just querying
@@ -46,7 +47,7 @@ struct libxlDomainJobObj {
enum libxlDomainJob active; /* Currently running job */
int owner; /* Thread which set current job */
unsigned long long started; /* When the job started */
- virDomainJobInfoPtr current; /* Statistics for the current job */
+ virDomainJobData *current; /* Statistics for the current job */
};
typedef struct _libxlDomainObjPrivate libxlDomainObjPrivate;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 97965aaf1d..4c61d330ed 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -5235,7 +5235,11 @@ libxlDomainGetJobInfo(virDomainPtr dom,
if (libxlDomainJobUpdateTime(&priv->job) < 0)
goto cleanup;
- memcpy(info, priv->job.current, sizeof(virDomainJobInfo));
+ /* 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;
ret = 0;
cleanup:
@@ -5252,7 +5256,7 @@ libxlDomainGetJobStats(virDomainPtr dom,
{
libxlDomainObjPrivate *priv;
virDomainObj *vm;
- virDomainJobInfoPtr jobInfo;
+ virDomainJobData *jobData;
int ret = -1;
int maxparams = 0;
@@ -5266,7 +5270,7 @@ libxlDomainGetJobStats(virDomainPtr dom,
goto cleanup;
priv = vm->privateData;
- jobInfo = priv->job.current;
+ jobData = priv->job.current;
if (!priv->job.active) {
*type = VIR_DOMAIN_JOB_NONE;
*params = NULL;
@@ -5283,10 +5287,10 @@ libxlDomainGetJobStats(virDomainPtr dom,
if (virTypedParamsAddULLong(params, nparams, &maxparams,
VIR_DOMAIN_JOB_TIME_ELAPSED,
- jobInfo->timeElapsed) < 0)
+ jobData->timeElapsed) < 0)
goto cleanup;
- *type = jobInfo->type;
+ *type = jobData->jobType;
ret = 0;
cleanup:
--
2.34.1