From nobody Mon Feb 9 00:42:47 2026 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 1487693722588423.8950915920577; Tue, 21 Feb 2017 08:15:22 -0800 (PST) Received: from localhost ([::1]:46611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgD60-0004ol-08 for importer@patchew.org; Tue, 21 Feb 2017 11:15:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgBuy-0000l2-KV for qemu-devel@nongnu.org; Tue, 21 Feb 2017 09:59:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgBux-00088h-4J for qemu-devel@nongnu.org; Tue, 21 Feb 2017 09:59:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgBuq-00085A-O4; Tue, 21 Feb 2017 09:59:44 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 B71BC3A768D; Tue, 21 Feb 2017 14:59:44 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LEwudF030565; Tue, 21 Feb 2017 09:59:43 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 21 Feb 2017 15:58:27 +0100 Message-Id: <1487689130-30373-32-git-send-email-kwolf@redhat.com> In-Reply-To: <1487689130-30373-1-git-send-email-kwolf@redhat.com> References: <1487689130-30373-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 21 Feb 2017 14:59:44 +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 31/54] 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, jcody@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com 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 --- 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 c551bfc..9a61c1e 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1010,8 +1010,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