[PATCH] libxl: remove redundant variable from libxlDomainJobObj

Kristina Hanicova posted 1 patch 2 years, 1 month ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/cd9b777c3d2b3eebb045cb986031f585fda82b5e.1646045319.git.khanicov@redhat.com
src/libxl/libxl_domain.c | 10 +++++-----
src/libxl/libxl_domain.h |  1 -
2 files changed, 5 insertions(+), 6 deletions(-)
[PATCH] libxl: remove redundant variable from libxlDomainJobObj
Posted by Kristina Hanicova 2 years, 1 month ago
It makes no sense to have 'started' variable in the
libxlDomainJobObj as the same one is already in virDomainJobData,
but never used.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
---
 src/libxl/libxl_domain.c | 10 +++++-----
 src/libxl/libxl_domain.h |  1 -
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index ee031267ca..205049f98a 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -118,7 +118,7 @@ libxlDomainObjBeginJob(libxlDriverPrivate *driver G_GNUC_UNUSED,
     VIR_DEBUG("Starting job: %s", libxlDomainJobTypeToString(job));
     priv->job.active = job;
     priv->job.owner = virThreadSelfID();
-    priv->job.started = now;
+    priv->job.current->started = now;
     priv->job.current->jobType = VIR_DOMAIN_JOB_UNBOUNDED;
 
     return 0;
@@ -171,18 +171,18 @@ libxlDomainJobUpdateTime(struct libxlDomainJobObj *job)
     virDomainJobData *jobData = job->current;
     unsigned long long now;
 
-    if (!job->started)
+    if (!jobData->started)
         return 0;
 
     if (virTimeMillisNow(&now) < 0)
         return -1;
 
-    if (now < job->started) {
-        job->started = 0;
+    if (now < jobData->started) {
+        jobData->started = 0;
         return 0;
     }
 
-    jobData->timeElapsed = now - job->started;
+    jobData->timeElapsed = now - jobData->started;
     return 0;
 }
 
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 475e4a6933..157f480b93 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -46,7 +46,6 @@ struct libxlDomainJobObj {
     virCond cond;                       /* Use to coordinate jobs */
     enum libxlDomainJob active;         /* Currently running job */
     int owner;                          /* Thread which set current job */
-    unsigned long long started;         /* When the job started */
     virDomainJobData *current;        /* Statistics for the current job */
 };
 
-- 
2.35.1
Re: [PATCH] libxl: remove redundant variable from libxlDomainJobObj
Posted by Michal Prívozník 2 years, 1 month ago
On 2/28/22 11:49, Kristina Hanicova wrote:
> It makes no sense to have 'started' variable in the
> libxlDomainJobObj as the same one is already in virDomainJobData,
> but never used.
> 
> Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
> ---
>  src/libxl/libxl_domain.c | 10 +++++-----
>  src/libxl/libxl_domain.h |  1 -
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

and pushed.

Another supporting argument is that even libxlDomainObjResetJob() does
not reset the job->started. After this patch, maybe it should reset
job->current?

Michal