From nobody Sun Feb 8 20:35:58 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; dkim=fail; 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 1543592508731788.9083668471711; Fri, 30 Nov 2018 07:41:48 -0800 (PST) Received: from localhost ([::1]:33406 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSkvL-0005xB-Cg for importer@patchew.org; Fri, 30 Nov 2018 10:41:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSkZa-0007S8-CR for qemu-devel@nongnu.org; Fri, 30 Nov 2018 10:19:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSkZY-0006Wt-6H for qemu-devel@nongnu.org; Fri, 30 Nov 2018 10:19:18 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:53247) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSkZU-00062a-4v; Fri, 30 Nov 2018 10:19:14 -0500 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gSkYp-0007XI-3v; Fri, 30 Nov 2018 16:18:31 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1gSkYZ-0003ea-L6; Fri, 30 Nov 2018 17:18:15 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=1kXvmYoxyJGoUUXnYzm5gW8sk4itu9NFqrumXuE/Ydc=; b=nvh5x9jy5HtuYKZZS6lpVbReR42Huw2ZVR47JO2to87UxbMRppVQ4NHmbrmR7J2qC2nN3iRsVjJy26I4gVrme2OxSr/ncDqWLi+sPuF7QZe0uSTYXejBLGidqzSVyEvKjVi1oPCJNdhRkFS95+opZAbOp/FfPLImIqg8s+P8zK0BK7hSTHI5iKlmExOCJfbOW7RL7FncY/P4Mq8U8q8cAzuoe2G44DgQAVT/av1ZQI6ecPAdClCfcKvAnE26q1P3XY+fxGGK85F1i+P/XOWWvn3wUlqzYeHnf6bbXZfgbbbbytolS+sE2FNesxegDHucxQNBE+gwG8q2Vmob6qnCzQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 30 Nov 2018 17:17:47 +0200 Message-Id: <0a6d861a7b942e495dc79946a3eb225eb959decf.1543590618.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [RFC PATCH v2 09/12] block: Add 'runtime_opts' and 'mutable_opts' fields to BlockDriver 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 , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch adds two new fields to BlockDriver: - runtime_opts: list of runtime options for a particular block driver. We'll use this list later to detect what options are missing when we try to reopen a block device. - mutable_opts: names of the runtime options that can be reset to their default value after a block device has been added. This way an option can not be reset by omitting it during reopen unless we explicitly allow it. This also sets runtime_opts (and mutable_opts where appropriate) in all drivers that allow reopening. Most of those drivers don't actually support changing any of their options. If the user specifies a new value for an option that can't be changed then we already detect that and forbid it (in bdrv_reopen_prepare()). But if the user omits an option in order to try to reset it to its default value we need to detect that, so we'll use these two new fields for that. Signed-off-by: Alberto Garcia --- block/blkdebug.c | 1 + block/crypto.c | 1 + block/file-posix.c | 10 ++++++++++ block/iscsi.c | 2 ++ block/null.c | 2 ++ block/nvme.c | 1 + block/qcow.c | 1 + block/rbd.c | 1 + block/sheepdog.c | 2 ++ block/vpc.c | 1 + include/block/block_int.h | 5 +++++ 11 files changed, 27 insertions(+) diff --git a/block/blkdebug.c b/block/blkdebug.c index 0759452925..bba7645e09 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -893,6 +893,7 @@ static BlockDriver bdrv_blkdebug =3D { .protocol_name =3D "blkdebug", .instance_size =3D sizeof(BDRVBlkdebugState), .is_filter =3D true, + .runtime_opts =3D &runtime_opts, =20 .bdrv_parse_filename =3D blkdebug_parse_filename, .bdrv_file_open =3D blkdebug_open, diff --git a/block/crypto.c b/block/crypto.c index 33ee01bebd..266b737bde 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -634,6 +634,7 @@ BlockDriver bdrv_crypto_luks =3D { .bdrv_co_create_opts =3D block_crypto_co_create_opts_luks, .bdrv_co_truncate =3D block_crypto_co_truncate, .create_opts =3D &block_crypto_create_opts_luks, + .runtime_opts =3D &block_crypto_runtime_opts_luks, =20 .bdrv_reopen_prepare =3D block_crypto_reopen_prepare, .bdrv_refresh_limits =3D block_crypto_refresh_limits, diff --git a/block/file-posix.c b/block/file-posix.c index 07bbdab953..9bffdf4566 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -439,6 +439,8 @@ static QemuOptsList raw_runtime_opts =3D { }, }; =20 +static const char *const mutable_opts[] =3D { "x-check-cache-dropped", NUL= L }; + static int raw_open_common(BlockDriverState *bs, QDict *options, int bdrv_flags, int open_flags, bool device, Error **errp) @@ -2722,6 +2724,8 @@ BlockDriver bdrv_file =3D { .format_name =3D "file", .protocol_name =3D "file", .instance_size =3D sizeof(BDRVRawState), + .runtime_opts =3D &raw_runtime_opts, + .mutable_opts =3D mutable_opts, .bdrv_needs_filename =3D true, .bdrv_probe =3D NULL, /* no probe for protocols */ .bdrv_parse_filename =3D raw_parse_filename, @@ -3204,6 +3208,8 @@ static BlockDriver bdrv_host_device =3D { .format_name =3D "host_device", .protocol_name =3D "host_device", .instance_size =3D sizeof(BDRVRawState), + .runtime_opts =3D &raw_runtime_opts, + .mutable_opts =3D mutable_opts, .bdrv_needs_filename =3D true, .bdrv_probe_device =3D hdev_probe_device, .bdrv_parse_filename =3D hdev_parse_filename, @@ -3330,6 +3336,8 @@ static BlockDriver bdrv_host_cdrom =3D { .format_name =3D "host_cdrom", .protocol_name =3D "host_cdrom", .instance_size =3D sizeof(BDRVRawState), + .runtime_opts =3D &raw_runtime_opts, + .mutable_opts =3D mutable_opts, .bdrv_needs_filename =3D true, .bdrv_probe_device =3D cdrom_probe_device, .bdrv_parse_filename =3D cdrom_parse_filename, @@ -3463,6 +3471,8 @@ static BlockDriver bdrv_host_cdrom =3D { .format_name =3D "host_cdrom", .protocol_name =3D "host_cdrom", .instance_size =3D sizeof(BDRVRawState), + .runtime_opts =3D &raw_runtime_opts, + .mutable_opts =3D mutable_opts, .bdrv_needs_filename =3D true, .bdrv_probe_device =3D cdrom_probe_device, .bdrv_parse_filename =3D cdrom_parse_filename, diff --git a/block/iscsi.c b/block/iscsi.c index 727dee50bf..adfa6da6b7 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -2433,6 +2433,7 @@ static BlockDriver bdrv_iscsi =3D { .bdrv_close =3D iscsi_close, .bdrv_co_create_opts =3D iscsi_co_create_opts, .create_opts =3D &iscsi_create_opts, + .runtime_opts =3D &runtime_opts, .bdrv_reopen_prepare =3D iscsi_reopen_prepare, .bdrv_reopen_commit =3D iscsi_reopen_commit, .bdrv_co_invalidate_cache =3D iscsi_co_invalidate_cache, @@ -2470,6 +2471,7 @@ static BlockDriver bdrv_iser =3D { .bdrv_close =3D iscsi_close, .bdrv_co_create_opts =3D iscsi_co_create_opts, .create_opts =3D &iscsi_create_opts, + .runtime_opts =3D &runtime_opts, .bdrv_reopen_prepare =3D iscsi_reopen_prepare, .bdrv_reopen_commit =3D iscsi_reopen_commit, .bdrv_co_invalidate_cache =3D iscsi_co_invalidate_cache, diff --git a/block/null.c b/block/null.c index d442d3e901..5df4b46723 100644 --- a/block/null.c +++ b/block/null.c @@ -256,6 +256,7 @@ static BlockDriver bdrv_null_co =3D { .format_name =3D "null-co", .protocol_name =3D "null-co", .instance_size =3D sizeof(BDRVNullState), + .runtime_opts =3D &runtime_opts, =20 .bdrv_file_open =3D null_file_open, .bdrv_parse_filename =3D null_co_parse_filename, @@ -275,6 +276,7 @@ static BlockDriver bdrv_null_aio =3D { .format_name =3D "null-aio", .protocol_name =3D "null-aio", .instance_size =3D sizeof(BDRVNullState), + .runtime_opts =3D &runtime_opts, =20 .bdrv_file_open =3D null_file_open, .bdrv_parse_filename =3D null_aio_parse_filename, diff --git a/block/nvme.c b/block/nvme.c index 29294038fc..655b18dc27 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1143,6 +1143,7 @@ static BlockDriver bdrv_nvme =3D { .format_name =3D "nvme", .protocol_name =3D "nvme", .instance_size =3D sizeof(BDRVNVMeState), + .runtime_opts =3D &runtime_opts, =20 .bdrv_parse_filename =3D nvme_parse_filename, .bdrv_file_open =3D nvme_file_open, diff --git a/block/qcow.c b/block/qcow.c index 4518cb4c35..5cceba7c16 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -1186,6 +1186,7 @@ static QemuOptsList qcow_create_opts =3D { static BlockDriver bdrv_qcow =3D { .format_name =3D "qcow", .instance_size =3D sizeof(BDRVQcowState), + .runtime_opts =3D &qcow_runtime_opts, .bdrv_probe =3D qcow_probe, .bdrv_open =3D qcow_open, .bdrv_close =3D qcow_close, diff --git a/block/rbd.c b/block/rbd.c index 8a1a9f4b6e..6de6112ce8 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1231,6 +1231,7 @@ static QemuOptsList qemu_rbd_create_opts =3D { static BlockDriver bdrv_rbd =3D { .format_name =3D "rbd", .instance_size =3D sizeof(BDRVRBDState), + .runtime_opts =3D &runtime_opts, .bdrv_parse_filename =3D qemu_rbd_parse_filename, .bdrv_refresh_limits =3D qemu_rbd_refresh_limits, .bdrv_file_open =3D qemu_rbd_open, diff --git a/block/sheepdog.c b/block/sheepdog.c index 0125df9d49..28d64af517 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -3288,6 +3288,7 @@ static BlockDriver bdrv_sheepdog_tcp =3D { .bdrv_attach_aio_context =3D sd_attach_aio_context, =20 .create_opts =3D &sd_create_opts, + .runtime_opts =3D &runtime_opts, }; =20 static BlockDriver bdrv_sheepdog_unix =3D { @@ -3325,6 +3326,7 @@ static BlockDriver bdrv_sheepdog_unix =3D { .bdrv_attach_aio_context =3D sd_attach_aio_context, =20 .create_opts =3D &sd_create_opts, + .runtime_opts =3D &runtime_opts, }; =20 static void bdrv_sheepdog_init(void) diff --git a/block/vpc.c b/block/vpc.c index 80c5b2b197..159f5c9ec6 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -1235,6 +1235,7 @@ static BlockDriver bdrv_vpc =3D { .bdrv_get_info =3D vpc_get_info, =20 .create_opts =3D &vpc_create_opts, + .runtime_opts =3D &vpc_runtime_opts, .bdrv_has_zero_init =3D vpc_has_zero_init, }; =20 diff --git a/include/block/block_int.h b/include/block/block_int.h index 05d925227a..6c2dffd8b9 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -345,6 +345,11 @@ struct BlockDriver { =20 /* List of options for creating images, terminated by name =3D=3D NULL= */ QemuOptsList *create_opts; + /* Runtime options for a block device, terminated by name =3D=3D NULL = */ + QemuOptsList *runtime_opts; + /* Names of the runtime options that can be reset by omitting + * their value on reopen, NULL-terminated. */ + const char *const *mutable_opts; =20 /* * Returns 0 for completed check, -errno for internal errors. --=20 2.11.0