[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 09/41] blockjobs: add CONCLUDED state
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 09/41] blockjobs: add CONCLUDED state |
Date: |
Tue, 13 Mar 2018 17:17:31 +0100 |
From: John Snow <address@hidden>
add a new state "CONCLUDED" that identifies a job that has ceased all
operations. The wording was chosen to avoid any phrasing that might
imply success, error, or cancellation. The task has simply ceased all
operation and can never again perform any work.
("finished", "done", and "completed" might all imply success.)
Transitions:
Running -> Concluded: normal completion
Ready -> Concluded: normal completion
Aborting -> Concluded: error and cancellations
Verbs:
None as of this commit. (a future commit adds 'dismiss')
+---------+
|UNDEFINED|
+--+------+
|
+--v----+
+---------+CREATED|
| +--+----+
| |
| +--v----+ +------+
+---------+RUNNING<----->PAUSED|
| +--+-+--+ +------+
| | |
| | +------------------+
| | |
| +--v--+ +-------+ |
+---------+READY<------->STANDBY| |
| +--+--+ +-------+ |
| | |
+--v-----+ +--v------+ |
|ABORTING+--->CONCLUDED<-------------+
+--------+ +---------+
Signed-off-by: John Snow <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qapi/block-core.json | 7 +++++--
blockjob.c | 39 ++++++++++++++++++++++++---------------
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c33a9e91a7..2edfd194e3 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -997,14 +997,17 @@
# The job may return to @ready or otherwise be canceled.
#
# @aborting: The job is in the process of being aborted, and will finish with
-# an error.
+# an error. The job will afterwards report that it is @concluded.
# This status may not be visible to the management process.
#
+# @concluded: The job has finished all work. If manual was set to true, the job
+# will remain in the query list until it is dismissed.
+#
# Since: 2.12
##
{ 'enum': 'BlockJobStatus',
'data': ['undefined', 'created', 'running', 'paused', 'ready', 'standby',
- 'aborting' ] }
+ 'aborting', 'concluded' ] }
##
# @BlockJobInfo:
diff --git a/blockjob.c b/blockjob.c
index fe5b0041f7..3f730967b3 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -44,23 +44,24 @@ static QemuMutex block_job_mutex;
/* BlockJob State Transition Table */
bool BlockJobSTT[BLOCK_JOB_STATUS__MAX][BLOCK_JOB_STATUS__MAX] = {
- /* U, C, R, P, Y, S, X */
- /* U: */ [BLOCK_JOB_STATUS_UNDEFINED] = {0, 1, 0, 0, 0, 0, 0},
- /* C: */ [BLOCK_JOB_STATUS_CREATED] = {0, 0, 1, 0, 0, 0, 1},
- /* R: */ [BLOCK_JOB_STATUS_RUNNING] = {0, 0, 0, 1, 1, 0, 1},
- /* P: */ [BLOCK_JOB_STATUS_PAUSED] = {0, 0, 1, 0, 0, 0, 0},
- /* Y: */ [BLOCK_JOB_STATUS_READY] = {0, 0, 0, 0, 0, 1, 1},
- /* S: */ [BLOCK_JOB_STATUS_STANDBY] = {0, 0, 0, 0, 1, 0, 0},
- /* X: */ [BLOCK_JOB_STATUS_ABORTING] = {0, 0, 0, 0, 0, 0, 0},
+ /* U, C, R, P, Y, S, X, E */
+ /* U: */ [BLOCK_JOB_STATUS_UNDEFINED] = {0, 1, 0, 0, 0, 0, 0, 0},
+ /* C: */ [BLOCK_JOB_STATUS_CREATED] = {0, 0, 1, 0, 0, 0, 1, 0},
+ /* R: */ [BLOCK_JOB_STATUS_RUNNING] = {0, 0, 0, 1, 1, 0, 1, 1},
+ /* P: */ [BLOCK_JOB_STATUS_PAUSED] = {0, 0, 1, 0, 0, 0, 0, 0},
+ /* Y: */ [BLOCK_JOB_STATUS_READY] = {0, 0, 0, 0, 0, 1, 1, 1},
+ /* S: */ [BLOCK_JOB_STATUS_STANDBY] = {0, 0, 0, 0, 1, 0, 0, 0},
+ /* X: */ [BLOCK_JOB_STATUS_ABORTING] = {0, 0, 0, 0, 0, 0, 0, 1},
+ /* E: */ [BLOCK_JOB_STATUS_CONCLUDED] = {0, 0, 0, 0, 0, 0, 0, 0},
};
bool BlockJobVerbTable[BLOCK_JOB_VERB__MAX][BLOCK_JOB_STATUS__MAX] = {
- /* U, C, R, P, Y, S, X */
- [BLOCK_JOB_VERB_CANCEL] = {0, 1, 1, 1, 1, 1, 0},
- [BLOCK_JOB_VERB_PAUSE] = {0, 1, 1, 1, 1, 1, 0},
- [BLOCK_JOB_VERB_RESUME] = {0, 1, 1, 1, 1, 1, 0},
- [BLOCK_JOB_VERB_SET_SPEED] = {0, 1, 1, 1, 1, 1, 0},
- [BLOCK_JOB_VERB_COMPLETE] = {0, 0, 0, 0, 1, 0, 0},
+ /* U, C, R, P, Y, S, X, E */
+ [BLOCK_JOB_VERB_CANCEL] = {0, 1, 1, 1, 1, 1, 0, 0},
+ [BLOCK_JOB_VERB_PAUSE] = {0, 1, 1, 1, 1, 1, 0, 0},
+ [BLOCK_JOB_VERB_RESUME] = {0, 1, 1, 1, 1, 1, 0, 0},
+ [BLOCK_JOB_VERB_SET_SPEED] = {0, 1, 1, 1, 1, 1, 0, 0},
+ [BLOCK_JOB_VERB_COMPLETE] = {0, 0, 0, 0, 1, 0, 0, 0},
};
static void block_job_state_transition(BlockJob *job, BlockJobStatus s1)
@@ -377,6 +378,11 @@ void block_job_start(BlockJob *job)
bdrv_coroutine_enter(blk_bs(job->blk), job->co);
}
+static void block_job_conclude(BlockJob *job)
+{
+ block_job_state_transition(job, BLOCK_JOB_STATUS_CONCLUDED);
+}
+
static void block_job_completed_single(BlockJob *job)
{
assert(job->completed);
@@ -417,6 +423,7 @@ static void block_job_completed_single(BlockJob *job)
QLIST_REMOVE(job, txn_list);
block_job_txn_unref(job->txn);
+ block_job_conclude(job);
block_job_unref(job);
}
@@ -617,7 +624,9 @@ void block_job_user_resume(BlockJob *job, Error **errp)
void block_job_cancel(BlockJob *job)
{
- if (block_job_started(job)) {
+ if (job->status == BLOCK_JOB_STATUS_CONCLUDED) {
+ return;
+ } else if (block_job_started(job)) {
block_job_cancel_async(job);
block_job_enter(job);
} else {
--
2.13.6
- [Qemu-block] [PULL 08/41] blockjobs: add ABORTING state, (continued)
- [Qemu-block] [PULL 08/41] blockjobs: add ABORTING state, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 07/41] blockjobs: add block_job_verb permission table, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 10/41] blockjobs: add NULL state, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 11/41] blockjobs: add block_job_dismiss, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 16/41] blockjobs: add waiting status, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 14/41] blockjobs: add block_job_txn_apply function, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 18/41] blockjobs: add block-job-finalize, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 13/41] blockjobs: add commit, abort, clean helpers, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 09/41] blockjobs: add CONCLUDED state,
Kevin Wolf <=
- [Qemu-block] [PULL 17/41] blockjobs: add PENDING status and event, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 23/41] luks: Create block_crypto_co_create_generic(), Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 24/41] luks: Support .bdrv_co_create, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 20/41] iotests: test manual job dismissal, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 12/41] blockjobs: ensure abort is called for cancelled jobs, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 15/41] blockjobs: add prepare callback, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 22/41] luks: Separate image file creation from formatting, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 29/41] vdi: Move file creation to vdi_co_create_opts, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 27/41] qemu-iotests: Test luks QMP image creation, Kevin Wolf, 2018/03/13
- [Qemu-block] [PULL 26/41] luks: Catch integer overflow for huge sizes, Kevin Wolf, 2018/03/13