mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
libxl: use virDomainJobData instead of virDomainJobInfo
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@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
0301db44e2
commit
65312001bd
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user