From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joao Martins Subject: [PATCH v2 8/8] libxl: implement virDomainGetJobStats Date: Tue, 10 Nov 2015 15:34:12 +0000 Message-ID: <1447169652-8950-9-git-send-email-joao.m.martins@oracle.com> References: <1447169652-8950-1-git-send-email-joao.m.martins@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1447169652-8950-1-git-send-email-joao.m.martins@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: libvir-list@redhat.com Cc: jfehlig@suse.com, Joao Martins , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Introduces support for domainGetJobStats which has the same info as domainGetJobInfo but in a slightly different format. Another difference is that virDomainGetJobStats can also retrieve info on the most recently completed job. Though so far this is only used in the source node to know if the migration has been completed. But because we don't support completed jobs we will deliver an error. Signed-off-by: Joao Martins --- Changes since v1: - Fixed indentation on libxlDomainGetJobStats() - s/estimed/estimated/g - Bump version to 1.2.22 --- src/libxl/libxl_driver.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index b0b6ea7..dda14c2 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5273,6 +5273,58 @@ libxlDomainGetJobInfo(virDomainPtr dom, return ret; } +static int +libxlDomainGetJobStats(virDomainPtr dom, + int *type, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + libxlDomainObjPrivatePtr priv; + virDomainObjPtr vm; + virDomainJobInfoPtr jobInfo; + int ret = -1; + int maxparams = 0; + + /* VIR_DOMAIN_JOB_STATS_COMPLETED not supported yet */ + virCheckFlags(0, -1); + + if (!(vm = libxlDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainGetJobStatsEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + priv = vm->privateData; + jobInfo = priv->job.current; + if (!priv->job.active) { + *type = VIR_DOMAIN_JOB_NONE; + *params = NULL; + *nparams = 0; + ret = 0; + goto cleanup; + } + + /* 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) + goto cleanup; + + if (virTypedParamsAddULLong(params, nparams, &maxparams, + VIR_DOMAIN_JOB_TIME_ELAPSED, + jobInfo->timeElapsed) < 0) + goto cleanup; + + *type = jobInfo->type; + ret = 0; + + cleanup: + if (vm) + virObjectUnlock(vm); + return ret; +} + #undef LIBXL_SET_MEMSTAT #define LIBXL_RECORD_UINT(error, key, value, ...) \ @@ -6134,6 +6186,7 @@ static virHypervisorDriver libxlHypervisorDriver = { .nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */ .nodeGetCellsFreeMemory = libxlNodeGetCellsFreeMemory, /* 1.1.1 */ .domainGetJobInfo = libxlDomainGetJobInfo, /* 1.2.22 */ + .domainGetJobStats = libxlDomainGetJobStats, /* 1.2.22 */ .domainBlockStats = libxlDomainBlockStats, /* 1.2.22 */ .domainBlockStatsFlags = libxlDomainBlockStatsFlags, /* 1.2.22 */ .domainInterfaceStats = libxlDomainInterfaceStats, /* 1.2.22 */ -- 2.1.4