diff options
author | Hanna Reitz <hreitz@redhat.com> | 2021-10-06 17:19:33 +0200 |
---|---|---|
committer | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2021-10-07 10:42:34 +0200 |
commit | 73895f3838cd7fdaf185cf1dbc47be58844a966f (patch) | |
tree | ffc814f4d4452dcaf8097ae23e3d73a7e5b570e7 /include/qemu | |
parent | 4cfb3f05627ad82af473e7f7ae113c3884cd04e3 (diff) | |
download | qemu-73895f3838cd7fdaf185cf1dbc47be58844a966f.zip qemu-73895f3838cd7fdaf185cf1dbc47be58844a966f.tar.gz qemu-73895f3838cd7fdaf185cf1dbc47be58844a966f.tar.bz2 |
jobs: Give Job.force_cancel more meaning
We largely have two cancel modes for jobs:
First, there is actual cancelling. The job is terminated as soon as
possible, without trying to reach a consistent result.
Second, we have mirror in the READY state. Technically, the job is not
really cancelled, but it just is a different completion mode. The job
can still run for an indefinite amount of time while it tries to reach a
consistent result.
We want to be able to clearly distinguish which cancel mode a job is in
(when it has been cancelled). We can use Job.force_cancel for this, but
right now it only reflects cancel requests from the user with
force=true, but clearly, jobs that do not even distinguish between
force=false and force=true are effectively always force-cancelled.
So this patch has Job.force_cancel signify whether the job will
terminate as soon as possible (force_cancel=true) or whether it will
effectively remain running despite being "cancelled"
(force_cancel=false).
To this end, we let jobs that provide JobDriver.cancel() tell the
generic job code whether they will terminate as soon as possible or not,
and for jobs that do not provide that method we assume they will.
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20211006151940.214590-7-hreitz@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Diffstat (limited to 'include/qemu')
-rw-r--r-- | include/qemu/job.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/qemu/job.h b/include/qemu/job.h index 2eddf3b..90f6abb 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -253,8 +253,17 @@ struct JobDriver { /** * If the callback is not NULL, it will be invoked in job_cancel_async + * + * This function must return true if the job will be cancelled + * immediately without any further I/O (mandatory if @force is + * true), and false otherwise. This lets the generic job layer + * know whether a job has been truly (force-)cancelled, or whether + * it is just in a special completion mode (like mirror after + * READY). + * (If the callback is NULL, the job is assumed to terminate + * without I/O.) */ - void (*cancel)(Job *job, bool force); + bool (*cancel)(Job *job, bool force); /** Called when the job is freed */ |