From nobody Sun Apr 13 04:30:37 2025 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.zoho.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 1488315036439603.9111172931608; Tue, 28 Feb 2017 12:50:36 -0800 (PST) Received: from localhost ([::1]:36814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cioj8-00007e-T2 for importer@patchew.org; Tue, 28 Feb 2017 15:50:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cioWl-0006A2-CA for qemu-devel@nongnu.org; Tue, 28 Feb 2017 15:37:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cioWf-0007ru-U6 for qemu-devel@nongnu.org; Tue, 28 Feb 2017 15:37:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44154) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cioWc-0007qO-RI; Tue, 28 Feb 2017 15:37:35 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD8FD8047B; Tue, 28 Feb 2017 20:37:34 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-177.ams2.redhat.com [10.36.116.177]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1SKapFN021888; Tue, 28 Feb 2017 15:37:33 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 28 Feb 2017 21:36:21 +0100 Message-Id: <1488314205-16264-23-git-send-email-kwolf@redhat.com> In-Reply-To: <1488314205-16264-1-git-send-email-kwolf@redhat.com> References: <1488314205-16264-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 28 Feb 2017 20:37:34 +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] [PULL 22/46] blockjob: Add permissions to block_job_create() 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, 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" This functions creates a BlockBackend internally, so the block jobs need to tell it what they want to do with the BB. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Acked-by: Fam Zheng --- block/backup.c | 5 +++-- block/commit.c | 5 +++-- block/mirror.c | 5 +++-- block/stream.c | 5 +++-- blockjob.c | 6 +++--- include/block/blockjob_int.h | 4 +++- tests/test-blockjob-txn.c | 6 +++--- tests/test-blockjob.c | 5 +++-- 8 files changed, 24 insertions(+), 17 deletions(-) diff --git a/block/backup.c b/block/backup.c index f38d1d0..c759684 100644 --- a/block/backup.c +++ b/block/backup.c @@ -618,8 +618,9 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, goto error; } =20 - job =3D block_job_create(job_id, &backup_job_driver, bs, speed, - creation_flags, cb, opaque, errp); + /* FIXME Use real permissions */ + job =3D block_job_create(job_id, &backup_job_driver, bs, 0, BLK_PERM_A= LL, + speed, creation_flags, cb, opaque, errp); if (!job) { goto error; } diff --git a/block/commit.c b/block/commit.c index 2ad8138..60d29a9 100644 --- a/block/commit.c +++ b/block/commit.c @@ -235,8 +235,9 @@ void commit_start(const char *job_id, BlockDriverState = *bs, return; } =20 - s =3D block_job_create(job_id, &commit_job_driver, bs, speed, - BLOCK_JOB_DEFAULT, NULL, NULL, errp); + /* FIXME Use real permissions */ + s =3D block_job_create(job_id, &commit_job_driver, bs, 0, BLK_PERM_ALL, + speed, BLOCK_JOB_DEFAULT, NULL, NULL, errp); if (!s) { return; } diff --git a/block/mirror.c b/block/mirror.c index 063925a..18128e6 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1015,8 +1015,9 @@ static void mirror_start_job(const char *job_id, Bloc= kDriverState *bs, buf_size =3D DEFAULT_MIRROR_BUF_SIZE; } =20 - s =3D block_job_create(job_id, driver, bs, speed, creation_flags, - cb, opaque, errp); + /* FIXME Use real permissions */ + s =3D block_job_create(job_id, driver, bs, 0, BLK_PERM_ALL, speed, + creation_flags, cb, opaque, errp); if (!s) { return; } diff --git a/block/stream.c b/block/stream.c index 1523ba7..7f49279 100644 --- a/block/stream.c +++ b/block/stream.c @@ -229,8 +229,9 @@ void stream_start(const char *job_id, BlockDriverState = *bs, BlockDriverState *iter; int orig_bs_flags; =20 - s =3D block_job_create(job_id, &stream_job_driver, bs, speed, - BLOCK_JOB_DEFAULT, NULL, NULL, errp); + /* FIXME Use real permissions */ + s =3D block_job_create(job_id, &stream_job_driver, bs, 0, BLK_PERM_ALL, + speed, BLOCK_JOB_DEFAULT, NULL, NULL, errp); if (!s) { return; } diff --git a/blockjob.c b/blockjob.c index 72b7d4c..27833c7 100644 --- a/blockjob.c +++ b/blockjob.c @@ -123,7 +123,8 @@ void block_job_add_bdrv(BlockJob *job, BlockDriverState= *bs) } =20 void *block_job_create(const char *job_id, const BlockJobDriver *driver, - BlockDriverState *bs, int64_t speed, int flags, + BlockDriverState *bs, uint64_t perm, + uint64_t shared_perm, int64_t speed, int flags, BlockCompletionFunc *cb, void *opaque, Error **errp) { BlockBackend *blk; @@ -160,8 +161,7 @@ void *block_job_create(const char *job_id, const BlockJ= obDriver *driver, } } =20 - /* FIXME Use real permissions */ - blk =3D blk_new(0, BLK_PERM_ALL); + blk =3D blk_new(perm, shared_perm); ret =3D blk_insert_bs(blk, bs, errp); if (ret < 0) { blk_unref(blk); diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h index 8223822..3f86cc5 100644 --- a/include/block/blockjob_int.h +++ b/include/block/blockjob_int.h @@ -119,6 +119,7 @@ struct BlockJobDriver { * generated automatically. * @job_type: The class object for the newly-created job. * @bs: The block + * @perm, @shared_perm: Permissions to request for @bs * @speed: The maximum speed, in bytes per second, or 0 for unlimited. * @cb: Completion function for the job. * @opaque: Opaque pointer value passed to @cb. @@ -134,7 +135,8 @@ 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, int64_t speed, int flags, + BlockDriverState *bs, uint64_t perm, + uint64_t shared_perm, int64_t speed, int flags, BlockCompletionFunc *cb, void *opaque, Error **errp= ); =20 /** diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c index f6dfd08..4ccbda1 100644 --- a/tests/test-blockjob-txn.c +++ b/tests/test-blockjob-txn.c @@ -101,9 +101,9 @@ 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, 0, - BLOCK_JOB_DEFAULT, test_block_job_cb, - data, &error_abort); + s =3D block_job_create(job_id, &test_block_job_driver, bs, + 0, BLK_PERM_ALL, 0, BLOCK_JOB_DEFAULT, + test_block_job_cb, data, &error_abort); s->iterations =3D iterations; s->use_timer =3D use_timer; s->rc =3D rc; diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c index 143ce96..1afe17b 100644 --- a/tests/test-blockjob.c +++ b/tests/test-blockjob.c @@ -30,8 +30,9 @@ 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), 0, - BLOCK_JOB_DEFAULT, block_job_cb, NULL, &errp); + job =3D block_job_create(id, &test_block_job_driver, blk_bs(blk), + 0, BLK_PERM_ALL, 0, BLOCK_JOB_DEFAULT, block_jo= b_cb, + NULL, &errp); if (should_succeed) { g_assert_null(errp); g_assert_nonnull(job); --=20 1.8.3.1