Blame SOURCES/kvm-job-Add-job_delete.patch

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