summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy2021-02-05 17:37:14 +0100
committerEric Blake2021-02-12 18:23:19 +0100
commit9820933b57b24c21a509680650f669123651b60d (patch)
tree880a422fa859d5566eccd39103ec93f515cf6c76
parentblock/raw-format: implement .bdrv_cancel_in_flight handler (diff)
downloadqemu-9820933b57b24c21a509680650f669123651b60d.tar.gz
qemu-9820933b57b24c21a509680650f669123651b60d.tar.xz
qemu-9820933b57b24c21a509680650f669123651b60d.zip
job: add .cancel handler for the driver
To be used in mirror in the following commit to cancel in-flight io on target to not waste the time. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20210205163720.887197-5-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
-rw-r--r--include/qemu/job.h5
-rw-r--r--job.c3
2 files changed, 8 insertions, 0 deletions
diff --git a/include/qemu/job.h b/include/qemu/job.h
index 32aabb1c60..efc6fa7544 100644
--- a/include/qemu/job.h
+++ b/include/qemu/job.h
@@ -251,6 +251,11 @@ struct JobDriver {
*/
void (*clean)(Job *job);
+ /**
+ * If the callback is not NULL, it will be invoked in job_cancel_async
+ */
+ void (*cancel)(Job *job);
+
/** Called when the job is freed */
void (*free)(Job *job);
diff --git a/job.c b/job.c
index 3aaaebafe2..289edee143 100644
--- a/job.c
+++ b/job.c
@@ -715,6 +715,9 @@ static int job_finalize_single(Job *job)
static void job_cancel_async(Job *job, bool force)
{
+ if (job->driver->cancel) {
+ job->driver->cancel(job);
+ }
if (job->user_paused) {
/* Do not call job_enter here, the caller will handle it. */
if (job->driver->user_resume) {