From nobody Mon Feb 9 07:25:30 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528991522609472.065982036312; Thu, 14 Jun 2018 08:52:02 -0700 (PDT) Received: from localhost ([::1]:41411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTUXS-0002AI-OB for importer@patchew.org; Thu, 14 Jun 2018 11:51:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTUVM-0000jB-Vl for qemu-devel@nongnu.org; Thu, 14 Jun 2018 11:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTUVI-0003mx-0F for qemu-devel@nongnu.org; Thu, 14 Jun 2018 11:49:44 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:37194) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTUVH-0003jm-F9; Thu, 14 Jun 2018 11:49:39 -0400 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 1fTUVE-0004dk-C7; Thu, 14 Jun 2018 17:49:36 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fTUUv-0008Nd-7x; Thu, 14 Jun 2018 18:49:17 +0300 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=jaDLdJ7t1dBMDI65Xp4rNp7EMLJH/QaRYSY5zHdvaG4=; b=LCEcg/vp9hH/S2QHBiFDRUqF9R4aL3loEkCki5icPc13/evkmG03KKKfzX8O0BKRfHaVavBiqnnxyZ33tTJiBUHSzyGWSOR1rTgu2ac94bOfaLOkw1Ozl2EeMNYsK1BPC8knSXpzfClLchgK06btrUrUftN+hQ53lhQA9RUuc4f3p+shjRmncH7NEZ8lipeAEVvL2P0LXZDHjcWuYbwiA8e9dY2hfxUCGQlTdV0j078gkLvkHfcTgQTwDpYZY/ICTexpxvU6qBAsF7DJSSRSg4EvZlq8ycX9CToa4hQ/wlfDZz9qNEkxYUiwbIWu7k5UIGwCELFpmRTq0zjC4BvsoQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 14 Jun 2018 18:49:01 +0300 Message-Id: <5800c9ccc0a6ce2e58d25b127e75cac282458a11.1528991017.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 04/10] block: Allow changing 'force-share' on reopen 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, Markus Armbruster , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 'force-share' is one of the basic BlockdevOptions available for all drivers, but it's silently ignored by bdrv_reopen_prepare/commit(), so the user cannot change it and doesn't get an error explaining that it can't be changed. Since there's no reason why we shouldn't allow changing it and the implementation is trivial, let's just do it. Signed-off-by: Alberto Garcia --- block.c | 11 +++++++++++ include/block/block.h | 1 + 2 files changed, 12 insertions(+) diff --git a/block.c b/block.c index 4c186e54b6..a741300fae 100644 --- a/block.c +++ b/block.c @@ -3169,6 +3169,16 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_stat= e, BlockReopenQueue *queue, } } =20 + reopen_state->force_share =3D qemu_opt_get_bool(opts, BDRV_OPT_FORCE_S= HARE, + false); + if (reopen_state->force_share && (reopen_state->flags & BDRV_O_RDWR)) { + error_setg(errp, + BDRV_OPT_FORCE_SHARE + "=3Don can only be used with read-only images"); + ret =3D -EINVAL; + goto error; + } + /* node-name and driver must be unchanged. Put them back into the QDic= t, so * that they are checked at the end of this function. */ value =3D qemu_opt_get(opts, "node-name"); @@ -3300,6 +3310,7 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state) bs->open_flags =3D reopen_state->flags; bs->read_only =3D !(reopen_state->flags & BDRV_O_RDWR); bs->detect_zeroes =3D reopen_state->detect_zeroes; + bs->force_share =3D reopen_state->force_share; =20 bdrv_refresh_limits(bs, NULL); =20 diff --git a/include/block/block.h b/include/block/block.h index 1e78587331..9306c986ef 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -160,6 +160,7 @@ typedef struct BDRVReopenState { BlockDriverState *bs; int flags; BlockdevDetectZeroesOptions detect_zeroes; + bool force_share; uint64_t perm, shared_perm; QDict *options; QDict *explicit_options; --=20 2.11.0