ae23c9
From 5845c03f7bd9ad3759eb63977eecb7412f6250aa Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Tue, 26 Jun 2018 09:48:02 +0200
ae23c9
Subject: [PATCH 094/268] job: Add job_delete()
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20180626094856.6924-20-kwolf@redhat.com>
ae23c9
Patchwork-id: 81065
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 19/73] job: Add job_delete()
ae23c9
Bugzilla: 1513543
ae23c9
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Fam Zheng <famz@redhat.com>
ae23c9
ae23c9
This moves freeing the Job object and its fields from block_job_unref()
ae23c9
to job_delete().
ae23c9
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Reviewed-by: Max Reitz <mreitz@redhat.com>
ae23c9
Reviewed-by: John Snow <jsnow@redhat.com>
ae23c9
(cherry picked from commit fd61a701f1de8e4c1d89b3716ba9ca749cf5c724)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 blockjob.c         | 3 +--
ae23c9
 include/qemu/job.h | 3 +++
ae23c9
 job.c              | 6 ++++++
ae23c9
 3 files changed, 10 insertions(+), 2 deletions(-)
ae23c9
ae23c9
diff --git a/blockjob.c b/blockjob.c
ae23c9
index ea71ec0..430a67b 100644
ae23c9
--- a/blockjob.c
ae23c9
+++ b/blockjob.c
ae23c9
@@ -261,9 +261,8 @@ void block_job_unref(BlockJob *job)
ae23c9
                                         block_job_detach_aio_context, job);
ae23c9
         blk_unref(job->blk);
ae23c9
         error_free(job->blocker);
ae23c9
-        g_free(job->job.id);
ae23c9
         assert(!timer_pending(&job->sleep_timer));
ae23c9
-        g_free(job);
ae23c9
+        job_delete(&job->job);
ae23c9
     }
ae23c9
 }
ae23c9
 
ae23c9
diff --git a/include/qemu/job.h b/include/qemu/job.h
ae23c9
index 279ce68..43dc2e4 100644
ae23c9
--- a/include/qemu/job.h
ae23c9
+++ b/include/qemu/job.h
ae23c9
@@ -62,6 +62,9 @@ struct JobDriver {
ae23c9
  */
ae23c9
 void *job_create(const char *job_id, const JobDriver *driver, Error **errp);
ae23c9
 
ae23c9
+/** Frees the @job object. */
ae23c9
+void job_delete(Job *job);
ae23c9
+
ae23c9
 /** Returns the JobType of a given Job. */
ae23c9
 JobType job_type(const Job *job);
ae23c9
 
ae23c9
diff --git a/job.c b/job.c
ae23c9
index 83724a4..cfdd008 100644
ae23c9
--- a/job.c
ae23c9
+++ b/job.c
ae23c9
@@ -56,3 +56,9 @@ void *job_create(const char *job_id, const JobDriver *driver, Error **errp)
ae23c9
 
ae23c9
     return job;
ae23c9
 }
ae23c9
+
ae23c9
+void job_delete(Job *job)
ae23c9
+{
ae23c9
+    g_free(job->id);
ae23c9
+    g_free(job);
ae23c9
+}
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9