From nobody Mon Apr 29 10:56:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507000751372446.4844895539893; Mon, 2 Oct 2017 20:19:11 -0700 (PDT) Received: from localhost ([::1]:55969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzDji-0000Ui-D1 for importer@patchew.org; Mon, 02 Oct 2017 23:19:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzDgq-000743-I9 for qemu-devel@nongnu.org; Mon, 02 Oct 2017 23:16:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzDgn-0005uh-BJ for qemu-devel@nongnu.org; Mon, 02 Oct 2017 23:16:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49670) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzDge-0005kj-TQ; Mon, 02 Oct 2017 23:16:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 098D581E13; Tue, 3 Oct 2017 03:16:00 +0000 (UTC) Received: from probe.redhat.com (ovpn-120-249.rdu2.redhat.com [10.10.120.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 072A36047F; Tue, 3 Oct 2017 03:15:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 098D581E13 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jsnow@redhat.com From: John Snow To: qemu-block@nongnu.org Date: Mon, 2 Oct 2017 23:15:54 -0400 Message-Id: <20171003031556.15173-2-jsnow@redhat.com> In-Reply-To: <20171003031556.15173-1-jsnow@redhat.com> References: <20171003031556.15173-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 03 Oct 2017 03:16:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/3] blockjob: add manual-cull property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, John Snow , pkrempa@redhat.com, jtc@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a "manual cull" property to block jobs that forces them to linger in the block job list (visible to QMP queries) until the user explicitly dismisses them via QMP. The cull command itself is implemented in the next commit, and the feature is exposed to drive-backup and blockdev-backup in the subsequent commit. Signed-off-by: John Snow --- block/backup.c | 20 +++++++++---------- block/commit.c | 2 +- block/mirror.c | 2 +- block/replication.c | 5 +++-- block/stream.c | 2 +- blockdev.c | 8 ++++---- blockjob.c | 46 ++++++++++++++++++++++++++++++++++++++++= ++-- include/block/block_int.h | 8 +++++--- include/block/blockjob.h | 21 ++++++++++++++++++++ include/block/blockjob_int.h | 2 +- qapi/block-core.json | 7 ++++--- tests/test-blockjob-txn.c | 2 +- tests/test-blockjob.c | 2 +- 13 files changed, 97 insertions(+), 30 deletions(-) diff --git a/block/backup.c b/block/backup.c index 517c300..0b00908 100644 --- a/block/backup.c +++ b/block/backup.c @@ -532,15 +532,15 @@ static const BlockJobDriver backup_job_driver =3D { .drain =3D backup_drain, }; =20 -BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, - BlockDriverState *target, int64_t speed, - MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, - bool compress, - BlockdevOnError on_source_error, - BlockdevOnError on_target_error, - int creation_flags, - BlockCompletionFunc *cb, void *opaque, - BlockJobTxn *txn, Error **errp) +BlockJob *backup_job_create(const char *job_id, bool manual_cull, + BlockDriverState *bs, BlockDriverState *target, + int64_t speed, MirrorSyncMode sync_mode, + BdrvDirtyBitmap *sync_bitmap, bool compress, + BlockdevOnError on_source_error, + BlockdevOnError on_target_error, + int creation_flags, + BlockCompletionFunc *cb, void *opaque, + BlockJobTxn *txn, Error **errp) { int64_t len; BlockDriverInfo bdi; @@ -608,7 +608,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, } =20 /* job->common.len is fixed, so we can't allow resize */ - job =3D block_job_create(job_id, &backup_job_driver, bs, + job =3D block_job_create(job_id, &backup_job_driver, manual_cull, bs, BLK_PERM_CONSISTENT_READ, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED | BLK_PERM_GRAPH_MOD, diff --git a/block/commit.c b/block/commit.c index 8f0e835..308a5fd 100644 --- a/block/commit.c +++ b/block/commit.c @@ -304,7 +304,7 @@ void commit_start(const char *job_id, BlockDriverState = *bs, return; } =20 - s =3D block_job_create(job_id, &commit_job_driver, bs, 0, BLK_PERM_ALL, + s =3D block_job_create(job_id, &commit_job_driver, false, bs, 0, BLK_P= ERM_ALL, speed, BLOCK_JOB_DEFAULT, NULL, NULL, errp); if (!s) { return; diff --git a/block/mirror.c b/block/mirror.c index 6f5cb9f..013e73a 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1180,7 +1180,7 @@ static void mirror_start_job(const char *job_id, Bloc= kDriverState *bs, } =20 /* Make sure that the source is not resized while the job is running */ - s =3D block_job_create(job_id, driver, mirror_top_bs, + s =3D block_job_create(job_id, driver, false, mirror_top_bs, BLK_PERM_CONSISTENT_READ, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANG= ED | BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD, speed, diff --git a/block/replication.c b/block/replication.c index 3a4e682..6c59f00 100644 --- a/block/replication.c +++ b/block/replication.c @@ -539,8 +539,9 @@ static void replication_start(ReplicationState *rs, Rep= licationMode mode, bdrv_op_block_all(top_bs, s->blocker); bdrv_op_unblock(top_bs, BLOCK_OP_TYPE_DATAPLANE, s->blocker); =20 - job =3D backup_job_create(NULL, s->secondary_disk->bs, s->hidden_d= isk->bs, - 0, MIRROR_SYNC_MODE_NONE, NULL, false, + job =3D backup_job_create(NULL, false, s->secondary_disk->bs, + s->hidden_disk->bs, 0, MIRROR_SYNC_MODE_NO= NE, + NULL, false, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, BLOCK_JOB_INTERN= AL, backup_job_completed, bs, NULL, &local_err= ); diff --git a/block/stream.c b/block/stream.c index e6f7234..c644f34 100644 --- a/block/stream.c +++ b/block/stream.c @@ -244,7 +244,7 @@ void stream_start(const char *job_id, BlockDriverState = *bs, /* Prevent concurrent jobs trying to modify the graph structure here, = we * already have our own plans. Also don't allow resize as the image si= ze is * queried only at the job start and then cached. */ - s =3D block_job_create(job_id, &stream_job_driver, bs, + s =3D block_job_create(job_id, &stream_job_driver, false, bs, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANG= ED | BLK_PERM_GRAPH_MOD, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANG= ED | diff --git a/blockdev.c b/blockdev.c index 56a6b24..eeb4986 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3290,8 +3290,8 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= BlockJobTxn *txn, } } =20 - job =3D backup_job_create(backup->job_id, bs, target_bs, backup->speed, - backup->sync, bmap, backup->compress, + job =3D backup_job_create(backup->job_id, false, bs, target_bs, + backup->speed, backup->sync, bmap, backup->com= press, backup->on_source_error, backup->on_target_err= or, BLOCK_JOB_DEFAULT, NULL, NULL, txn, &local_err= ); bdrv_unref(target_bs); @@ -3369,8 +3369,8 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, = BlockJobTxn *txn, goto out; } } - job =3D backup_job_create(backup->job_id, bs, target_bs, backup->speed, - backup->sync, NULL, backup->compress, + job =3D backup_job_create(backup->job_id, false, bs, target_bs, + backup->speed, backup->sync, NULL, backup->com= press, backup->on_source_error, backup->on_target_err= or, BLOCK_JOB_DEFAULT, NULL, NULL, txn, &local_err= ); if (local_err !=3D NULL) { diff --git a/blockjob.c b/blockjob.c index 3a0c491..b4aaeb0 100644 --- a/blockjob.c +++ b/blockjob.c @@ -336,6 +336,8 @@ static void block_job_completed_single(BlockJob *job) QLIST_REMOVE(job, txn_list); block_job_txn_unref(job->txn); } + + job->finished =3D true; block_job_unref(job); } =20 @@ -352,6 +354,13 @@ static void block_job_cancel_async(BlockJob *job) job->cancelled =3D true; } =20 +static void block_job_do_cull(BlockJob *job) +{ + assert(job && job->manual_cull =3D=3D true); + job->manual_cull =3D false; + block_job_unref(job); +} + static int block_job_finish_sync(BlockJob *job, void (*finish)(BlockJob *, Error **errp), Error **errp) @@ -381,6 +390,9 @@ static int block_job_finish_sync(BlockJob *job, aio_poll(qemu_get_aio_context(), true); } ret =3D (job->cancelled && job->ret =3D=3D 0) ? -ECANCELED : job->ret; + if (job->manual_cull) { + block_job_do_cull(job); + } block_job_unref(job); return ret; } @@ -483,6 +495,26 @@ void block_job_complete(BlockJob *job, Error **errp) job->driver->complete(job, errp); } =20 +void block_job_cull(BlockJob **jobptr, Error **errp) +{ + BlockJob *job =3D *jobptr; + /* similarly to _complete, this is QMP-interface only. */ + assert(job->id); + if (!job->manual_cull) { + error_setg(errp, "The active block job '%s' was not started with " + "\'manual-cull\': true, and so cannot be culled as it w= ill " + "clean up after itself automatically", job->id); + return; + } else if (!job->finished) { + error_setg(errp, "The active block job '%s' has not yet terminated= , " + "and cannot be culled yet", job->id); + return; + } + + block_job_do_cull(job); + *jobptr =3D NULL; +} + void block_job_user_pause(BlockJob *job) { job->user_paused =3D true; @@ -505,7 +537,9 @@ void block_job_user_resume(BlockJob *job) =20 void block_job_cancel(BlockJob *job) { - if (block_job_started(job)) { + if (job->finished) { + return; + } else if (block_job_started(job)) { block_job_cancel_async(job); block_job_enter(job); } else { @@ -562,6 +596,7 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **er= rp) info->speed =3D job->speed; info->io_status =3D job->iostatus; info->ready =3D job->ready; + info->finished =3D job->finished; return info; } =20 @@ -609,7 +644,7 @@ static void block_job_event_completed(BlockJob *job, co= nst char *msg) */ =20 void *block_job_create(const char *job_id, const BlockJobDriver *driver, - BlockDriverState *bs, uint64_t perm, + bool manual_cull, BlockDriverState *bs, uint64_t pe= rm, uint64_t shared_perm, int64_t speed, int flags, BlockCompletionFunc *cb, void *opaque, Error **errp) { @@ -664,6 +699,7 @@ void *block_job_create(const char *job_id, const BlockJ= obDriver *driver, job->paused =3D true; job->pause_count =3D 1; job->refcnt =3D 1; + job->manual_cull =3D manual_cull; =20 error_setg(&job->blocker, "block device is in use by block job: %s", BlockJobType_str(driver->job_type)); @@ -689,6 +725,12 @@ void *block_job_create(const char *job_id, const Block= JobDriver *driver, return NULL; } } + + /* Hang on to an extra reference on behalf of the QMP monitor */ + if (job->manual_cull) { + block_job_ref(job); + } + return job; } =20 diff --git a/include/block/block_int.h b/include/block/block_int.h index 99abe2c..7d5a5d1 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -944,6 +944,8 @@ void mirror_start(const char *job_id, BlockDriverState = *bs, * backup_job_create: * @job_id: The id of the newly-created job, or %NULL to use the * device name of @bs. + * @manual_cull: Whether or not this job, when completed, will need to be + * manually culled via block-job-cull or not. * @bs: Block device to operate on. * @target: Block device to write to. * @speed: The maximum speed, in bytes per second, or 0 for unlimited. @@ -960,9 +962,9 @@ void mirror_start(const char *job_id, BlockDriverState = *bs, * Create a backup operation on @bs. Clusters in @bs are written to @targ= et * until the job is cancelled or manually completed. */ -BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, - BlockDriverState *target, int64_t speed, - MirrorSyncMode sync_mode, +BlockJob *backup_job_create(const char *job_id, bool manual_cull, + BlockDriverState *bs, BlockDriverState *target, + int64_t speed, MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, bool compress, BlockdevOnError on_source_error, diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 67c0968..8ea20ba 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -135,6 +135,15 @@ typedef struct BlockJob { */ int ret; =20 + /* True if this job must remain present post-completion until + * it can be queried and removed via block-job-cull. */ + bool manual_cull; + + /* True if and only if manual_cull is true and the job has finished + * calling either abort or commit (if applicable) and can be reaped + * via interactive user command. */ + bool finished; + /** Non-NULL if this job is part of a transaction */ BlockJobTxn *txn; QLIST_ENTRY(BlockJob) txn_list; @@ -227,6 +236,18 @@ void block_job_cancel(BlockJob *job); void block_job_complete(BlockJob *job, Error **errp); =20 /** + * block_job_cull: + * @job: The job to be culled. + * @errp: Error object. + * + * For completed or canceled jobs, remove the job object + * from the block_job_query list and perform final cleanup. + * + * Note that at this stage, the job cannot be rolled back. + */ +void block_job_cull(BlockJob **job, Error **errp); + +/** * block_job_query: * @job: The job to get information about. * diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h index f13ad05..17e2c91 100644 --- a/include/block/blockjob_int.h +++ b/include/block/blockjob_int.h @@ -132,7 +132,7 @@ struct BlockJobDriver { * called from a wrapper that is specific to the job type. */ void *block_job_create(const char *job_id, const BlockJobDriver *driver, - BlockDriverState *bs, uint64_t perm, + bool manual_cull, BlockDriverState *bs, uint64_t pe= rm, uint64_t shared_perm, int64_t speed, int flags, BlockCompletionFunc *cb, void *opaque, Error **errp= ); =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index 750bb0c..a4f5e10 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -984,9 +984,10 @@ # Since: 1.1 ## { 'struct': 'BlockJobInfo', - 'data': {'type': 'str', 'device': 'str', 'len': 'int', - 'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'in= t', - 'io-status': 'BlockDeviceIoStatus', 'ready': 'bool'} } + 'data': {'type': 'str', 'device': 'str', 'len': 'int', 'offset': 'int', + 'busy': 'bool', 'paused': 'bool', 'speed': 'int', + 'io-status': 'BlockDeviceIoStatus', 'ready': 'bool', + 'finished': 'bool'} } =20 ## # @query-block-jobs: diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index c77343f..5ab0e22 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -101,7 +101,7 @@ static BlockJob *test_block_job_start(unsigned int iter= ations, g_assert_nonnull(bs); =20 snprintf(job_id, sizeof(job_id), "job%u", counter++); - s =3D block_job_create(job_id, &test_block_job_driver, bs, + s =3D block_job_create(job_id, &test_block_job_driver, false, bs, 0, BLK_PERM_ALL, 0, BLOCK_JOB_DEFAULT, test_block_job_cb, data, &error_abort); s->iterations =3D iterations; diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c index 23bdf1a..9fc2785 100644 --- a/tests/test-blockjob.c +++ b/tests/test-blockjob.c @@ -30,7 +30,7 @@ static BlockJob *do_test_id(BlockBackend *blk, const char= *id, BlockJob *job; Error *errp =3D NULL; =20 - job =3D block_job_create(id, &test_block_job_driver, blk_bs(blk), + job =3D block_job_create(id, &test_block_job_driver, false, blk_bs(blk= ), 0, BLK_PERM_ALL, 0, BLOCK_JOB_DEFAULT, block_jo= b_cb, NULL, &errp); if (should_succeed) { --=20 2.9.5 From nobody Mon Apr 29 10:56:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507000764405710.4100594634773; Mon, 2 Oct 2017 20:19:24 -0700 (PDT) Received: from localhost ([::1]:55970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzDjt-0000cv-Ja for importer@patchew.org; Mon, 02 Oct 2017 23:19:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzDgk-0006yw-04 for qemu-devel@nongnu.org; Mon, 02 Oct 2017 23:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzDgj-0005q2-23 for qemu-devel@nongnu.org; Mon, 02 Oct 2017 23:16:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49714) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzDgg-0005ls-0u; Mon, 02 Oct 2017 23:16:02 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A07481DF9; Tue, 3 Oct 2017 03:16:01 +0000 (UTC) Received: from probe.redhat.com (ovpn-120-249.rdu2.redhat.com [10.10.120.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3316E6047F; Tue, 3 Oct 2017 03:16:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0A07481DF9 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jsnow@redhat.com From: John Snow To: qemu-block@nongnu.org Date: Mon, 2 Oct 2017 23:15:55 -0400 Message-Id: <20171003031556.15173-3-jsnow@redhat.com> In-Reply-To: <20171003031556.15173-1-jsnow@redhat.com> References: <20171003031556.15173-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 03 Oct 2017 03:16:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] qmp: add block-job-cull command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, John Snow , pkrempa@redhat.com, jtc@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For jobs that have finished (either completed or canceled), allow the user to dismiss the job's status reports via block-job-cull. Signed-off-by: John Snow --- block/trace-events | 1 + blockdev.c | 14 ++++++++++++++ qapi/block-core.json | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/block/trace-events b/block/trace-events index 25dd5a3..cb64e91 100644 --- a/block/trace-events +++ b/block/trace-events @@ -46,6 +46,7 @@ qmp_block_job_cancel(void *job) "job %p" qmp_block_job_pause(void *job) "job %p" qmp_block_job_resume(void *job) "job %p" qmp_block_job_complete(void *job) "job %p" +qmp_block_job_cull(void *job) "job %p" qmp_block_stream(void *bs, void *job) "bs %p job %p" =20 # block/file-win32.c diff --git a/blockdev.c b/blockdev.c index eeb4986..ee07bca 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3766,6 +3766,20 @@ void qmp_block_job_complete(const char *device, Erro= r **errp) aio_context_release(aio_context); } =20 +void qmp_block_job_cull(const char *device, Error **errp) +{ + AioContext *aio_context; + BlockJob *job =3D find_block_job(device, &aio_context, errp); + + if (!job) { + return; + } + + trace_qmp_block_job_cull(job); + block_job_cull(&job, errp); + aio_context_release(aio_context); +} + void qmp_change_backing_file(const char *device, const char *image_node_name, const char *backing_file, diff --git a/qapi/block-core.json b/qapi/block-core.json index a4f5e10..de322d1 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2161,6 +2161,27 @@ { 'command': 'block-job-complete', 'data': { 'device': 'str' } } =20 ## +# @block-job-cull: +# +# For jobs that have already completed, remove them from the block-job-que= ry +# list. This command only needs to be run for jobs which were started with= the +# manual-cull=3Dtrue option. +# +# This command will refuse to operate on any job that has not yet reached +# its terminal state. "cancel" or "complete" will still need to be used as +# appropriate. +# +# @device: The job identifier. This used to be a device name (hence +# the name of the parameter), but since QEMU 2.7 it can have +# other values. +# +# Returns: Nothing on success +# +# Since: 2.11 +## +{ 'command': 'block-job-cull', 'data': { 'device': 'str' } } + +## # @BlockdevDiscardOptions: # # Determines how to handle discard requests. --=20 2.9.5 From nobody Mon Apr 29 10:56:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507000702322646.7524921014752; Mon, 2 Oct 2017 20:18:22 -0700 (PDT) Received: from localhost ([::1]:55967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzDir-0008Ec-Td for importer@patchew.org; Mon, 02 Oct 2017 23:18:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzDgm-00070e-BE for qemu-devel@nongnu.org; Mon, 02 Oct 2017 23:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzDgl-0005sY-5E for qemu-devel@nongnu.org; Mon, 02 Oct 2017 23:16:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42282) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzDgh-0005nf-Qg; Mon, 02 Oct 2017 23:16:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB51746213; Tue, 3 Oct 2017 03:16:02 +0000 (UTC) Received: from probe.redhat.com (ovpn-120-249.rdu2.redhat.com [10.10.120.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3624A6047F; Tue, 3 Oct 2017 03:16:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EB51746213 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jsnow@redhat.com From: John Snow To: qemu-block@nongnu.org Date: Mon, 2 Oct 2017 23:15:56 -0400 Message-Id: <20171003031556.15173-4-jsnow@redhat.com> In-Reply-To: <20171003031556.15173-1-jsnow@redhat.com> References: <20171003031556.15173-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 03 Oct 2017 03:16:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/3] blockjob: expose manual-cull property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, John Snow , pkrempa@redhat.com, jtc@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For drive-backup and blockdev-backup, expose the manual-cull property, having it default to false. There are no universal creation parameters, so it must be added to each job type that it makes sense for individually. Signed-off-by: John Snow --- blockdev.c | 10 ++++++++-- qapi/block-core.json | 21 ++++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/blockdev.c b/blockdev.c index ee07bca..ba2ebfb 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3198,6 +3198,9 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= BlockJobTxn *txn, if (!backup->has_job_id) { backup->job_id =3D NULL; } + if (!backup->has_manual_cull) { + backup->manual_cull =3D false; + } if (!backup->has_compress) { backup->compress =3D false; } @@ -3290,7 +3293,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= BlockJobTxn *txn, } } =20 - job =3D backup_job_create(backup->job_id, false, bs, target_bs, + job =3D backup_job_create(backup->job_id, backup->manual_cull, bs, tar= get_bs, backup->speed, backup->sync, bmap, backup->com= press, backup->on_source_error, backup->on_target_err= or, BLOCK_JOB_DEFAULT, NULL, NULL, txn, &local_err= ); @@ -3341,6 +3344,9 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, = BlockJobTxn *txn, if (!backup->has_job_id) { backup->job_id =3D NULL; } + if (!backup->has_manual_cull) { + backup->manual_cull =3D false; + } if (!backup->has_compress) { backup->compress =3D false; } @@ -3369,7 +3375,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, = BlockJobTxn *txn, goto out; } } - job =3D backup_job_create(backup->job_id, false, bs, target_bs, + job =3D backup_job_create(backup->job_id, backup->manual_cull, bs, tar= get_bs, backup->speed, backup->sync, NULL, backup->com= press, backup->on_source_error, backup->on_target_err= or, BLOCK_JOB_DEFAULT, NULL, NULL, txn, &local_err= ); diff --git a/qapi/block-core.json b/qapi/block-core.json index de322d1..c646743 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1104,6 +1104,11 @@ # @job-id: identifier for the newly-created block job. If # omitted, the device name will be used. (Since 2.7) # +# @manual-cull: Whether or not the job created by this command needs to be +# cleaned up manually via block-job-cull or not. The default= is +# false. When true, the job will remain in a "completed" sta= te +# until culled manually with block-job-cull. (Since 2.11) +# # @device: the device name or node-name of a root node which should be cop= ied. # # @target: the target of the new image. If the file exists, or if it @@ -1144,9 +1149,10 @@ # Since: 1.6 ## { 'struct': 'DriveBackup', - 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', - '*format': 'str', 'sync': 'MirrorSyncMode', '*mode': 'NewImage= Mode', - '*speed': 'int', '*bitmap': 'str', '*compress': 'bool', + 'data': { '*job-id': 'str', '*manual-cull': 'bool', 'device': 'str', + 'target': 'str', '*format': 'str', 'sync': 'MirrorSyncMode', + '*mode': 'NewImageMode', '*speed': 'int', '*bitmap': 'str', + '*compress': 'bool', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError' } } =20 @@ -1156,6 +1162,11 @@ # @job-id: identifier for the newly-created block job. If # omitted, the device name will be used. (Since 2.7) # +# @manual-cull: Whether or not the job created by this command needs to be +# cleaned up manually via block-job-cull or not. The default= is +# false. When true, the job will remain in a "completed" sta= te +# until culled manually with block-job-cull. (Since 2.11) +# # @device: the device name or node-name of a root node which should be cop= ied. # # @target: the device name or node-name of the backup target node. @@ -1185,8 +1196,8 @@ # Since: 2.3 ## { 'struct': 'BlockdevBackup', - 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', - 'sync': 'MirrorSyncMode', + 'data': { '*job-id': 'str', '*manual-cull': 'bool', 'device': 'str', + 'target': 'str', 'sync': 'MirrorSyncMode', '*speed': 'int', '*compress': 'bool', '*on-source-error': 'BlockdevOnError', --=20 2.9.5