|
|
383d26 |
From 4d3f866a590d0c5005bd864cc2ee7bb8187f6dbb Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Date: Tue, 26 Jun 2018 09:48:13 +0200
|
|
|
383d26 |
Subject: [PATCH 44/89] job: Move BlockJobCreateFlags to Job
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Message-id: <20180626094856.6924-31-kwolf@redhat.com>
|
|
|
383d26 |
Patchwork-id: 81106
|
|
|
383d26 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 30/73] job: Move BlockJobCreateFlags to Job
|
|
|
383d26 |
Bugzilla: 1513543
|
|
|
383d26 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
This renames the BlockJobCreateFlags constants, moves a few JOB_INTERNAL
|
|
|
383d26 |
checks to job_create() and the auto_{finalize,dismiss} fields from
|
|
|
383d26 |
BlockJob to Job.
|
|
|
383d26 |
|
|
|
383d26 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
(cherry picked from commit bb02b65c7d57e4f2136f39bfba95cc68d89eb216)
|
|
|
383d26 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
block/commit.c | 2 +-
|
|
|
383d26 |
block/mirror.c | 2 +-
|
|
|
383d26 |
block/replication.c | 4 ++--
|
|
|
383d26 |
block/stream.c | 2 +-
|
|
|
383d26 |
blockdev.c | 14 +++++++-------
|
|
|
383d26 |
blockjob.c | 27 +++++++--------------------
|
|
|
383d26 |
include/block/blockjob.h | 17 -----------------
|
|
|
383d26 |
include/block/blockjob_int.h | 3 +--
|
|
|
383d26 |
include/qemu/job.h | 20 +++++++++++++++++++-
|
|
|
383d26 |
job.c | 11 ++++++++++-
|
|
|
383d26 |
qemu-img.c | 2 +-
|
|
|
383d26 |
tests/test-blockjob-txn.c | 2 +-
|
|
|
383d26 |
tests/test-blockjob.c | 4 ++--
|
|
|
383d26 |
13 files changed, 53 insertions(+), 57 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/block/commit.c b/block/commit.c
|
|
|
383d26 |
index c4a98e5..7a6ae59 100644
|
|
|
383d26 |
--- a/block/commit.c
|
|
|
383d26 |
+++ b/block/commit.c
|
|
|
383d26 |
@@ -282,7 +282,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
s = block_job_create(job_id, &commit_job_driver, NULL, bs, 0, BLK_PERM_ALL,
|
|
|
383d26 |
- speed, BLOCK_JOB_DEFAULT, NULL, NULL, errp);
|
|
|
383d26 |
+ speed, JOB_DEFAULT, NULL, NULL, errp);
|
|
|
383d26 |
if (!s) {
|
|
|
383d26 |
return;
|
|
|
383d26 |
}
|
|
|
383d26 |
diff --git a/block/mirror.c b/block/mirror.c
|
|
|
383d26 |
index 9a7226f..5091e72 100644
|
|
|
383d26 |
--- a/block/mirror.c
|
|
|
383d26 |
+++ b/block/mirror.c
|
|
|
383d26 |
@@ -1284,7 +1284,7 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
|
|
|
383d26 |
}
|
|
|
383d26 |
is_none_mode = mode == MIRROR_SYNC_MODE_NONE;
|
|
|
383d26 |
base = mode == MIRROR_SYNC_MODE_TOP ? backing_bs(bs) : NULL;
|
|
|
383d26 |
- mirror_start_job(job_id, bs, BLOCK_JOB_DEFAULT, target, replaces,
|
|
|
383d26 |
+ mirror_start_job(job_id, bs, JOB_DEFAULT, target, replaces,
|
|
|
383d26 |
speed, granularity, buf_size, backing_mode,
|
|
|
383d26 |
on_source_error, on_target_error, unmap, NULL, NULL,
|
|
|
383d26 |
&mirror_job_driver, is_none_mode, base, false,
|
|
|
383d26 |
diff --git a/block/replication.c b/block/replication.c
|
|
|
383d26 |
index 3f7500e..8241400 100644
|
|
|
383d26 |
--- a/block/replication.c
|
|
|
383d26 |
+++ b/block/replication.c
|
|
|
383d26 |
@@ -566,7 +566,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
|
|
|
383d26 |
job = backup_job_create(NULL, s->secondary_disk->bs, s->hidden_disk->bs,
|
|
|
383d26 |
0, MIRROR_SYNC_MODE_NONE, NULL, false,
|
|
|
383d26 |
BLOCKDEV_ON_ERROR_REPORT,
|
|
|
383d26 |
- BLOCKDEV_ON_ERROR_REPORT, BLOCK_JOB_INTERNAL,
|
|
|
383d26 |
+ BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL,
|
|
|
383d26 |
backup_job_completed, bs, NULL, &local_err);
|
|
|
383d26 |
if (local_err) {
|
|
|
383d26 |
error_propagate(errp, local_err);
|
|
|
383d26 |
@@ -691,7 +691,7 @@ static void replication_stop(ReplicationState *rs, bool failover, Error **errp)
|
|
|
383d26 |
|
|
|
383d26 |
s->stage = BLOCK_REPLICATION_FAILOVER;
|
|
|
383d26 |
commit_active_start(NULL, s->active_disk->bs, s->secondary_disk->bs,
|
|
|
383d26 |
- BLOCK_JOB_INTERNAL, 0, BLOCKDEV_ON_ERROR_REPORT,
|
|
|
383d26 |
+ JOB_INTERNAL, 0, BLOCKDEV_ON_ERROR_REPORT,
|
|
|
383d26 |
NULL, replication_done, bs, true, errp);
|
|
|
383d26 |
break;
|
|
|
383d26 |
default:
|
|
|
383d26 |
diff --git a/block/stream.c b/block/stream.c
|
|
|
383d26 |
index e81b488..eee0253 100644
|
|
|
383d26 |
--- a/block/stream.c
|
|
|
383d26 |
+++ b/block/stream.c
|
|
|
383d26 |
@@ -242,7 +242,7 @@ void stream_start(const char *job_id, BlockDriverState *bs,
|
|
|
383d26 |
BLK_PERM_GRAPH_MOD,
|
|
|
383d26 |
BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED |
|
|
|
383d26 |
BLK_PERM_WRITE,
|
|
|
383d26 |
- speed, BLOCK_JOB_DEFAULT, NULL, NULL, errp);
|
|
|
383d26 |
+ speed, JOB_DEFAULT, NULL, NULL, errp);
|
|
|
383d26 |
if (!s) {
|
|
|
383d26 |
goto fail;
|
|
|
383d26 |
}
|
|
|
383d26 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
383d26 |
index 0fa1990..89df7d9 100644
|
|
|
383d26 |
--- a/blockdev.c
|
|
|
383d26 |
+++ b/blockdev.c
|
|
|
383d26 |
@@ -3291,7 +3291,7 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
|
|
|
383d26 |
goto out;
|
|
|
383d26 |
}
|
|
|
383d26 |
commit_active_start(has_job_id ? job_id : NULL, bs, base_bs,
|
|
|
383d26 |
- BLOCK_JOB_DEFAULT, speed, on_error,
|
|
|
383d26 |
+ JOB_DEFAULT, speed, on_error,
|
|
|
383d26 |
filter_node_name, NULL, NULL, false, &local_err);
|
|
|
383d26 |
} else {
|
|
|
383d26 |
BlockDriverState *overlay_bs = bdrv_find_overlay(bs, top_bs);
|
|
|
383d26 |
@@ -3322,7 +3322,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,
|
|
|
383d26 |
AioContext *aio_context;
|
|
|
383d26 |
QDict *options = NULL;
|
|
|
383d26 |
Error *local_err = NULL;
|
|
|
383d26 |
- int flags, job_flags = BLOCK_JOB_DEFAULT;
|
|
|
383d26 |
+ int flags, job_flags = JOB_DEFAULT;
|
|
|
383d26 |
int64_t size;
|
|
|
383d26 |
bool set_backing_hd = false;
|
|
|
383d26 |
|
|
|
383d26 |
@@ -3445,10 +3445,10 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
if (!backup->auto_finalize) {
|
|
|
383d26 |
- job_flags |= BLOCK_JOB_MANUAL_FINALIZE;
|
|
|
383d26 |
+ job_flags |= JOB_MANUAL_FINALIZE;
|
|
|
383d26 |
}
|
|
|
383d26 |
if (!backup->auto_dismiss) {
|
|
|
383d26 |
- job_flags |= BLOCK_JOB_MANUAL_DISMISS;
|
|
|
383d26 |
+ job_flags |= JOB_MANUAL_DISMISS;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
|
|
|
383d26 |
@@ -3489,7 +3489,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn,
|
|
|
383d26 |
Error *local_err = NULL;
|
|
|
383d26 |
AioContext *aio_context;
|
|
|
383d26 |
BlockJob *job = NULL;
|
|
|
383d26 |
- int job_flags = BLOCK_JOB_DEFAULT;
|
|
|
383d26 |
+ int job_flags = JOB_DEFAULT;
|
|
|
383d26 |
|
|
|
383d26 |
if (!backup->has_speed) {
|
|
|
383d26 |
backup->speed = 0;
|
|
|
383d26 |
@@ -3538,10 +3538,10 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn,
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
if (!backup->auto_finalize) {
|
|
|
383d26 |
- job_flags |= BLOCK_JOB_MANUAL_FINALIZE;
|
|
|
383d26 |
+ job_flags |= JOB_MANUAL_FINALIZE;
|
|
|
383d26 |
}
|
|
|
383d26 |
if (!backup->auto_dismiss) {
|
|
|
383d26 |
- job_flags |= BLOCK_JOB_MANUAL_DISMISS;
|
|
|
383d26 |
+ job_flags |= JOB_MANUAL_DISMISS;
|
|
|
383d26 |
}
|
|
|
383d26 |
job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
|
|
|
383d26 |
backup->sync, NULL, backup->compress,
|
|
|
383d26 |
diff --git a/blockjob.c b/blockjob.c
|
|
|
383d26 |
index a1d1f48..d9d8ff7 100644
|
|
|
383d26 |
--- a/blockjob.c
|
|
|
383d26 |
+++ b/blockjob.c
|
|
|
383d26 |
@@ -285,7 +285,7 @@ static void block_job_do_dismiss(BlockJob *job)
|
|
|
383d26 |
static void block_job_conclude(BlockJob *job)
|
|
|
383d26 |
{
|
|
|
383d26 |
job_state_transition(&job->job, JOB_STATUS_CONCLUDED);
|
|
|
383d26 |
- if (job->auto_dismiss || !job_started(&job->job)) {
|
|
|
383d26 |
+ if (job->job.auto_dismiss || !job_started(&job->job)) {
|
|
|
383d26 |
block_job_do_dismiss(job);
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
@@ -483,7 +483,7 @@ static void block_job_completed_txn_abort(BlockJob *job)
|
|
|
383d26 |
|
|
|
383d26 |
static int block_job_needs_finalize(BlockJob *job)
|
|
|
383d26 |
{
|
|
|
383d26 |
- return !job->auto_finalize;
|
|
|
383d26 |
+ return !job->job.auto_finalize;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
static void block_job_do_finalize(BlockJob *job)
|
|
|
383d26 |
@@ -688,8 +688,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp)
|
|
|
383d26 |
info->io_status = job->iostatus;
|
|
|
383d26 |
info->ready = job->ready;
|
|
|
383d26 |
info->status = job->job.status;
|
|
|
383d26 |
- info->auto_finalize = job->auto_finalize;
|
|
|
383d26 |
- info->auto_dismiss = job->auto_dismiss;
|
|
|
383d26 |
+ info->auto_finalize = job->job.auto_finalize;
|
|
|
383d26 |
+ info->auto_dismiss = job->job.auto_dismiss;
|
|
|
383d26 |
info->has_error = job->ret != 0;
|
|
|
383d26 |
info->error = job->ret ? g_strdup(strerror(-job->ret)) : NULL;
|
|
|
383d26 |
return info;
|
|
|
383d26 |
@@ -736,7 +736,7 @@ static void block_job_event_completed(BlockJob *job, const char *msg)
|
|
|
383d26 |
static int block_job_event_pending(BlockJob *job)
|
|
|
383d26 |
{
|
|
|
383d26 |
job_state_transition(&job->job, JOB_STATUS_PENDING);
|
|
|
383d26 |
- if (!job->auto_finalize && !block_job_is_internal(job)) {
|
|
|
383d26 |
+ if (!job->job.auto_finalize && !block_job_is_internal(job)) {
|
|
|
383d26 |
qapi_event_send_block_job_pending(job_type(&job->job),
|
|
|
383d26 |
job->job.id,
|
|
|
383d26 |
&error_abort);
|
|
|
383d26 |
@@ -763,19 +763,8 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
|
|
|
383d26 |
return NULL;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
- if (job_id == NULL && !(flags & BLOCK_JOB_INTERNAL)) {
|
|
|
383d26 |
+ if (job_id == NULL && !(flags & JOB_INTERNAL)) {
|
|
|
383d26 |
job_id = bdrv_get_device_name(bs);
|
|
|
383d26 |
- if (!*job_id) {
|
|
|
383d26 |
- error_setg(errp, "An explicit job ID is required for this node");
|
|
|
383d26 |
- return NULL;
|
|
|
383d26 |
- }
|
|
|
383d26 |
- }
|
|
|
383d26 |
-
|
|
|
383d26 |
- if (job_id) {
|
|
|
383d26 |
- if (flags & BLOCK_JOB_INTERNAL) {
|
|
|
383d26 |
- error_setg(errp, "Cannot specify job ID for internal block job");
|
|
|
383d26 |
- return NULL;
|
|
|
383d26 |
- }
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
blk = blk_new(perm, shared_perm);
|
|
|
383d26 |
@@ -786,7 +775,7 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
job = job_create(job_id, &driver->job_driver, blk_get_aio_context(blk),
|
|
|
383d26 |
- errp);
|
|
|
383d26 |
+ flags, errp);
|
|
|
383d26 |
if (job == NULL) {
|
|
|
383d26 |
blk_unref(blk);
|
|
|
383d26 |
return NULL;
|
|
|
383d26 |
@@ -800,8 +789,6 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
|
|
|
383d26 |
job->blk = blk;
|
|
|
383d26 |
job->cb = cb;
|
|
|
383d26 |
job->opaque = opaque;
|
|
|
383d26 |
- job->auto_finalize = !(flags & BLOCK_JOB_MANUAL_FINALIZE);
|
|
|
383d26 |
- job->auto_dismiss = !(flags & BLOCK_JOB_MANUAL_DISMISS);
|
|
|
383d26 |
|
|
|
383d26 |
error_setg(&job->blocker, "block device is in use by block job: %s",
|
|
|
383d26 |
job_type_str(&job->job));
|
|
|
383d26 |
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
|
|
|
383d26 |
index 3e94e18..f9aaaaa 100644
|
|
|
383d26 |
--- a/include/block/blockjob.h
|
|
|
383d26 |
+++ b/include/block/blockjob.h
|
|
|
383d26 |
@@ -91,27 +91,10 @@ typedef struct BlockJob {
|
|
|
383d26 |
/** ret code passed to block_job_completed. */
|
|
|
383d26 |
int ret;
|
|
|
383d26 |
|
|
|
383d26 |
- /** True if this job should automatically finalize itself */
|
|
|
383d26 |
- bool auto_finalize;
|
|
|
383d26 |
-
|
|
|
383d26 |
- /** True if this job should automatically dismiss itself */
|
|
|
383d26 |
- bool auto_dismiss;
|
|
|
383d26 |
-
|
|
|
383d26 |
BlockJobTxn *txn;
|
|
|
383d26 |
QLIST_ENTRY(BlockJob) txn_list;
|
|
|
383d26 |
} BlockJob;
|
|
|
383d26 |
|
|
|
383d26 |
-typedef enum BlockJobCreateFlags {
|
|
|
383d26 |
- /* Default behavior */
|
|
|
383d26 |
- BLOCK_JOB_DEFAULT = 0x00,
|
|
|
383d26 |
- /* BlockJob is not QMP-created and should not send QMP events */
|
|
|
383d26 |
- BLOCK_JOB_INTERNAL = 0x01,
|
|
|
383d26 |
- /* BlockJob requires manual finalize step */
|
|
|
383d26 |
- BLOCK_JOB_MANUAL_FINALIZE = 0x02,
|
|
|
383d26 |
- /* BlockJob requires manual dismiss step */
|
|
|
383d26 |
- BLOCK_JOB_MANUAL_DISMISS = 0x04,
|
|
|
383d26 |
-} BlockJobCreateFlags;
|
|
|
383d26 |
-
|
|
|
383d26 |
/**
|
|
|
383d26 |
* block_job_next:
|
|
|
383d26 |
* @job: A block job, or %NULL.
|
|
|
383d26 |
diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
|
|
|
383d26 |
index 7e705ae..88639f7 100644
|
|
|
383d26 |
--- a/include/block/blockjob_int.h
|
|
|
383d26 |
+++ b/include/block/blockjob_int.h
|
|
|
383d26 |
@@ -106,8 +106,7 @@ struct BlockJobDriver {
|
|
|
383d26 |
* @bs: The block
|
|
|
383d26 |
* @perm, @shared_perm: Permissions to request for @bs
|
|
|
383d26 |
* @speed: The maximum speed, in bytes per second, or 0 for unlimited.
|
|
|
383d26 |
- * @flags: Creation flags for the Block Job.
|
|
|
383d26 |
- * See @BlockJobCreateFlags
|
|
|
383d26 |
+ * @flags: Creation flags for the Block Job. See @JobCreateFlags.
|
|
|
383d26 |
* @cb: Completion function for the job.
|
|
|
383d26 |
* @opaque: Opaque pointer value passed to @cb.
|
|
|
383d26 |
* @errp: Error object.
|
|
|
383d26 |
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
|
|
383d26 |
index 858f3be..9783e40 100644
|
|
|
383d26 |
--- a/include/qemu/job.h
|
|
|
383d26 |
+++ b/include/qemu/job.h
|
|
|
383d26 |
@@ -99,6 +99,12 @@ typedef struct Job {
|
|
|
383d26 |
/** Set to true when the job has deferred work to the main loop. */
|
|
|
383d26 |
bool deferred_to_main_loop;
|
|
|
383d26 |
|
|
|
383d26 |
+ /** True if this job should automatically finalize itself */
|
|
|
383d26 |
+ bool auto_finalize;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ /** True if this job should automatically dismiss itself */
|
|
|
383d26 |
+ bool auto_dismiss;
|
|
|
383d26 |
+
|
|
|
383d26 |
/** Element of the list of jobs */
|
|
|
383d26 |
QLIST_ENTRY(Job) job_list;
|
|
|
383d26 |
} Job;
|
|
|
383d26 |
@@ -140,6 +146,17 @@ struct JobDriver {
|
|
|
383d26 |
void (*free)(Job *job);
|
|
|
383d26 |
};
|
|
|
383d26 |
|
|
|
383d26 |
+typedef enum JobCreateFlags {
|
|
|
383d26 |
+ /* Default behavior */
|
|
|
383d26 |
+ JOB_DEFAULT = 0x00,
|
|
|
383d26 |
+ /* Job is not QMP-created and should not send QMP events */
|
|
|
383d26 |
+ JOB_INTERNAL = 0x01,
|
|
|
383d26 |
+ /* Job requires manual finalize step */
|
|
|
383d26 |
+ JOB_MANUAL_FINALIZE = 0x02,
|
|
|
383d26 |
+ /* Job requires manual dismiss step */
|
|
|
383d26 |
+ JOB_MANUAL_DISMISS = 0x04,
|
|
|
383d26 |
+} JobCreateFlags;
|
|
|
383d26 |
+
|
|
|
383d26 |
|
|
|
383d26 |
/**
|
|
|
383d26 |
* Create a new long-running job and return it.
|
|
|
383d26 |
@@ -147,10 +164,11 @@ struct JobDriver {
|
|
|
383d26 |
* @job_id: The id of the newly-created job, or %NULL for internal jobs
|
|
|
383d26 |
* @driver: The class object for the newly-created job.
|
|
|
383d26 |
* @ctx: The AioContext to run the job coroutine in.
|
|
|
383d26 |
+ * @flags: Creation flags for the job. See @JobCreateFlags.
|
|
|
383d26 |
* @errp: Error object.
|
|
|
383d26 |
*/
|
|
|
383d26 |
void *job_create(const char *job_id, const JobDriver *driver, AioContext *ctx,
|
|
|
383d26 |
- Error **errp);
|
|
|
383d26 |
+ int flags, Error **errp);
|
|
|
383d26 |
|
|
|
383d26 |
/**
|
|
|
383d26 |
* Add a reference to Job refcnt, it will be decreased with job_unref, and then
|
|
|
383d26 |
diff --git a/job.c b/job.c
|
|
|
383d26 |
index aaacfcc..dd46170 100644
|
|
|
383d26 |
--- a/job.c
|
|
|
383d26 |
+++ b/job.c
|
|
|
383d26 |
@@ -182,11 +182,15 @@ static void job_sleep_timer_cb(void *opaque)
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
void *job_create(const char *job_id, const JobDriver *driver, AioContext *ctx,
|
|
|
383d26 |
- Error **errp)
|
|
|
383d26 |
+ int flags, Error **errp)
|
|
|
383d26 |
{
|
|
|
383d26 |
Job *job;
|
|
|
383d26 |
|
|
|
383d26 |
if (job_id) {
|
|
|
383d26 |
+ if (flags & JOB_INTERNAL) {
|
|
|
383d26 |
+ error_setg(errp, "Cannot specify job ID for internal job");
|
|
|
383d26 |
+ return NULL;
|
|
|
383d26 |
+ }
|
|
|
383d26 |
if (!id_wellformed(job_id)) {
|
|
|
383d26 |
error_setg(errp, "Invalid job ID '%s'", job_id);
|
|
|
383d26 |
return NULL;
|
|
|
383d26 |
@@ -195,6 +199,9 @@ void *job_create(const char *job_id, const JobDriver *driver, AioContext *ctx,
|
|
|
383d26 |
error_setg(errp, "Job ID '%s' already in use", job_id);
|
|
|
383d26 |
return NULL;
|
|
|
383d26 |
}
|
|
|
383d26 |
+ } else if (!(flags & JOB_INTERNAL)) {
|
|
|
383d26 |
+ error_setg(errp, "An explicit job ID is required");
|
|
|
383d26 |
+ return NULL;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
job = g_malloc0(driver->instance_size);
|
|
|
383d26 |
@@ -205,6 +212,8 @@ void *job_create(const char *job_id, const JobDriver *driver, AioContext *ctx,
|
|
|
383d26 |
job->busy = false;
|
|
|
383d26 |
job->paused = true;
|
|
|
383d26 |
job->pause_count = 1;
|
|
|
383d26 |
+ job->auto_finalize = !(flags & JOB_MANUAL_FINALIZE);
|
|
|
383d26 |
+ job->auto_dismiss = !(flags & JOB_MANUAL_DISMISS);
|
|
|
383d26 |
|
|
|
383d26 |
job_state_transition(job, JOB_STATUS_CREATED);
|
|
|
383d26 |
aio_timer_init(qemu_get_aio_context(), &job->sleep_timer,
|
|
|
383d26 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
383d26 |
index f5bb0ef..843dc6a 100644
|
|
|
383d26 |
--- a/qemu-img.c
|
|
|
383d26 |
+++ b/qemu-img.c
|
|
|
383d26 |
@@ -1026,7 +1026,7 @@ static int img_commit(int argc, char **argv)
|
|
|
383d26 |
|
|
|
383d26 |
aio_context = bdrv_get_aio_context(bs);
|
|
|
383d26 |
aio_context_acquire(aio_context);
|
|
|
383d26 |
- commit_active_start("commit", bs, base_bs, BLOCK_JOB_DEFAULT, 0,
|
|
|
383d26 |
+ commit_active_start("commit", bs, base_bs, JOB_DEFAULT, 0,
|
|
|
383d26 |
BLOCKDEV_ON_ERROR_REPORT, NULL, common_block_job_cb,
|
|
|
383d26 |
&cbi, false, &local_err);
|
|
|
383d26 |
aio_context_release(aio_context);
|
|
|
383d26 |
diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c
|
|
|
383d26 |
index 93d1ff0..60e9fa2 100644
|
|
|
383d26 |
--- a/tests/test-blockjob-txn.c
|
|
|
383d26 |
+++ b/tests/test-blockjob-txn.c
|
|
|
383d26 |
@@ -107,7 +107,7 @@ static BlockJob *test_block_job_start(unsigned int iterations,
|
|
|
383d26 |
|
|
|
383d26 |
snprintf(job_id, sizeof(job_id), "job%u", counter++);
|
|
|
383d26 |
s = block_job_create(job_id, &test_block_job_driver, txn, bs,
|
|
|
383d26 |
- 0, BLK_PERM_ALL, 0, BLOCK_JOB_DEFAULT,
|
|
|
383d26 |
+ 0, BLK_PERM_ALL, 0, JOB_DEFAULT,
|
|
|
383d26 |
test_block_job_cb, data, &error_abort);
|
|
|
383d26 |
s->iterations = iterations;
|
|
|
383d26 |
s->use_timer = use_timer;
|
|
|
383d26 |
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
|
|
|
383d26 |
index ceb5960..8bb0aa8 100644
|
|
|
383d26 |
--- a/tests/test-blockjob.c
|
|
|
383d26 |
+++ b/tests/test-blockjob.c
|
|
|
383d26 |
@@ -59,7 +59,7 @@ static BlockJob *do_test_id(BlockBackend *blk, const char *id,
|
|
|
383d26 |
bool should_succeed)
|
|
|
383d26 |
{
|
|
|
383d26 |
return mk_job(blk, id, &test_block_job_driver,
|
|
|
383d26 |
- should_succeed, BLOCK_JOB_DEFAULT);
|
|
|
383d26 |
+ should_succeed, JOB_DEFAULT);
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
/* This creates a BlockBackend (optionally with a name) with a
|
|
|
383d26 |
@@ -214,7 +214,7 @@ static CancelJob *create_common(BlockJob **pjob)
|
|
|
383d26 |
|
|
|
383d26 |
blk = create_blk(NULL);
|
|
|
383d26 |
job = mk_job(blk, "Steve", &test_cancel_driver, true,
|
|
|
383d26 |
- BLOCK_JOB_MANUAL_FINALIZE | BLOCK_JOB_MANUAL_DISMISS);
|
|
|
383d26 |
+ JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS);
|
|
|
383d26 |
job_ref(&job->job);
|
|
|
383d26 |
assert(job->job.status == JOB_STATUS_CREATED);
|
|
|
383d26 |
s = container_of(job, CancelJob, common);
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|