From nobody Tue Feb 10 05:46:46 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.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 1502287590929827.9644603375642; Wed, 9 Aug 2017 07:06:30 -0700 (PDT) Received: from localhost ([::1]:47697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfRcz-000519-Je for importer@patchew.org; Wed, 09 Aug 2017 10:06:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfRay-0003Zi-5A for qemu-devel@nongnu.org; Wed, 09 Aug 2017 10:04:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfRat-0003fW-Oa for qemu-devel@nongnu.org; Wed, 09 Aug 2017 10:04:24 -0400 Received: from smtp1.ntua.gr ([2001:648:2000:de::183]:49066) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfRal-0003W0-P7; Wed, 09 Aug 2017 10:04:12 -0400 Received: from mail.ntua.gr ([IPv6:2a02:587:8030:4e00:989e:98bf:1f16:f20b]) (authenticated bits=0) by smtp1.ntua.gr (8.15.2/8.15.2) with ESMTPSA id v79E3TBc083100 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 9 Aug 2017 17:03:29 +0300 (EEST) (envelope-from el13635@mail.ntua.gr) X-Authentication-Warning: smtp1.ntua.gr: Host [IPv6:2a02:587:8030:4e00:989e:98bf:1f16:f20b] claimed to be mail.ntua.gr From: Manos Pitsidianakis To: qemu-devel Date: Wed, 9 Aug 2017 17:02:52 +0300 Message-Id: <20170809140256.25584-3-el13635@mail.ntua.gr> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170809140256.25584-1-el13635@mail.ntua.gr> References: <20170809140256.25584-1-el13635@mail.ntua.gr> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:648:2000:de::183 Subject: [Qemu-devel] [PATCH v2 2/6] block: add options parameter to bdrv_new_open_driver() 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: Kevin Wolf , Alberto Garcia , Stefan Hajnoczi , qemu-block 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" Allow passing a QDict *options parameter to bdrv_new_open_driver() so that it can be used if a driver needs it upon creation. The previous behaviour (empty bs->options and bs->explicit_options) remains when options is NULL. Signed-off-by: Manos Pitsidianakis Reviewed-by: Alberto Garcia --- block.c | 16 +++++++++++++--- block/commit.c | 4 ++-- block/mirror.c | 2 +- block/vvfat.c | 2 +- include/block/block.h | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/block.c b/block.c index e35d546c08..2de1c29eb3 100644 --- a/block.c +++ b/block.c @@ -1153,16 +1153,26 @@ open_failed: return ret; } =20 +/* + * If options is not NULL, its ownership is transferred to the block layer= . The + * caller must use QINCREF() if they wish to keep ownership. + */ BlockDriverState *bdrv_new_open_driver(BlockDriver *drv, const char *node_= name, - int flags, Error **errp) + int flags, QDict *options, Error **= errp) { BlockDriverState *bs; int ret; =20 bs =3D bdrv_new(); bs->open_flags =3D flags; - bs->explicit_options =3D qdict_new(); - bs->options =3D qdict_new(); + if (options) { + bs->explicit_options =3D qdict_clone_shallow(options); + bs->options =3D qdict_clone_shallow(options); + QDECREF(options); + } else { + bs->explicit_options =3D qdict_new(); + bs->options =3D qdict_new(); + } bs->opaque =3D NULL; =20 update_options_from_flags(bs->options, flags); diff --git a/block/commit.c b/block/commit.c index c7857c3321..539e23c3f8 100644 --- a/block/commit.c +++ b/block/commit.c @@ -342,7 +342,7 @@ void commit_start(const char *job_id, BlockDriverState = *bs, /* Insert commit_top block node above top, so we can block consistent = read * on the backing chain below it */ commit_top_bs =3D bdrv_new_open_driver(&bdrv_commit_top, filter_node_n= ame, 0, - errp); + NULL, errp); if (commit_top_bs =3D=3D NULL) { goto fail; } @@ -494,7 +494,7 @@ int bdrv_commit(BlockDriverState *bs) backing_file_bs =3D backing_bs(bs); =20 commit_top_bs =3D bdrv_new_open_driver(&bdrv_commit_top, NULL, BDRV_O_= RDWR, - &local_err); + NULL, &local_err); if (commit_top_bs =3D=3D NULL) { error_report_err(local_err); goto ro_cleanup; diff --git a/block/mirror.c b/block/mirror.c index c9a6a3ca86..e1a160e6ea 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1164,7 +1164,7 @@ static void mirror_start_job(const char *job_id, Bloc= kDriverState *bs, * reads on the top, while disabling it in the intermediate nodes, and= make * the backing chain writable. */ mirror_top_bs =3D bdrv_new_open_driver(&bdrv_mirror_top, filter_node_n= ame, - BDRV_O_RDWR, errp); + BDRV_O_RDWR, NULL, errp); if (mirror_top_bs =3D=3D NULL) { return; } diff --git a/block/vvfat.c b/block/vvfat.c index a9e207f7f0..6c59473baf 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3194,7 +3194,7 @@ static int enable_write_target(BlockDriverState *bs, = Error **errp) #endif =20 backing =3D bdrv_new_open_driver(&vvfat_write_target, NULL, BDRV_O_ALL= OW_RDWR, - &error_abort); + NULL, &error_abort); *(void**) backing->opaque =3D s; =20 bdrv_set_backing_hd(s->bs, backing, &error_abort); diff --git a/include/block/block.h b/include/block/block.h index ab80195378..d1f03cb48b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -263,7 +263,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict = *parent_options, BlockDriverState *bdrv_open(const char *filename, const char *reference, QDict *options, int flags, Error **errp); BlockDriverState *bdrv_new_open_driver(BlockDriver *drv, const char *node_= name, - int flags, Error **errp); + int flags, QDict *options, Error **= errp); BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, BlockDriverState *bs, QDict *options, int flags); --=20 2.11.0