From nobody Sun Nov 9 21:40:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155189624446126.662444522726446; Wed, 6 Mar 2019 10:17:24 -0800 (PST) Received: from localhost ([127.0.0.1]:37232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1b6T-0007z1-9d for importer@patchew.org; Wed, 06 Mar 2019 13:17:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1b1e-0004D6-At for qemu-devel@nongnu.org; Wed, 06 Mar 2019 13:12:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1b1b-0005t5-0S for qemu-devel@nongnu.org; Wed, 06 Mar 2019 13:12:17 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:59341) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1b1W-0005iQ-DY; Wed, 06 Mar 2019 13:12:12 -0500 Received: from 87-92-21-153.bb.dnainternet.fi ([87.92.21.153] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1h1b10-0004r2-OD; Wed, 06 Mar 2019 19:11:38 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1h1b0m-0005Oa-Cn; Wed, 06 Mar 2019 20:11:24 +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=2c5Ym+fEVpvdIcHRUv2hT84sE4hv+kIeqmmJRIloSFU=; b=YwckF3i/8B8iQDNTmZxMfZ3Lf0vkTFLOruICDRu9nDZsCLGQ9n1OL6HyyWkyL851O/ciSrZlNezURJBhke46PgaBDyWKDwJWMAMyK9qQeswPFzeXmAvyKz2tyLNF/igOiQVAhfgIIEqF7L+h0dMm57r8uz24Ih8VrlAH+CmlUW5PKikVzOJvV2XHVITT3q5bJMtg7zB/5H1Uj9ZZrOO9NLTm9naLkzzuTroT8+B/fjqw3yF80t+n/Mo2hwxWX7lpX3y8cDpebkWvWCz6xoPlGenTp3jLibJuMCmCyQr096kaYYBbhOOI+CDSbkVWshAWRnIDxHrDf+vlMOdNevzIpg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 6 Mar 2019 20:11:09 +0200 Message-Id: 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] [PATCH v2 09/13] block: Add a 'mutable_opts' field 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" If we reopen a BlockDriverState and there is an option that is present in bs->options but missing from the new set of options then we have to return an error unless the driver is able to reset it to its default value. This patch adds a new 'mutable_opts' field to BlockDriver. This is a list of runtime options that can be modified during reopen. If an option in this list is unspecified on reopen then it must be reset (or return an error). Signed-off-by: Alberto Garcia --- block/file-posix.c | 6 ++++++ block/qcow2.c | 25 +++++++++++++++++++++++++ block/raw-format.c | 3 +++ include/block/block_int.h | 8 ++++++++ 4 files changed, 42 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index ba6ab62a38..07c91a985f 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -431,6 +431,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) @@ -2766,6 +2768,7 @@ BlockDriver bdrv_file =3D { .bdrv_set_perm =3D raw_set_perm, .bdrv_abort_perm_update =3D raw_abort_perm_update, .create_opts =3D &raw_create_opts, + .mutable_opts =3D mutable_opts, }; =20 /***********************************************/ @@ -3217,6 +3220,7 @@ static BlockDriver bdrv_host_device =3D { .bdrv_reopen_abort =3D raw_reopen_abort, .bdrv_co_create_opts =3D hdev_co_create_opts, .create_opts =3D &raw_create_opts, + .mutable_opts =3D mutable_opts, .bdrv_co_invalidate_cache =3D raw_co_invalidate_cache, .bdrv_co_pwrite_zeroes =3D hdev_co_pwrite_zeroes, =20 @@ -3343,6 +3347,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_reopen_abort =3D raw_reopen_abort, .bdrv_co_create_opts =3D hdev_co_create_opts, .create_opts =3D &raw_create_opts, + .mutable_opts =3D mutable_opts, .bdrv_co_invalidate_cache =3D raw_co_invalidate_cache, =20 =20 @@ -3476,6 +3481,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_reopen_abort =3D raw_reopen_abort, .bdrv_co_create_opts =3D hdev_co_create_opts, .create_opts =3D &raw_create_opts, + .mutable_opts =3D mutable_opts, =20 .bdrv_co_preadv =3D raw_co_preadv, .bdrv_co_pwritev =3D raw_co_pwritev, diff --git a/block/qcow2.c b/block/qcow2.c index 7fb2730f09..9421f0d847 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -611,6 +611,30 @@ int qcow2_validate_table(BlockDriverState *bs, uint64_= t offset, return 0; } =20 +static const char *const mutable_opts[] =3D { + QCOW2_OPT_LAZY_REFCOUNTS, + QCOW2_OPT_DISCARD_REQUEST, + QCOW2_OPT_DISCARD_SNAPSHOT, + QCOW2_OPT_DISCARD_OTHER, + QCOW2_OPT_OVERLAP, + QCOW2_OPT_OVERLAP_TEMPLATE, + QCOW2_OPT_OVERLAP_MAIN_HEADER, + QCOW2_OPT_OVERLAP_ACTIVE_L1, + QCOW2_OPT_OVERLAP_ACTIVE_L2, + QCOW2_OPT_OVERLAP_REFCOUNT_TABLE, + QCOW2_OPT_OVERLAP_REFCOUNT_BLOCK, + QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE, + QCOW2_OPT_OVERLAP_INACTIVE_L1, + QCOW2_OPT_OVERLAP_INACTIVE_L2, + QCOW2_OPT_OVERLAP_BITMAP_DIRECTORY, + QCOW2_OPT_CACHE_SIZE, + QCOW2_OPT_L2_CACHE_SIZE, + QCOW2_OPT_L2_CACHE_ENTRY_SIZE, + QCOW2_OPT_REFCOUNT_CACHE_SIZE, + QCOW2_OPT_CACHE_CLEAN_INTERVAL, + NULL +}; + static QemuOptsList qcow2_runtime_opts =3D { .name =3D "qcow2", .head =3D QTAILQ_HEAD_INITIALIZER(qcow2_runtime_opts.head), @@ -5053,6 +5077,7 @@ BlockDriver bdrv_qcow2 =3D { =20 .create_opts =3D &qcow2_create_opts, .strong_runtime_opts =3D qcow2_strong_runtime_opts, + .mutable_opts =3D mutable_opts, .bdrv_co_check =3D qcow2_co_check, .bdrv_amend_options =3D qcow2_amend_options, =20 diff --git a/block/raw-format.c b/block/raw-format.c index e3e5ba2c8a..cec29986cc 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -37,6 +37,8 @@ typedef struct BDRVRawState { bool has_size; } BDRVRawState; =20 +static const char *const mutable_opts[] =3D { "offset", "size", NULL }; + static QemuOptsList raw_runtime_opts =3D { .name =3D "raw", .head =3D QTAILQ_HEAD_INITIALIZER(raw_runtime_opts.head), @@ -570,6 +572,7 @@ BlockDriver bdrv_raw =3D { .create_opts =3D &raw_create_opts, .bdrv_has_zero_init =3D &raw_has_zero_init, .strong_runtime_opts =3D raw_strong_runtime_opts, + .mutable_opts =3D mutable_opts, }; =20 static void bdrv_raw_init(void) diff --git a/include/block/block_int.h b/include/block/block_int.h index c8a83c3eea..8e3f3760a0 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -381,6 +381,14 @@ struct BlockDriver { =20 /* List of options for creating images, terminated by name =3D=3D NULL= */ QemuOptsList *create_opts; + /* + * If this driver supports reopening images this contains a + * NULL-terminated list of the runtime options that can be + * modified. If an option in this list is unspecified during + * reopen then it _must_ be reset to its default value or return + * an error. + */ + const char *const *mutable_opts; =20 /* * Returns 0 for completed check, -errno for internal errors. --=20 2.11.0