From nobody Mon Apr 29 04:17:24 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 1507082054283369.73355178605914; Tue, 3 Oct 2017 18:54:14 -0700 (PDT) Received: from localhost ([::1]:60987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzYsv-0006m0-Gf for importer@patchew.org; Tue, 03 Oct 2017 21:54:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzYrF-0005mY-06 for qemu-devel@nongnu.org; Tue, 03 Oct 2017 21:52:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzYrD-0000KC-2j for qemu-devel@nongnu.org; Tue, 03 Oct 2017 21:52:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzYr8-0000FO-NF; Tue, 03 Oct 2017 21:52:14 -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 B6814356D7; Wed, 4 Oct 2017 01:52:13 +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 6538E600C8; Wed, 4 Oct 2017 01:52:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B6814356D7 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jsnow@redhat.com From: John Snow To: qemu-block@nongnu.org Date: Tue, 3 Oct 2017 21:52:02 -0400 Message-Id: <20171004015205.20724-2-jsnow@redhat.com> In-Reply-To: <20171004015205.20724-1-jsnow@redhat.com> References: <20171004015205.20724-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.30]); Wed, 04 Oct 2017 01:52:13 +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 v2 1/4] blockjob: add persistent 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 persistent (manually reap) 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 reap 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..93ac194 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 persistent, + 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, persistent, 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..1efac45 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_reap(BlockJob *job) +{ + assert(job && job->persistent =3D=3D true); + job->persistent =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->persistent) { + block_job_do_reap(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_reap(BlockJob **jobptr, Error **errp) +{ + BlockJob *job =3D *jobptr; + /* similarly to _complete, this is QMP-interface only. */ + assert(job->id); + if (!job->persistent) { + error_setg(errp, "The active block job '%s' was not started with " + "\'manual-reap\': true, and so cannot be reaped 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 reaped yet", job->id); + return; + } + + block_job_do_reap(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 persistent, BlockDriverState *bs, uint64_t per= m, 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->persistent =3D persistent; =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->persistent) { + block_job_ref(job); + } + return job; } =20 diff --git a/include/block/block_int.h b/include/block/block_int.h index 99abe2c..a576357 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. + * @persistent: Whether or not this job, when completed, will need to be + * manually reaped via block-job-reap 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 persistent, + 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..cd1b41b 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-reap. */ + bool persistent; + + /* True if and only if persistent 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_reap: + * @job: The job to be reaped. + * @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_reap(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..c19275c 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 persistent, BlockDriverState *bs, uint64_t per= m, 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 04:17:24 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 1507082133896202.2480600142568; Tue, 3 Oct 2017 18:55:33 -0700 (PDT) Received: from localhost ([::1]:60996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzYuL-0007wh-64 for importer@patchew.org; Tue, 03 Oct 2017 21:55:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzYrC-0005kM-RS for qemu-devel@nongnu.org; Tue, 03 Oct 2017 21:52:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzYrB-0000Iz-Uj for qemu-devel@nongnu.org; Tue, 03 Oct 2017 21:52:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzYr9-0000Gq-TR; Tue, 03 Oct 2017 21:52:16 -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 E2147859F7; Wed, 4 Oct 2017 01:52:14 +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 0C257600C8; Wed, 4 Oct 2017 01:52:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E2147859F7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jsnow@redhat.com From: John Snow To: qemu-block@nongnu.org Date: Tue, 3 Oct 2017 21:52:03 -0400 Message-Id: <20171004015205.20724-3-jsnow@redhat.com> In-Reply-To: <20171004015205.20724-1-jsnow@redhat.com> References: <20171004015205.20724-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.26]); Wed, 04 Oct 2017 01:52:15 +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 v2 2/4] qmp: add block-job-reap 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-reap. 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..9580efa 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_reap(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..c08d6fb 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_reap(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_reap(job); + block_job_reap(&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..5cce49d 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-reap: +# +# 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 +# persistent=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-reap', 'data': { 'device': 'str' } } + +## # @BlockdevDiscardOptions: # # Determines how to handle discard requests. --=20 2.9.5 From nobody Mon Apr 29 04:17:24 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 1507082200598709.1176532791716; Tue, 3 Oct 2017 18:56:40 -0700 (PDT) Received: from localhost ([::1]:60999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzYvN-0008VC-QQ for importer@patchew.org; Tue, 03 Oct 2017 21:56:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzYrE-0005lr-GY for qemu-devel@nongnu.org; Tue, 03 Oct 2017 21:52:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzYrD-0000Kv-HA for qemu-devel@nongnu.org; Tue, 03 Oct 2017 21:52:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36431) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzYrA-0000He-Vj; Tue, 03 Oct 2017 21:52:17 -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 ED1B05F2967; Wed, 4 Oct 2017 01:52:15 +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 192AF600C8; Wed, 4 Oct 2017 01:52:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED1B05F2967 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jsnow@redhat.com From: John Snow To: qemu-block@nongnu.org Date: Tue, 3 Oct 2017 21:52:04 -0400 Message-Id: <20171004015205.20724-4-jsnow@redhat.com> In-Reply-To: <20171004015205.20724-1-jsnow@redhat.com> References: <20171004015205.20724-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.38]); Wed, 04 Oct 2017 01:52:16 +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 v2 3/4] blockjob: expose persistent 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 persistent 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 c08d6fb..8bbbf2a 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_persistent) { + backup->persistent =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->persistent, bs, targ= et_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_persistent) { + backup->persistent =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->persistent, bs, targ= et_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 5cce49d..4c7c17b 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) # +# @persistent: Whether or not the job created by this command needs to be +# cleaned up manually via block-job-reap or not. The default = is +# false. When true, the job will remain in a "completed" state +# until reaped manually with block-job-reap. (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', '*persistent': '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) # +# @persistent: Whether or not the job created by this command needs to be +# cleaned up manually via block-job-reap or not. The default = is +# false. When true, the job will remain in a "completed" state +# until reaped manually with block-job-reap. (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', '*persistent': 'bool', 'device': 'str', + 'target': 'str', 'sync': 'MirrorSyncMode', '*speed': 'int', '*compress': 'bool', '*on-source-error': 'BlockdevOnError', --=20 2.9.5 From nobody Mon Apr 29 04:17:24 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507082054793637.7911216601457; Tue, 3 Oct 2017 18:54:14 -0700 (PDT) Received: from localhost ([::1]:60986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzYst-0006kK-Am for importer@patchew.org; Tue, 03 Oct 2017 21:54:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzYrI-0005py-GK for qemu-devel@nongnu.org; Tue, 03 Oct 2017 21:52:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzYrF-0000Q4-CU for qemu-devel@nongnu.org; Tue, 03 Oct 2017 21:52:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41476) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzYrB-0000If-W2; Tue, 03 Oct 2017 21:52:18 -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 01BA9859F7; Wed, 4 Oct 2017 01:52:17 +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 2440A600C8; Wed, 4 Oct 2017 01:52:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 01BA9859F7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jsnow@redhat.com From: John Snow To: qemu-block@nongnu.org Date: Tue, 3 Oct 2017 21:52:05 -0400 Message-Id: <20171004015205.20724-5-jsnow@redhat.com> In-Reply-To: <20171004015205.20724-1-jsnow@redhat.com> References: <20171004015205.20724-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.26]); Wed, 04 Oct 2017 01:52:17 +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 v2 4/4] iotests: test manual job reaping 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" RFC: The error returned by a job creation command when that device already has a job attached has become misleading; "Someone should do something about that!" Signed-off-by: John Snow --- tests/qemu-iotests/056 | 227 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/056.out | 4 +- 2 files changed, 229 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/056 b/tests/qemu-iotests/056 index 04f2c3c..d6bed20 100755 --- a/tests/qemu-iotests/056 +++ b/tests/qemu-iotests/056 @@ -29,6 +29,26 @@ backing_img =3D os.path.join(iotests.test_dir, 'backing.= img') test_img =3D os.path.join(iotests.test_dir, 'test.img') target_img =3D os.path.join(iotests.test_dir, 'target.img') =20 +def img_create(img, fmt=3Diotests.imgfmt, size=3D'64M', **kwargs): + fullname =3D os.path.join(iotests.test_dir, '%s.%s' % (img, fmt)) + optargs =3D [] + for k,v in kwargs.iteritems(): + optargs =3D optargs + ['-o', '%s=3D%s' % (k,v)] + args =3D ['create', '-f', fmt] + optargs + [fullname, size] + iotests.qemu_img(*args) + return fullname + +def try_remove(img): + try: + os.remove(img) + except OSError: + pass + +def io_write_patterns(img, patterns): + for pattern in patterns: + iotests.qemu_io('-c', 'write -P%s %s %s' % pattern, img) + + class TestSyncModesNoneAndTop(iotests.QMPTestCase): image_len =3D 64 * 1024 * 1024 # MB =20 @@ -108,5 +128,212 @@ class TestBeforeWriteNotifier(iotests.QMPTestCase): event =3D self.cancel_and_wait() self.assert_qmp(event, 'data/type', 'backup') =20 +class BackupTest(iotests.QMPTestCase): + def setUp(self): + self.vm =3D iotests.VM() + self.test_img =3D img_create('test') + self.dest_img =3D img_create('dest') + self.vm.add_drive(self.test_img) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + try_remove(self.test_img) + try_remove(self.dest_img) + + def hmp_io_writes(self, drive, patterns): + for pattern in patterns: + self.vm.hmp_qemu_io(drive, 'write -P%s %s %s' % pattern) + self.vm.hmp_qemu_io(drive, 'flush') + + def qmp_backup_and_wait(self, cmd=3D'drive-backup', serror=3DNone, + aerror=3DNone, **kwargs): + return (self.qmp_backup(cmd, serror, **kwargs) and + self.qmp_backup_wait(kwargs['device'], aerror)) + + def qmp_backup(self, cmd=3D'drive-backup', + error=3DNone, **kwargs): + self.assertTrue('device' in kwargs) + res =3D self.vm.qmp(cmd, **kwargs) + if error: + self.assert_qmp(res, 'error/desc', error) + return False + self.assert_qmp(res, 'return', {}) + return True + + def qmp_backup_wait(self, device, error=3DNone): + event =3D self.vm.event_wait(name=3D"BLOCK_JOB_COMPLETED", + match=3D{'data': {'device': device}}) + self.assertNotEqual(event, None) + try: + failure =3D self.dictpath(event, 'data/error') + except AssertionError: + # Backup succeeded. + self.assert_qmp(event, 'data/offset', event['data']['len']) + return True + else: + # Failure. + self.assert_qmp(event, 'data/error', qerror) + return False + + def test_reap_false(self): + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + self.qmp_backup_and_wait(device=3D'drive0', format=3Diotests.imgfm= t, + sync=3D'full', target=3Dself.dest_img, pe= rsistent=3DFalse) + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + + def test_reap_true(self): + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + self.qmp_backup_and_wait(device=3D'drive0', format=3Diotests.imgfm= t, + sync=3D'full', target=3Dself.dest_img, pe= rsistent=3DTrue) + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return[0]/finished', True) + res =3D self.vm.qmp('block-job-reap', device=3D'drive0') + self.assert_qmp(res, 'return', {}) + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + + def test_reap_bad_id(self): + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + res =3D self.vm.qmp('block-job-reap', device=3D'foobar') + self.assert_qmp(res, 'error/class', 'DeviceNotActive') + + def test_reap_collision(self): + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + self.qmp_backup_and_wait(device=3D'drive0', format=3Diotests.imgfm= t, + sync=3D'full', target=3Dself.dest_img, pe= rsistent=3DTrue) + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return[0]/finished', True) + # Leave zombie job un-reaped, observe a failure: + res =3D self.qmp_backup_and_wait(serror=3D'Need a root block node', + device=3D'drive0', format=3Diotests= .imgfmt, + sync=3D'full', target=3Dself.dest_i= mg, + persistent=3DTrue) + self.assertEqual(res, False) + # OK, reap the zombie. + res =3D self.vm.qmp('block-job-reap', device=3D'drive0') + self.assert_qmp(res, 'return', {}) + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + # Ensure it's really gone. + self.qmp_backup_and_wait(device=3D'drive0', format=3Diotests.imgfm= t, + sync=3D'full', target=3Dself.dest_img, pe= rsistent=3DTrue) + + def test_reap_premature(self): + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + # Give blkdebug something to chew on + self.hmp_io_writes('drive0', + (('0x9a', 0, 512), + ('0x55', '8M', '352k'), + ('0x78', '15872k', '1M'))) + # Add destination node via blkdebug + res =3D self.vm.qmp('blockdev-add', + node_name=3D'target0', + driver=3Diotests.imgfmt, + file=3D{ + 'driver': 'blkdebug', + 'image': { + 'driver': 'file', + 'filename': self.dest_img + }, + 'inject-error': [{ + 'event': 'write_aio', + 'errno': 5, + 'immediately': False, + 'once': True + }], + }) + self.assert_qmp(res, 'return', {}) + + res =3D self.qmp_backup(cmd=3D'blockdev-backup', + device=3D'drive0', target=3D'target0', + on_target_error=3D'stop', + sync=3D'full', + persistent=3DTrue) + self.assertTrue(res) + event =3D self.vm.event_wait(name=3D"BLOCK_JOB_ERROR", + match=3D{'data': {'device': 'drive0'}}) + self.assertNotEqual(event, None) + # OK, job should be wedged + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return[0]/finished', False) + res =3D self.vm.qmp('block-job-reap', device=3D'drive0') + self.assert_qmp(res, 'error/desc', + "The active block job 'drive0' has not yet termina= ted, and cannot be reaped yet") + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return[0]/finished', False) + # OK, unstick job and move forward. + res =3D self.vm.qmp('block-job-resume', device=3D'drive0') + self.assert_qmp(res, 'return', {}) + res =3D self.qmp_backup_wait(device=3D'drive0') + self.assertTrue(res) + # Job should now be languishing: + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return[0]/finished', True) + res =3D self.vm.qmp('block-job-reap', device=3D'drive0') + self.assert_qmp(res, 'return', {}) + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + + def test_reap_erroneous(self): + '''Same as above test, but manual-reap is set to False.''' + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + # Give blkdebug something to chew on + self.hmp_io_writes('drive0', + (('0x9a', 0, 512), + ('0x55', '8M', '352k'), + ('0x78', '15872k', '1M'))) + # Add destination node via blkdebug + res =3D self.vm.qmp('blockdev-add', + node_name=3D'target0', + driver=3Diotests.imgfmt, + file=3D{ + 'driver': 'blkdebug', + 'image': { + 'driver': 'file', + 'filename': self.dest_img + }, + 'inject-error': [{ + 'event': 'write_aio', + 'errno': 5, + 'immediately': False, + 'once': True + }], + }) + self.assert_qmp(res, 'return', {}) + + res =3D self.qmp_backup(cmd=3D'blockdev-backup', + device=3D'drive0', target=3D'target0', + on_target_error=3D'stop', + sync=3D'full', + persistent=3DFalse) + self.assertTrue(res) + event =3D self.vm.event_wait(name=3D"BLOCK_JOB_ERROR", + match=3D{'data': {'device': 'drive0'}}) + self.assertNotEqual(event, None) + # OK, job should be wedged + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return[0]/finished', False) + res =3D self.vm.qmp('block-job-reap', device=3D'drive0') + self.assert_qmp(res, 'error/desc', + "The active block job 'drive0' was not started wit= h 'manual-reap': true, and so cannot be reaped as it will clean up after it= self automatically") + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return[0]/finished', False) + # OK, unstick job and move forward. + res =3D self.vm.qmp('block-job-resume', device=3D'drive0') + self.assert_qmp(res, 'return', {}) + res =3D self.qmp_backup_wait(device=3D'drive0') + self.assertTrue(res) + # Job should now be gone: + res =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(res, 'return', []) + if __name__ =3D=3D '__main__': iotests.main(supported_fmts=3D['qcow2', 'qed']) diff --git a/tests/qemu-iotests/056.out b/tests/qemu-iotests/056.out index 8d7e996..dae404e 100644 --- a/tests/qemu-iotests/056.out +++ b/tests/qemu-iotests/056.out @@ -1,5 +1,5 @@ -... +......... ---------------------------------------------------------------------- -Ran 3 tests +Ran 9 tests =20 OK --=20 2.9.5